天天看点

mysql数据库介绍笔记_MySQL数据库之MySQL读书笔记

本文主要向大家介绍了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数据库频道!