CREATE OR REPLACE PROCEDURE check_table_exists Oracle数据库开发:编写存储过程判断表是否存在 (p_table_name IN VARCHAR2) IS v_count INT; BEGIN SELECT COUNT(*) INTO v_count FROM all_tables WHERE table_name = p_table_name; IF v_count > 0 THEN DBMS_OUTPUT.PUT_LINE('Table ' || p_table_name || ' exists in the database.'); ELSE DBMS_OUTPUT.PUT_LINE('Table ' || p_table_name || ' does not exist in the database.'); END IF; EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('Table ' || p_table_name || ' does not exist in the database.'); WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('An error occurred: ' || SQLERRM); END; /
登录后复制