在MySQL中创建带有TIMESTAMP字段的表?
为此,您可以在MySQL中使用TIMESTAMP关键字。
让我们创建一个表-
mysql> create table demo50 −> ( −> id int not null auto_increment primary key, −> start_date timestamp default current_timestamp not null, −> end_date timestamp default current_timestamp not null −> );
借助insert命令将一些记录插入表中-
mysql> insert into demo50 values();
mysql> insert into demo50(end_date) values('2020−12−21');
mysql> insert into demo50(start_date) values('2020−01−01');使用select语句显示表中的记录-
mysql> select *from demo50;
这将产生以下输出-
+----+---------------------+---------------------+ | id | start_date | end_date | +----+---------------------+---------------------+ | 1 | 2020−11−04 20:54:31 | 2020−11−04 20:54:31 | | 2 | 2020−11−04 20:54:53 | 2020−12−21 00:00:00 | | 3 | 2020−01−01 00:00:00 | 2020−11−04 20:55:04 | +----+---------------------+---------------------+ 3 rows in set (0.00 sec)
热门推荐
10 花茶礼盒生日祝福语简短
11 朋友布置新房祝福语简短
12 男孩卡通祝福语简短霸气
13 订婚花束祝福语妈妈简短
14 领证结婚搞笑祝福语简短
15 作品棒棒哒祝福语简短
16 小学毕业英语祝福语简短
17 毕业祝福语贺词大全简短
18 给老板简短祝福语大全