Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
743 views
in Technique[技术] by (71.8m points)

Sqlite: adding COMMENT ON descriptions to tables and columns?

In MySQL Workbench you can add COMMENTs to tables and columns in a MySQL database.

Does Sqlite support adding comments to tables and columns?

question from:https://stackoverflow.com/questions/7426205/sqlite-adding-comment-on-descriptions-to-tables-and-columns

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

Also, the Unsupported SQL wiki page has this:

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.

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

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
);

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
);

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...