码迷,mamicode.com
首页 > 数据库 > 详细

sql 语句删除主键、更改主键、删除重复列(多列组合)

时间:2014-12-26 13:08:49      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

--alter table HistoryData drop constraint PK_HistoryData
alter table HistoryData add constraint PK_HistoryData primary key (CollectionTime,Code)
更改主键


delete from HistoryData where CollectionTime between‘2014-09-01 00:00:00‘ and ‘2014-11-01 00:00:00‘and ID not in ( 
select id from (
select Code,CollectionTime,max(ID) id from HistoryData 
where CollectionTime between‘2014-09-01 00:00:00‘ and ‘2014-11-01 00:00:00‘group by Code,CollectionTime) a)
删除重复的列。

sql 语句删除主键、更改主键、删除重复列(多列组合)

标签:

原文地址:http://blog.csdn.net/syytem004/article/details/42169219

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!