MySql database operation alter table: add, modify, delete TABLE columns, constraints, and other TABLE definitions.
- View column: desc 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;
- Alter column name MySQL: alter table bbb change nnnnn hh int;
- Modify the 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;
- 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.
View constraints in MySQL, add constraints, delete constraints, add columns, modify columns, and delete columns
- View the table field information: desc table name;
- View all table information: show create table name;
- Add primary key constraint: alter table name add constraint primary key (for example, PK _ table name) primary key table name (primary key field );
- Add foreign key constraint: alter table from table add constraint foreign key (for example: FK _ slave table _ master table) foreign key from table (foreign key field) references primary table (primary key field );
- Delete primary key constraint: alter table name drop primary key;
- Delete foreign key constraints: alter table name drop foreign key (case sensitive );
- 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;
- Alter column name MySQL: alter table bbb change nnnnn hh int;
- Modify the column name SQLServer: exec sp_rename 't_ student. name', 'nn ', 'column ';
- Alter column name Oracle: alter table bbb rename column nnnnn to hh int;
- 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.