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

2015-07-24 10:25:29 ? 作者: ? 浏览: 2
--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)
删除重复的列。
-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: