Correcting teacher:灭绝师太
Correction status:qualified
Teacher's comments:
演示效果
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| qidian |
| sys |
| video |
+--------------------+
6 rows in set (0.02 sec)
mysql> mysql -v;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql -v' at line 1
mysql> desc video
-> ;
1146 - Table 'qidian.video' doesn't exist
mysql> desc video;
1146 - Table 'qidian.video' doesn't exist
mysql> use video
-> ;
Database changed
mysql> show tables;
+-----------------+
| Tables_in_video |
+-----------------+
| admins |
+-----------------+
1 row in set (0.02 sec)
mysql> desc admins;
+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| username | varchar(20) | NO | | NULL | |
| password | varchar(32) | NO | | NULL | |
| truename | varchar(20) | NO | | NULL | |
| gid | int(10) | NO | | NULL | |
| status | tinyint(1) | NO | | 0 | |
| add_time | int(10) | NO | | NULL | |
+----------+-------------+------+-----+---------+----------------+
7 rows in set (0.03 sec)
mysql> CREATE TABLE IF NOT EXISTS `runoob_tbl`(
`runoob_id` INT UNSIGNED AUTO_INCREMENT,
`runoob_title` VARCHAR(100) NOT NULL,
`runoob_author` VARCHAR(40) NOT NULL,
`submission_date` DATE,
PRIMARY KEY ( `runoob_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.03 sec)
mysql> desc runoob_tbl
-> ;
+-----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+----------------+
| runoob_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| runoob_title | varchar(100) | NO | | NULL | |
| runoob_author | varchar(40) | NO | | NULL | |
| submission_date | date | YES | | NULL | |
+-----------------+------------------+------+-----+---------+----------------+
4 rows in set (0.03 sec)
mysql> insert into runoob_tbl(runoob_title,runoob_author,submission_date) value('a','as',432432);
1292 - Incorrect date value: '432432' for column 'submission_date' at row 1
mysql> insert into runoob_tbl(runoob_title,runoob_author,submission_date) value('a','as','432432');
1292 - Incorrect date value: '432432' for column 'submission_date' at row 1
mysql> insert into runoob_tbl(runoob_title,runoob_author,submission_date) value('a','as','2002/1/1');
Query OK, 1 row affected (0.00 sec)
mysql> select *from runoob_tbl;
+-----------+--------------+---------------+-----------------+
| runoob_id | runoob_title | runoob_author | submission_date |
+-----------+--------------+---------------+-----------------+
| 1 | a | as | 2002-01-01 |
+-----------+--------------+---------------+-----------------+
1 row in set (0.03 sec)
mysql>