MySQL
// Add a field
Alter table cdb_forumlinks add type smallint default 1;
Alter table cdb_forumlinks add views int default 0;
// Delete a field
Alter table cdb_forumlinks drop type;
Alter table cdb_forumlinks drop views;
// Modify the field
Alter table student change physics physisc char (10) Not NULL;
Char (10) Not null is the create_definition of your physisc field.
----------------------------------------
More...
// Add a field and set the primary key
Alter table tabelname add new_field_id int (5) unsigned default 0 not null auto_increment, add primary key (new_field_id );
// Index with the primary keyword
Alter table tablename add primary key (ID );
// Add an index
Alter table tablename change depno int (5) not null;
Alter table tablename add Index name (field name 1 [, field name 2…]);
Alter table tablename add index emp_name (name );
// Add an index with unique conditions
Alter table tablename add unique emp_name2 (cardNumber );
// Delete an index
Alter table tablename drop index emp_name;
// Add a field:
Alter table table_name add field_name field_type;
// Delete a field
Alter table table_name drop field_name;
// Rename a column
Alter table table_name change field_name1 field_name2 integer;
// Adjust the field order
Alter table 'users' change 'user _ password' varchar (20) not null after user_name;
// Change the column type
Alter table table_name change field_name bigint not null;
Alter table Infos change list tinyint not null default '0 ';
// Modify the original field name and type:
Alter table table_name change old_field_name new_field_name field_type;
// Rename the table
Alter table table_name rename new_table_name;
// Cascade update and delete (red, Case Insensitive)
Drop table if exists 'mail _ model'; Create Table mail_model (ID varchar (50) primary key not null, mail_filename varchar (200), content varchar (2000 )) engine = InnoDB default charset = GBK;
Drop table if exists 'mail _ model_extend '; Create Table mail_model_extend (ID int (6) auto_increment not null primary key, RID varchar (50) not null, content varchar (2000 ), index (RID), foreign key (RID) References mail_model (ID) on Delete cascade on update cascade) engine = InnoDB default charset = GBK;