mysql --explicit_mysql explicit_defaults_for_timestamp参数

1 mysql> create tabletimestamp_eg(2 -> id int not nullauto_increment,3 -> time1 timestamp,4 -> time2 timestamp,5 -> time3 timestamp NOT NULL DEFAULT '2010-01-01 00:00:00',6 -> time4 timestamp,7 -> primary key(id));8 Query OK, 0 rows affected (0.01sec)9

10 mysql> insert into timestamp_eg(id) values(1);11 Query OK, 1 row affected (0.00sec)12

13 mysql> select * fromtimestamp_eg;14 +----+---------------------+---------------------+---------------------+---------------------+

15 | id | time1 | time2 | time3 | time4 |

16 +----+---------------------+---------------------+---------------------+---------------------+

17 | 1 | 2015-12-16 09:23:33 | 0000-00-00 00:00:00 | 2010-01-01 00:00:00 | 0000-00-00 00:00:00 |

18 +----+---------------------+---------------------+---------------------+---------------------+

19 1 row in set (0.01sec)20

21 mysql> update timestamp_eg set id=2 where id=1;22 Query OK, 1 row affected (0.02sec)23 Rows matched: 1 Changed: 1 Warnings: 0

24

25 mysql> select * fromtimestamp_eg;26 +----+---------------------+---------------------+---------------------+---------------------+

27 | id | time1 | time2 | time3 | time4 |

28 +----+---------------------+---------------------+---------------------+---------------------+

29 | 2 | 2015-12-16 09:25:01 | 0000-00-00 00:00:00 | 2010-01-01 00:00:00 | 0000-00-00 00:00:00 |

30 +----+---------------------+---------------------+---------------------+---------------------+

31 1 row in set (0.00sec)32

33 mysql> insert into timestamp_eg(id,time4) values(3,'2011-01-01 00:00:00');34 Query OK, 1 row affected (0.00sec)35

36 mysql> select * fromtimestamp_eg;37 +----+---------------------+---------------------+---------------------+---------------------+

38 | id | time1 | time2 | time3 | time4 |

39 +----+---------------------+---------------------+---------------------+---------------------+

40 | 2 | 2015-12-16 09:25:01 | 0000-00-00 00:00:00 | 2010-01-01 00:00:00 | 0000-00-00 00:00:00 |

41 | 3 | 2015-12-16 09:28:04 | 0000-00-00 00:00:00 | 2010-01-01 00:00:00 | 2011-01-01 00:00:00 |

42 +----+---------------------+---------------------+---------------------+---------------------+

43 2 rows in set (0.00sec)44

45 mysql> update timestamp_eg set id=4 where id=3;46 Query OK, 1 row affected (0.00sec)47 Rows matched: 1 Changed: 1 Warnings: 0

48

49 mysql> select * fromtimestamp_eg;50 +----+---------------------+---------------------+---------------------+---------------------+

51 | id | time1 | time2 | time3 | time4 |

52 +----+---------------------+---------------------+---------------------+---------------------+

53 | 2 | 2015-12-16 09:25:01 | 0000-00-00 00:00:00 | 2010-01-01 00:00:00 | 0000-00-00 00:00:00 |

54 | 4 | 2015-12-16 09:28:24 | 0000-00-00 00:00:00 | 2010-01-01 00:00:00 | 2011-01-01 00:00:00 |

55 +----+---------------------+---------------------+---------------------+---------------------+

56 2 rows in set (0.00sec)57

58 mysql>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值