在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 红包祝福语简短10字
18 周六早晨祝福语简短