SQLite - create table if not exists

折月煮酒 提交于 2019-12-02 01:01:00

Changes returns the number of affected rows. This values is meaningless for CREATE TABLE statements.

There is no easy way to determine whether the CREATE TABLE IF NOT EXISTS statement did the creation or not. You should check beforehand with PRAGMA table_info.

The if not exists syntax makes the command succeed even if the table already exists. It just doesn't do anything.

I'm not sure what you're referring to with "returns 1" unless you're talking about the command-line client. In that case, if you just remove the if not exists from your create statement, the command will return 1 (indicating failure) if the table exists.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!