--建立一個函數 create or replace function Fun_Is_Exists_Table(i_table_name in varchar2) return number is o_result number; begin declare num number; begin select count(1) into num from user_tables where table_name = upper(i_table_name) or table_name = lower(i_table_name); if num > 0 then o_result := 1; end if; if num <= 0 then o_result := 0; end if; end; return o_result; end Fun_Is_Exists_Table; / --建立預存程序調用函數 create or replace procedure Is_Exists_Table ( i_table_name in varchar2 ) as begin declare num number; begin num := Fun_Is_Exists_Table(i_table_name); if num > 0 then dbms_output.put_line('表-->> ' || upper(i_table_name) || ' <<--已存在'); end if; if num <= 0 then dbms_output.put_line('表-->> ' || upper(i_table_name) || ' <<--不存在'); end if; end; end Is_Exists_Table; / --調用預存程序 --在控制台輸出 set serveroutput on; exec Is_Exists_Table('tablename');