check if table exists oracle

Solutions on MaxInterview for check if table exists oracle by the best coders in the world

showing results for - "check if table exists oracle"
Stefania
14 Aug 2018
1SELECT * FROM USER_TABLES WHERE TABLE_NAME = 'my_table';
2-- Tables from schemes you can access
3SELECT * FROM ALL_TABLES WHERE OWNER = 'scheme_name' TABLE_NAME = 'my_table';
4-- Tables from schemes you can access
5SELECT * FROM DBA_TABLES WHERE OWNER = 'scheme_name' TABLE_NAME = 'my_table';
Valeria
31 Feb 2020
1BEGIN
2  SELECT COUNT(*)
3    INTO l_cnt
4    FROM dba_tables
5   WHERE owner = <<table owner>>
6     AND table_name = <<table name>>;
7 
8  IF( l_cnt > 0 )
9  THEN
10     EXECUTE IMMEDIATE 'SELECT col1 FROM x'
11        BULK COLLECT INTO some_collection;
12  ELSE
13    SELECT 'table X does not exist'
14      INTO some_variable
15      FROM dual;
16  END IF;
17END;