- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 12:28 AM
what is the equivalent of "IF EXISTS" in databricks? I would like to first check something later after that use the insert into statement.
- Labels:
-
SQL
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 06:54 AM
Hi @Givi Salu ,
IF EXISTS - If specified, no TABLE_OR_VIEW_NOT_FOUND error is thrown when the table does not exist.
DROP TABLE IF EXISTS employeetable;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 06:54 AM
Hi @Givi Salu ,
IF EXISTS - If specified, no TABLE_OR_VIEW_NOT_FOUND error is thrown when the table does not exist.
DROP TABLE IF EXISTS employeetable;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 11:03 PM
Hi @Givi Salu
We haven't heard from you since the last response from @Ajay Pandey , and I was checking back to see if her suggestions helped you.
Or else, If you have any solution, please share it with the community, as it can be helpful to others.
Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 02:39 PM
Is there a way to check if a table exists, without trying to drop it? something like :
select table_name from system_catalogs where database_name = 'mydb' and schema_name = 'myschema' and object_name = 'mytab';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 10:06 AM
You can query `system.information_schema.tables` which includes all existing tables in the metastore. More on information schema: https://docs.databricks.com/en/sql/language-manual/sql-ref-information-schema.html

