首页 电脑 电脑学堂 查看内容

sql 语句删除主键、更改主键、删除重复列

2014-12-26 11:47 858 0

摘要: alter table HistoryData drop constraint PK_HistoryDataalter table HistoryData add constraint PK_Hist...
关键词: CollectionTime HistoryData 00 2014 constraint Code between select where table

alter table HistoryData drop constraint PK_HistoryDataalter 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)删除重复的列。
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部