Drop existing table in SQLite, when IF EXISTS operator is not supported

前端 未结 4 1681
余生分开走
余生分开走 2020-12-13 00:09

My version of SQLite does not support the IF EXISTS operator. How can I drop a table which may or may not exist without getting an error slapped at me?

4条回答
  •  执笔经年
    2020-12-13 00:32

    You could somehow use the metadata table in your query to find out if the table exist:

    SELECT count(*) > 0 FROM sqlite_master where tbl_name = "" and type="table"
    

提交回复
热议问题