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
Exceptional post however , I was wanting to know if you could write a litte more on this topic? I'd be very grateful if you could elaborate a little bit more. Bless you!mississauga movers
penis enlargement
penis enlargement
find best white card australia licence in below white card australia
We are an extremely well respected Loyalty Escorts Company which provide escort companies in London peach escorts and the surrounding areas. We satisfaction our selves of experiencing in our community some of the most beautiful and captivating escorts in London. There are all sorts of escorts available so you can rest assure you can find what you are seeking. All the Loyalty London Escorts happen to be sophisticated and reliable, we have a becoming a member of proses and we be sure that all are beautiful, intelligent and excitement to be with. Nearly every day Just about all photos are genuine and we have new Loyalty Young ladies joining. All Loyalty Escorts are for sale to in contact or out calls. They all have their own apartments in main London where they are able to entertain you or they will be happy to satisfy you at your hotel or a dinner day or for just about any event you could show up at! Like everybody, all girls happen to be always attempting to improve themselves therefore therefor they might be very delighted to listen to your comments and feel. In every girls page, there exists a review facility consequently feel free to provide your fed back again and share it with everybody else.
penis enlargement