oracle 按条件删除、查询表

---查询表的名称,字段信息以及字段注释

select
us.table_name, --表名  
ut.COLUMN_NAME,--字段名称
uc.comments,--字段注释
ut.DATA_TYPE,--字典类型
ut.DATA_LENGTH,--字典长度
ut.NULLABLE--是否为空
from user_tab_columns ut
inner JOIN user_col_comments uc
on ut.TABLE_NAME = uc.table_name and ut.COLUMN_NAME = uc.column_name
inner JOIN user_tables us on ut.TABLE_NAME = us.table_name
and us.TABLE_NAME not like '%ITSM%' --模糊查询表明
AND us.TABLE_NAME not like '%CAS%'
AND us.TABLE_NAME not like '%SYSM%'

AND us.TABLE_NAME not like '%RESM%' 

order by ut.TABLE_NAME

 

--删除

select 'drop table ' || t.TABLE_NAME ||';'
from user_tables t
where t.TABLE_NAME like 'BSM%'
or t.TABLE_NAME like 'MV%'
or t.TABLE_NAME like 'PORTAL%'
or t.TABLE_NAME like 'TD%'
or t.TABLE_NAME like 'TF%'
or t.TABLE_NAME like 'UNIGRP%'

将查询出来的结果复制,执行

注意删除之前先备份,不然哭都找不到地方

posted @ 2018-01-04 17:30  步步丶惊云  阅读(1650)  评论(0编辑  收藏  举报