ORACLE中查找用户表和用户表字段等

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




posted @ 2011-12-21 23:50  hongweigg  阅读(6)  评论(0)    收藏  举报