Using SQL query to determine if a table exists

前端 未结 6 1857
清歌不尽
清歌不尽 2020-12-31 06:06

Guys is there any other way to determine a table exists other than below

  1. select count(*) from where rownum =1
  2. select
    6条回答
    •  北海茫月
      2020-12-31 06:32

      Used this in Oracle SQL Developer:

      SELECT COUNT(*) FROM DUAL WHERE EXISTS (
          SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER = 'myschema' AND OBJECT_NAME = 'your_table_name')
      

      This will return either a 0 or 1 if your table exists or not in the ALL_OBJECTS records.

    提交回复
    热议问题