千家信息网

MySQL 主键、索引创建

发表于:2025-11-12 作者:千家信息网编辑
千家信息网最后更新 2025年11月12日,创建测试表create table t1.t (a int,b varchar(200));-- 添加主键、索引alter table t1.t add primary key (a);alter t
千家信息网最后更新 2025年11月12日MySQL 主键、索引创建

创建测试表
create table t1.t (a int,b varchar(200));

-- 添加主键、索引
alter table t1.t add primary key (a);
alter table t1.t add index ind_t_a (a);

-- 删除主键、索引
alter table t1.t drop primary key;
alter table t1.t drop index ind_t_a;

0