Sqlite:向表和列添加 COMMENT ON 描述? [英] Sqlite: adding COMMENT ON descriptions to tables and columns?

查看:119
本文介绍了Sqlite:向表和列添加 COMMENT ON 描述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MySQL Workbench 中,您可以将 COMMENT 添加到 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" 页面没有提及表或列注释,CREATE TABLEALTER 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:向表和列添加 COMMENT ON 描述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆