MySQL如何创建时间数据类型以及插入时间数据【笔记】

笔记
MySQL如何创建时间数据类型以及插入时间数据。

mysql> create table choices
    -> (
    -> no int not null,
    -> sid int not null,
    -> cid int not null,
    -> Takedate date null,
    -> score int null
    -> );
Query OK, 0 rows affected (0.02 sec)

在这里插入图片描述

mysql> select * from choices;
+-----+------+-------+------------+-------+
| no  | sid  | cid   | Takedate   | score |
+-----+------+-------+------------+-------+
|  58 | 1201 | 10001 | 2022-09-01 |    76 |
| 253 | 1205 | 10006 | 2021-03-01 |    87 |
| 640 | 1215 | 10002 | 2022-09-06 |  NULL |
+-----+------+-------+------------+-------+
3 rows in set (0.00 sec)

mysql> insert into takecourse.choices
    -> values
    -> (984,1205,10001,'2022-09-01',54),
    -> (1270,1201,10005,'2021-03-01',92),
    -> (2143,1205,10005,'2022-09-01',82),
    -> (2371,1201,10002,'2022-09-01',77),
    -> (2715,1207,10001,'2022-09-01',67),
    -> (3262,1207,10005,'2022-09-01',90),
    -> (4144,1207,10004,'2022-09-01',60),
    -> (5519,1205,10002,'2021-03-01',NULL),
    -> (5935,1215,10001,'2022-09-01',70),
    -> (5987,1201,10004,'2021-03-01',82),
    -> (6353,1205,10006,'2022-09-01',76),
    -> (6805,1201,10003,'2021-03-01',88),
    -> (6824,1205,10004,'2022-09-01',72),
    -> (7004,1207,10002,'2022-09-01',64),
    -> (7901,1215,10002,'2021-09-01',75),
    -> (8311,1215,10006,'2022-09-01',63);
Query OK, 16 rows affected (0.01 sec)
Records: 16  Duplicates: 0  Warnings: 0

在这里插入图片描述

mysql> drop table choices;
Query OK, 0 rows affected (0.03 sec)

mysql> show tables;
Empty set (0.00 sec)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值