欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

sql插入默认值为当前时间 乔乐共享默认值自增长当前时间 

程序员文章站 2024-03-19 21:05:10
...
mysql> desc message;
+---------+--------------+------+-----+-------------------+----------------+
| Field   | Type         | Null | Key | Default           | Extra          |
+---------+--------------+------+-----+-------------------+----------------+
| id      | int(11)      | NO   | PRI | NULL              | auto_increment |
| name    | varchar(20)  | YES  |     | NULL              |                |
| content | varchar(500) | YES  |     | NULL              |                |
| time    | timestamp    | YES  |     | CURRENT_TIMESTAMP |                |
+---------+--------------+------+-----+-------------------+----------------+
4 rows in set (0.02 sec)

 

CREATE TABLE mytable (
  mydate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  ....)