DROP TABLE如果在oracle中存在 [英] DROP TABLE IF EXIST in oracle

查看:1031
本文介绍了DROP TABLE如果在oracle中存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家

i希望在许多不同位置的循环中创建3到4个表但在某些位置表存在并且已经存在异常,所以有任何命令,比如在创建函数时code>创建或替换等我尝试过 DROP TABLE IF EXIST TABLENAME 但是没有工作......

任何建议....

hi experts
i want to create 3 to 4 table in a loop in many diffrent locations but in some locations the table exist and gives the exception already exist so is there any command like while creating function CREATE OR REPLACE etc i have tried DROP TABLE IF EXIST TABLENAME but not working...
any suggessions....

推荐答案

请按照以下解决方案,他们可能会帮助你。



1. Oracle:如果表存在 [ ^ ]。

2. Oracle删除表(如果存在) [ ^ ]。
Please follow the below solutions, they might help you.

1. Oracle: If Table Exists[^].
2. Oracle drop table if exists[^].


如果你想检查表是否存在那么查询应该如下...

if you want to check table exist or not then query should like below...
select count(*)
from all_objects
where object_type in ('TABLE','VIEW')
and object_name = 'your_table_name';



OR ...


OR...

DECLARE tbl_exist  PLS_INTEGER;

BEGIN
select count(*) into tbl_exist from user_tables where table_name = 'mytable';
if tbl_exist = 1 then
    execute immediate 'drop table mytable';
end if;

END;
--your create table query...



注意:当使用双引号创建表格时,它是具有案例意义的名称,所以在这种情况下,your_table_name应该是相同的情况



快乐编码!

:)


Note: when table created with double-quote then it''s case sensetive name so in that case your_table_name should be in same case

Happy Coding!
:)


这篇关于DROP TABLE如果在oracle中存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆