SQLserver 查看表详细信息--删除重复数据
2015-04-23 21:38
337 查看
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
)
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
)
相关文章推荐
- 查看SQLServer数据表的详细信息
- 查看SQLServer数据表的详细信息。
- ajax 实现加载页面、删除、查看详细信息,以及bootstrap网页的美化
- mysql数据表删除字段里重复的信息
- sqlserver 2008 R2 删除重复数据
- 用Entity Framework往数据库插数据时,出现异常,怎么查看异常的详细信息呢?
- sqlserver 2008 R2 删除重复数据
- 删除重复值【根据两个字段判断】(只保留一个)&查看执行计划&统计信息
- 几种在SQLServer中删除重复数据方法
- sqlserver中如何删除没有主键的重复数据。
- sql删除重复数据的详细方法
- sqlserver删除重复数据
- oracle 违反主键id错误,查看表中是否有重复的ID列的值,并删除重复数据
- sql server 2005 中数据库表 的创建 ,查看表 属性,表的名称重命名,情况表中信息,删除表 ; 表中列重命名,添加新列,修改列的数据类型,删除列,设置列的主键外键
- SQLServer查看表,提示“请参阅‘对象资源管理器详细信息’了解此文件家中的对象”
- SqlServer 删除重复数据
- SQL 已更新或删除的行值要么不能使该行成为唯一行(sqlserver中有多行所有的列重复的数据,无法更新或删除问题)
- [Elixir005] 查看指定数据的详细信息 i helper
- 教你几种在SQLServer中删除重复数据方法
- sqlserver中删除数据表中重复的数据或是某一列中重复的字段,紧保留一条数据