Common MySQL table operations
View column: desc table name; Modify table Name: alter table t_book rename to bbb; add column: alter table name add column name varchar (30); delete column: alter table Name drop column name; Modify column name MySQL: alter table bbb change nnnnn hh int; Modify column name SQLServer: exec sp_rename't _ student. name ', 'nn', 'column '; modify the column name Oracle: lter table bbb rename column nnnnn to hh int; modify the column attribute: alter table t_book modify name varchar (22 ); sp_rename: the built-in Stored Procedure of SQL Server, which is used to modify the table definition. MySQL view constraints, add constraints, delete constraints add columns, Modify columns, delete columns View table field information: desc table name; view all table information: show create table name; add a primary key constraint: alter table name add constraint primary key (for example, PK _ table name) primary key table name (primary key field); add a foreign key constraint: alter table from the table add constraint foreign key (for example: FK _ slave table _ master table) foreign key from the table (foreign key field) references main table (primary key field ); delete primary key constraint: alter table Name drop primary key; Delete foreign key constraint: alter table Name drop foreign key (case sensitive); Modify table Name: alter table t_book rename to bbb; add column: alter table name add Column name varchar (30); delete column: alter table Name drop column name; Modify column name MySQL: alter table bbb change nnnnn hh int; Modify column name SQLServer: exec sp_rename't _ student. name ', 'nn', 'column '; modify the column name Oracle: alter table bbb rename column nnnnn to hh int; modify the column attribute: alter table t_book modify name varchar (22 ); sp_rename: the built-in Stored Procedure of SQL Server, which is used to modify the table definition.
Reference: http://blog.csdn.net/ws84643557/article/details/6939846