1. 程式人生 > >ODB --generate-schema 選項未生成 sql 檔案

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.