-1

The idea is to select 2 column response representing the table name and a boolean flag if it exists in the database for predefined list of tables. Is it possible to make such request in a single query?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

You can use USER_TABLES dictionary view. This view contains detail of the all tables that is owned by the current user.

You can achieve the desired result using following query:

WITH PREDEFINED_LIST_TABLES AS
(SELECT 'TABLE1' TABLE_NAME FROM DUAL UNION ALL
....
....)
SELECT P.TABLE_NAME , 
CASE WHEN U.TABLE_NAME IS NOT NULL THEN 1 ELSE 0 END AS TAB_EXISTS
FROM PREDEFINED_LIST_TABLES P 
LEFT JOIN USER_TABLES U
ON (P.TABLE_NAME = U.TABLE_NAME);

Cheers!!

Popeye
  • 35,427
  • 4
  • 10
  • 31