Delete row if table exists SQL

后端 未结 9 976
旧时难觅i
旧时难觅i 2021-01-17 10:36

I have a script that drops a load of tables using DROP TABLE IF EXISTS, this works.

There is also a delete in this script to DELETE a row from another table that I d

9条回答
  •  [愿得一人]
    2021-01-17 11:17

    I dont think you'll find a common syntax between SQL server and my SQL. I mean, you can check if the table exsits on SQL Server using something like:

    if exists(select * from sys.objects where name like 'table_name')
    

    but mySql would have its own catalog.

    Unless you write a script like:

    if (sql_server) then
       if exists(select * from sys.objects where name like 'table_name')
    else --mySQl
       --execute the mysql script
    

提交回复
热议问题