ODB --generate-schema 选项未生成 sql 文件

度娘未见答案(什么时候开放google),自己查看帮助文档发现,在数据库类型为sqlite的情况下,SQL 文件是内嵌的,所有不会单独生成sql文件,需添加--schema-format 选项,设置sql来生成单独的sql文件,具体信息见odb命令参数说明:

--generate-schema|-s

Generate the database schema. The database schema contains SQL statements that create database tables necessary to store persistent classes defined in the file being compiled. Note that by applying this schema, all the existing information stored in such tables will be lost.

Depending on the database being used (--database option), the schema is generated either as a standalone SQL file or embedded into the generated C++ code. By default the SQL file is generated for the MySQL, PostgreSQL, Oracle, and Microsoft SQL Server databases and the schema is embedded into the C++ code for the SQLite database. Use the --schema-format option to alter the default schema format.

If database schema evolution support is enabled (that is, the object model version is specified), then this option also triggers the generation of database schema migration statements, again either as standalong SQL files or embedded into the generated C++ code. You can suppress the generation of schema migration statements by specifying the --suppress-migration option.

--schema-format format

Generate the database schema in the specified format. Pass sql as format to generate the database schema as a standalone SQL file or pass embedded to embed the schema into the generated C++ code. The separate value is similar to embedded except the schema creation code is generated into a separate C++ file (name-schema.cxx by default). This value is primarily useful if you want to place the schema creation functionality into a separate program or library. Repeat this option to generate the same database schema in multiple formats.

猜你喜欢

转载自blog.csdn.net/MissLong/article/details/82781649