本文主要向大家介紹了MySQL資料庫之MySQL讀書筆記,通過具體的内容向大家展現,希望對大家學習MySQL資料庫有所幫助。
mysql> CREATE TABLE tb6(
-> id SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
-> username VARCHAR(20) NOT NULL UNIQUE KEY,
-> sex ENUM('1','2','3') DEFAULT '3'
-> );
Query OK, 0 rows affected (0.58 sec)
mysql> SHOW COLUMNS FROM tb6;
+----------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------------------+------+-----+---------+----------------+
| id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| username | varchar(20) | NO | UNI | NULL | |
| sex | enum('1','2','3') | YES | | 3 | |
+----------+----------------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)
mysql> INSERT tb6(username) VALUES 'Tom';
ERROR 1064 (42000): 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 ''Tom'' at line 1
mysql> INSERT tb6(username) VALUES( 'Tom');
Query OK, 1 row affected (0.06 sec)
本文由職坐标整理并釋出,希望對同學們學習MySQL有所幫助,更多内容請關注職坐标資料庫MySQL資料庫頻道!