mysql中TIMESTAMP类型和其他的类型有点不一样(在没有设置explicit_defaults_for_timestamp=1的情况下)
1、在默认情况下,如果TIMESTAMP列没有显式的指明null属性,那么该列会被自动加上not null属性(而其他类型的列如果没有被显式的指定not null,那么是允许null值的),如果往这个列中插入null值,会自动的设置该列的值为current timestamp值
2、表中的第一个TIMESTAMP列,如果没有指定null属性或者没有指定默认值,也没有指定ON UPDATE语句。那么该列会自动被加上DEFAULT CURRENT_TIMESTAMP和ON UPDATE CURRENT_TIMESTAMP属性。
3、第一个TIMESTAMP列之后的其他的TIMESTAMP类型的列,如果没有指定null属性,也没有指定默认值,那么该列会被自动加上DEFAULT '0000-00-00 00:00:00'属性。如果insert语句中没有为该列指定值,那么该列中插入'0000-00-00 00:00:00',并且没有warning
如果我们在启动的时候在配置文件中指定了explicit_defaults_for_timestamp=1,mysql会按照如下的方式处理TIMESTAMP 列
1、此时如果TIMESTAMP列没有显式的指定not null属性,那么默认的该列可以为null,此时向该列中插入null值时,会直接记录null,而不是current timestamp。
2、不会自动的为表中的第一个TIMESTAMP列加上DEFAULT CURRENT_TIMESTAMP 和ON UPDATE CURRENT_TIMESTAMP属性,除非你在建表的时候显式的指明
3、如果TIMESTAMP列被加上了not null属性,并且没有指定默认值。这时如果向表中插入记录,但是没有给该TIMESTAMP列指定值的时候,如果strict sql_mode被指定了,那么会直接报错。如果strict sql_mode没有被指定,那么会向该列中插入'0000-00-00 00:00:00'并且产生一个warning
文章最后更新时间:
2019年01月17日 21:26:51
타오바오구매대행
find best asbestos awareness training australia licence in below asbestos training
What is the supplement Lights Out CBD Gummies about? : The first fact that will help you is the organic composition of Lights Out CBD Gummies and which is rare and also will not affect or disturb your ongoing life at any cost. You may prefer a little exercise as per your choice or not, and the results from using this supplement will be the most incredible of all. That is the beauty of this freshly made relief product because it will work for your health at all costs, but without damaging it. Here is the real supplement whose need was always felt among users. Lights Out CBD Gummies
to see haima sampartyadak website you can click here سام پارت یدک هایما
find best white card australia licence in below white card licence
cabana-de-inchiriat.ro este o platforma de listare a cabanelor, gratuita si fara comisioane. Rezervarea este facuta direct cu propietarul, fara intermediari! Cazare la munte, la mare, toata romania.
Hello to every body, it's my first visit of this blog
Hello to every body, it's my first visit of this blog