desc 表名; show columns from 表名; describe 表名; show create table 表名;
use information_schema select * from columns where table_name='表名';
順便記下: show databases; 也可以這樣
use information_schema
select table_schema,table_name from tables where table_schema='數據庫名'
use 數據庫名; show tables; 原有一unique索引AK_PAS_Name(PAC_Name)在表tb_webparamcounter中, 執行以下sql修改索引 alter table tb_webparamcounter drop index AK_PAS_Name; alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name);
若發現索引的邏輯不對,還需要再加一個字段進去,執行 alter table tb_webparamcounter drop index AK_PAS_Name; alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name,PAC_Value); 注意:這時的PC_ID,PAC_Name,PAC_Value三個字段不是FOREIGN KEY 否則必需先drop FOREIGN KEY,再重做上一步才行
獲取列名數據類型備注 SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT FROM information_schema.columns WHERE table_name = ?