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


1、查找用户表

  1. select table_name,num_rows from all_tables where OWNER='TIGER' AND TABLE_NAME like '%MASTER'  
  2. order by num_rows desc  
2、查找用户表字段
  1. select * from user_tab_columns  
  2. where DATA_TYPE='CHAR' and DATA_LENGTH=119  
  3.  and Table_name=upper('TYIMBLMASTER')  
3、查找重复字段,去掉count函数则取出记录
  1. select count(*) from sys_data  
  2. where trxref in (select trxref from sys_data group by trxref having count(trxref) > 1)  
  3. --或   
  4. select sum(n) from (select trxref,count(trxref) as n from sys_datas group by trxref having count(trxref) > 1)  
4、查找不重复的记录
  1. select count(trxref) from (select trxref,count(trxref) as n from sys_data group by trxref having count(trxref) > 1)  
5、查找多余的重复记录
  1. select count(*) from sys_data  
  2. where trxref in (select trxref from sys_datas group by trxref having count(trxref) > 1)  
  3. and rowid not in (select min(rowid) from   sys_data group by trxref having count(trxref)>1)  
6、删除多余的重复记录
  1. delete from sys_data  
  2. where trxref in (select trxref from sys_data group by trxref having count(trxref) > 1)  
  3. and rowid not in (select min(rowid) from   sys_data  

相关内容