创建表的规范写法

2020-12-30 17:34:15 浏览数 (1)

CREATE TABLE [IF NOT EXISTS] tbl_name( 字段名称 字段类型 [UNSIGNED|ZEROFILL] [NOT NULL] [DEFAULT 默认值] [[PRIMARY] KEY| UNIQUE [KEY]] [AUTO_INCREMENT] )ENGINE=INNODB CHARSET=UTF8 AUTO_INCREMENT=100;

如: CREATE TABLE IF NOT EXISTS user10( id SMALLINT UNSIGNED KEY AUTO_INCREMENT, username VARCHAR(20) NOT NULL UNIQUE, password CHAR(32) NOT NULL, email VARCHAR(50) NOT NULL DEFAULT ‘382771946@qq.com’, age TINYINT UNSIGNED DEFAULT 18, sex ENUM(‘男’,’女’,’保密’) DEFAULT ‘保密’, addr VARCHAR(200) NOT NULL DEFAULT ‘北京’, salary FLOAT(6,2), regTime INT UNSIGNED, face CHAR(100) NOT NULL DEFAULT ‘default.jpg’ );

0 人点赞