SQLite:向表和列添加注释? [英] Sqlite: adding comments to tables and columns?
问题描述
在MySQL Workbench中,您可以向MySQL数据库中的表和列添加注释.
In MySQL Workbench you can add comments to tables and columns in a MySQL database.
Sqlite是否支持在表和列中添加注释?
Does Sqlite support adding comments to tables and columns?
推荐答案
我认为没有. "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.
这篇关于SQLite:向表和列添加注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!