当前位置: 代码迷 >> Oracle管理 >> 怎么在删除一个表前判断该表是否存在
  详细解决方案

怎么在删除一个表前判断该表是否存在

热度:95   发布时间:2016-04-24 06:08:06.0
如何在删除一个表前判断该表是否存在?

oracel有这样的sql语句不?

------解决方案--------------------
In Oracle
select count(table_name) from all_tables where table_name = 'TABLE '

------解决方案--------------------
例:
if exists(select 1 from sys.systable where table_name= 'SPAREPART ' and table_type= 'BASE ') then
drop table SPAREPART
end if;
------解决方案--------------------
上面不是吧,试过了都不能
------解决方案--------------------
你就删除不就接了,没这张表会报错的,不也就执行不起来?
------解决方案--------------------
有,从字典表里面取,大写
------解决方案--------------------
select * from dba_tables
where table_name = 'YOUR_TABLE_NAME';

或者

select * from all_tables
where table_name = 'YOUR_TABLE_NAME';

或者

select * from user_tables
where table_name = 'YOUR_TABLE_NAME';


------解决方案--------------------
select tname from tab where tname = '<tablename>'
------解决方案--------------------
查询数据字典,

select count(*) from all_tables where table_name='your_talbe_name'

------解决方案--------------------
有问题请先GOOGLE,BAIDU
------解决方案--------------------
  相关解决方案