[Oracle] 判斷表是否存在

declare v_cnt Number;

begin

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

    if v_cnt>0 then
        dbms_output.put_line('該表存在!');
    else
        dbms_output.put_line('該表不存在或當前用戶無權訪問!');
    end If;
End;

 

注意:表名要大寫,在這裏是區分大小寫的。Oracle創建的表名全是大寫。

 

 

寫於 2010-10-15

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章