mysql创建索引笔记
1.添加PRIMARY KEY(主键索引。就是 唯一 且 不能为空。):
ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )
2.添加UNIQUE(唯一索引) :
create TEMPORARY table temp_1 like user
create TEMPORARY table temp_2 like project
insert into temp_1
select * from (
select * from user where usertype=8
and uid not in (
select uid from po_user) order by create_time desc) a
insert into temp_2 select * from project where response_code in(
select username from temp_1
)
insert into po_user(uid,pid,project_name,is_deleted,last_modify_time,last_modify_user)
select uid,pid,project_name,1 as is_deleted,now() as last_modify_time,'手动修复数据' as last_modify_user from temp_1
join temp_2 on temp_1.username =temp_2.response_code
select * from po_user