【SQL】利⽤sql语句在mysql的表中插⼊date类型的数据,
⼀. 创建⼀个数据库
编程猫下载的素材在哪个文件1. create database test
⼆. 在数据库中创建表
ospf协议之详细图解create TABLE employees (emp_no int(4) not null,birth_date date not null,first_name varchar(14) not null,last_name varchar(16) not null,gender char(1) no t null,hire_dare date not null,primary key (emp_no));
三. 表结构
mysql> desc employees;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| emp_no | int(4) | NO | PRI | NULL | |
| birth_date | date | NO | | NULL | |
| first_name | varchar(14) | NO | | NULL | |
| last_name | varchar(16) | NO | | NULL | |
| gender | char(1) | NO | | NULL | |
| hire_dare | date | NO | | NULL | |
+------------+-------------+------+-----+---------+-------+
oracle即时客户端下载6 rows in set (0.73 sec)
四. 插⼊记录
mysql> insert into employees values(2,1998-07-14,'li','bc','w',2019-02-21);
Query OK, 1 row affected, 2 warnings (0.00 sec)
可以看到有告警
五. 查看表内容
mysql> select * from employees;
+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_dare |
+--------+------------+------------+-----------+--------+------------+
| 1 | 0000-00-00 | mai | yp | m | 0000-00-00 |
mysql语句分类| 2 | 0000-00-00 | li | bc | w | 0000-00-00 |
插⼊date类型的字段失效
六. 解决
mysql> insert into employees values(3,1998-07-14,'li','bc','w',20190211);
ERROR 1062 (23000): Duplicate entry '3' for key 'PRIMARY'
二进制八进制十进制十六进制提目mysql> insert into employees values(4,1998-07-14,'li','bc','w',20190211);
Query OK, 1 row affected, 1 warning (0.05 sec)
mysql> select * from employees;
+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_dare |
编程游戏异常+--------+------------+------------+-----------+--------+------------+
| 1 | 0000-00-00 | mai | yp | m | 0000-00-00 |
| 2 | 0000-00-00 | li | bc | w | 0000-00-00 |
| 3 | 0000-00-00 | li | bc | w | 0000-00-00 |
| 4 | 0000-00-00 | li | bc | w | 2019-02-11 |
+--------+------------+------------+-----------+--------+------------+
4 rows in set (0.00 sec)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论