create table命令用來創(chuàng)建數(shù)據(jù)表。
create table命令格式:create table <表名> (<字段名1> <類型1> [,..<字段名n> <類型n>]);
例如,建立一個名為MyClass的表:
字段名 | 數(shù)字類型 | 數(shù)據(jù)寬度 | 是否為空 | 是否主鍵 | 自動增加 | 默認(rèn)值 |
id | int | 4 | 否 | primary key | auto_increment | |
name | char | 20 | 否 | | | |
sex | int | 4 | 否 | | | 0 |
degree | double | 16 | 是 | | | |
mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));