1、查找用户表
select table_name,num_rows from all_tables where OWNER='TIGER' AND TABLE_NAME like '%MASTER'
order by num_rows desc
2、查找用户表字段
select * from user_tab_columns
where DATA_TYPE='CHAR' and DATA_LENGTH=119
and Table_name=upper('TYIMBLMASTER')
3、查找重复字段,去掉count函数则取出记录
select count(*) from sys_data
where trxref in (select trxref from sys_data group by trxref having count(trxref) > 1)
--或
select sum(n) from (select trxref,count(trxref) as n from sys_datas group by trxref having count(trxref) > 1)
4、查找不重复的记录
select count(trxref) from (select trxref,count(trxref) as n from sys_data group by trxref having count(trxref) > 1)
5、查找多余的重复记录
select count(*) from sys_data
where trxref in (select trxref from sys_datas group by trxref having count(trxref) > 1)
and rowid not in (select min(rowid) from sys_data group by trxref having count(trxref)>1)
6、删除多余的重复记录
delete from sys_data
where trxref in (select trxref from sys_data group by trxref having count(trxref) > 1)
and rowid not in (select min(rowid) from sys_data
本文提供了一系列实用的SQL查询技巧,包括如何查找特定用户的表及表字段、如何发现并处理重复数据等,对于数据库管理和优化非常实用。
454

被折叠的 条评论
为什么被折叠?



