Oracle中判断表是否存在

来源:互联网 发布:报名软件app 编辑:程序博客网 时间:2024/04/30 17:25

declare      
    num       number;      
    begin      
    select       count(1)       into       num       from       user_tables       where       table_name= '大写表名 ';      
    if       num> 0       then      
    execute       immediate       'drop       table       '||大写表名;      
    end       if;      
    execute       immediate       'create       table.... ';      
    end;    

=====================================================================

declare

     v_cnt Number;

begin

    select count(*) into v_cnt from user_tables where table_name = yourtablename;

    if v_cnt>0 then
        dbms_output.put_line('该表存在!');
    else
        dbms_output.put_line('该表不存在或当前用户无权访问!');
    end If;
End;
   

原创粉丝点击