gpt4 book ai didi

c - sqlite3_open 如何确定文件数据库是否是新创建的?

转载 作者:太空宇宙 更新时间:2023-11-04 00:08:39 24 4
gpt4 key购买 nike

sqlite3 新手。

如果我的理解有误,请纠正我?

sqlite3_open (文件名, &dbConnection) ->

1) This API creates an database [ie: filename], if it does not exists, and sets
the context to dbConnection.
2) If the database exists already it just sets the context to dbConnection.

情况 (1) 和 (2) 都返回 SQLITE_OK。

问题:如果是第一次创建的数据库,现在是否可以进行过滤?

例如: sqlite3_open (...) if(第一次创建数据库){ 创建表 }

一种可能是检查文件是否存在,但我不想那样做。 sqlite3 本身的任何替代方法?

最佳答案

你可以使用 create table if not exist 语法。

Sqlite Create Table

关于c - sqlite3_open 如何确定文件数据库是否是新创建的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12633919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com