DROP IF EXISTS VS DROP?

前端 未结 5 529
南方客
南方客 2020-12-07 09:29

Can someone tell me if there is any difference between

DROP IF EXISTS [TABLE_NAME]
DROP [TABLE_NAME]

I am askin

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 09:56

    You forgot the table in your syntax:

    drop table [table_name]
    

    which drops a table.

    Using

    drop table if exists [table_name]
    

    checks if the table exists before dropping it.
    If it exists, it gets dropped.
    If not, no error will be thrown and no action be taken.

提交回复
热议问题