mysql
//添加欄位
ALTER TABLE cdb_forumlinks ADD type smallint default 1;
ALTER TABLE cdb_forumlinks ADD views int default 0;
//刪除欄位
ALTER TABLE cdb_forumlinks DROP type;
ALTER TABLE cdb_forumlinks DROP views;
//修改欄位
alter table student change physics physisc char(10) not null;
其中char(10) not null是你physisc欄位的create_definition.
----------------------------------------
更加。。。
//添加欄位並設定主鍵
ALTER TABLE tabelname ADD new_field_id int(5) unsigned default 0 not null auto_increment ,ADD primary key (new_field_id);
//加主關鍵字的索引
ALTER TABLE tablename ADD primary key(id);
//加索引
ALTER TABLE tablename CHANGE depno depno int(5) not null;
ALTER TABLE tablename ADD INDEX 索引名 (欄位名1[,欄位名2 …]);
ALTER TABLE tablename ADD INDEX emp_name (name);
//加唯一限制條件的索引
ALTER TABLE tablename ADD UNIQUE emp_name2(cardnumber);
//刪除某個索引
ALTER TABLE tablename DROP INDEX emp_name;
//增加欄位:
ALTER TABLE table_name ADD field_name field_type;
//刪除欄位
ALTER TABLE table_name DROP field_name;
//重新命名列
ALTER TABLE table_name CHANGE field_name1 field_name2 integer;
//調整欄位順序
ALTER TABLE `users` CHANGE `user_password` `user_password` varchar( 20 ) NOT NULL AFTER user_name;
//改變列的類型
ALTER TABLE table_name CHANGE field_name field_name bigint not null;
ALTER TABLE infos CHANGE list list tinyint not null default '0';
//修改原欄位名稱及類型:
ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;
//重新命名表
ALTER TABLE table_name rename new_table_name;
//串聯更新 和 刪除(紅色部分,不區分大小寫 )
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;