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?
I can't update the version on a live application right now, so I cannot use a SQLite version that supports IF EXISTS
.
The official documentation says to use IF EXISTS, so I suspect your best plan is to upgrade.
If you can't, you need to see whether you can do some trivial operation on the table that will succeed whether or not the table is empty; if it succeeds you should delete the table, if it fails the table is already gone. An example of the sort of operation to try might be:
SELECT COUNT(*) FROM theTable;
Note that you need to trap the possible error from this at the language level, and you might want to wrap the whole lot (probe, error-trap, drop table) in a transaction. Of course, the other approach if you're getting into error handling is to just drop the table and handle the error anyway.
'Knowledge' 카테고리의 다른 글
System.Data.SQLite; 예시 튜토리얼 example tutorial (0) | 2018.04.27 |
---|---|
[MySQL] 테이블 구조 복사 및 데이터 복사 ( Table Copy ) 프로필 (0) | 2018.04.26 |
[System.Data.SQLite] Create SQLite Database and table (0) | 2018.04.24 |
[UWP] MetroLog 추가하기 (0) | 2018.04.21 |
제네릭 클래스(C# 프로그래밍 가이드) (0) | 2018.04.20 |