复制代码 代码如下:
mysql> create table student(
-> id int primary key,
-> name varchar(20),
-> sex boolean
-> );
Query OK, 0 rows affected (0.09 sec)
复制代码 代码如下:
mysql> create table student2(
-> id int,
-> course_id int,
-> score float,
-> primary key(id,course_id)
-> );
Query OK, 0 rows affected (0.11 sec)
复制代码 代码如下:
mysql> create table student3(
-> id int primary key,
-> course_id int,
-> teacher varchar(20),
-> constraint fk foreign key(id,course_id)
-> references student2(id,course_id)
-> );
Query OK, 0 rows affected (0.12 sec)
复制代码 代码如下:
mysql> create table student4(
-> id int not null,
-> name varchar(20),
-> sex boolean
-> );
Query OK, 0 rows affected (0.10 sec)
复制代码 代码如下:
mysql> create table student5(
-> id int unique,
-> name varchar(20)
-> );
Query OK, 0 rows affected (0.10 sec)
复制代码 代码如下:
mysql> create table student6(
-> id int primary key auto_increment,
-> name varchar(20)
-> );
Query OK, 0 rows affected (0.12 sec)
复制代码 代码如下:
mysql> create table student7(
-> id int primary key,
-> score int default 0
-> );
Query OK, 0 rows affected (0.10 sec)
新闻热点
疑难解答