Mysql操作主鍵 1.查詢主鍵 [html] SELECT t.TABLE_NAME, t.CONSTRAINT_TYPE, c.COLUMN_NAME, c.ORDINAL_POSITION FROM www.2cto.com INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS t, INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS c WHERE t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = '數據庫名字' AND t.CONSTRAINT_TYPE = 'PRIMARY KEY' and t.TABLE_NAME ='表名'; 2.刪除主鍵 [html] alter table 表名 drop primary key; www.2cto.com 3.增加主鍵 [html] alter table 表名 add primary key(列1,列2....); 4.修改主鍵 先刪除主鍵,再添加你的新主鍵,操作如上2和3說明。 作者 fellting