復制代碼 代碼如下:
 
mysql> alter table student rename person; 
Query OK, 0 rows affected (0.03 sec) 
復制代碼 代碼如下:
 
mysql> alter table person modify name varchar(20); 
Query OK, 0 rows affected (0.18 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person change stu_name name varchar(25); 
Query OK, 0 rows affected (0.20 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person add sex boolean; 
Query OK, 0 rows affected (0.21 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person add age int not null; 
Query OK, 0 rows affected (0.17 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person add num int primary key first; 
Query OK, 0 rows affected (0.20 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person add birth date after name; 
Query OK, 0 rows affected (0.20 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person drop sex; 
Query OK, 0 rows affected (0.18 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person modify id int first; 
Query OK, 0 rows affected (0.20 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table person modify name varchar(25) after id; 
Query OK, 0 rows affected (0.18 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table user rename person; 
Query OK, 0 rows affected (0.05 sec) 
復制代碼 代碼如下:
 
mysql> alter table score add constraint fk foreign key(stu_id) references student(id); 
Query OK, 10 rows affected (0.18 sec) 
Records: 10 Duplicates: 0 Warnings: 0 
復制代碼 代碼如下:
 
mysql> alter table student3 drop foreign key fk; 
Query OK, 0 rows affected (0.18 sec) 
Records: 0 Duplicates: 0 Warnings: 0 
新聞熱點
疑難解答