加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

SQLserver 查看表详细信息--删除重复数据

发布时间:2020-12-12 12:46:18 所属栏目:MsSql教程 来源:网络整理
导读:sp_help table_name ?--查询表详细信息sql server desc tables table_name 删除重复数据: 1、oracle 中 delete borrowRecord? --删除表名 where studentId in( --删除重复数据 select studentId from borrowRecord group by studentId having count(student

sp_help table_name ?--查询表详细信息sql server

desc tables table_name

删除重复数据:

1、oracle 中

delete borrowRecord? --删除表名
where studentId in( --删除重复数据
select studentId from borrowRecord group by studentId having count(studentId)>1
)
and?rowid not in( --保留重复数据中的一条数据
select min(rowid) from borrowRecord group by studentId having count(studentId)>1?
)


2、SQL server中

delete BorrowRecord ?? --BorrowRecord 表名
where studentId in(
select studentId from borrowRecord group by studentId having count(studentId)>1 --找出重复的数据
)
and borrowid not in(
select min(borrowId) from borrowRecord group by studentId having count(studentId)>1 --保留重复数据中的一条数据
)


3、删除所有重复的数据

delete from table_name

where id in(

select id from table_name group by id having count(id)>1

)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读