1.当前用户下是否有某个表
select count(*) from user_tables where table_name = 'TABLE_NAME';
注意,一般情况下,引号里面的table_name要全部用大写。
如果结果为1,表示有这个表,为0表示没有这个表。
2.某个用户下是否有某个表?
select count(*) from dba_tables where owner = 'USER_NAME' and table_name = 'TABLE_NAME';
3.当前用户下的是否有某个(Package/Procedure/Function)
SELECT * FROM USER_PROCEDURES WHERE OBJECT_TYPE='FUNCTION' AND OBJECT_NAME='FUNCTION_NAME'
注意OBJECT_TYPE='FUNCTION' 一定要大写;
SELECT * FROM USER_PROCEDURES WHERE OBJECT_TYPE='PROCEDURE' AND OBJECT_NAME='PROCEDURE_NAME'
注意OBJECT_TYPE='PROCEDURE' 一定要大写;
判断某个Package是否存在
SELECT * FROM USER_PROCEDURES WHERE OBJECT_NAME='PACKAGE_NAME' AND OBJECT_TYPE='PACKAGE'
判断某个Package中的过程是否存在
SELECT * FROM USER_PROCEDURES WHERE OBJECT_NAME='PACKAGE_NAME' AND PROCEDURE_NAME='PROCEDURE_NAME' AND OBJECT_TYPE='PACKAGE'