且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLite:向表和列添加注释?

更新时间:2023-12-01 08:46:55

我认为没有. "SQLite理解的SQL" 页没有提及表或列注释,也没有提及 ALTER TABLE 文档.

I don't think it does. The "SQL As Understood By SQLite" page makes no mention of table or column comments nor does the CREATE TABLE or ALTER TABLE documentation.

此外,不受支持的SQL Wiki页面具有以下内容:

Also, the Unsupported SQL wiki page has this:

2009-08-04:表和列注释-我搜索了doco,找不到有关将注释应用于表或其列的任何信息.

2009-08-04: Table and column comments - I have scoured the doco and can't find anything about applying comments to tables or their columns.

是的,那是2009年的Wiki页面,但该文档的其余部分均支持该注释.

Yes, that's a wiki page from 2009 but that note is supported by the rest of the documentation.

但是,SQLite确实会保留您放入DDL中的SQL注释.如果将其提供给sqlite3 CLI工具:

However, SQLite does preserve SQL comments that you put in your DDL. If you feed this to the sqlite3 CLI tool:

CREATE TABLE User
        -- A table comment
(
        uid INTEGER,    -- A field comment
        flags INTEGER   -- Another field comment
);

然后您完全可以从.schema命令获得答案:

Then you get exactly that back from a .schema command:

sqlite> .schema
CREATE TABLE User
        -- A table comment
(
        uid INTEGER,    -- A field comment
        flags INTEGER   -- Another field comment
);

因此,如果您可以控制用于创建表的DDL,则应该可以伪造它.

So you should be able to fake it if you can control the DDL used to create your tables.