柳生飘絮 2019-04-05
代码如下:
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)