SQLite: Add a comment to the table and columns?

In MySQL Workbench, you can add comments to tables and columns in the MySQL database.

Does Sqlite support adding comments to tables and columns?

I don’t think so. The “SQL As Understood By SQLite” page does not mention table or column comments, nor does it provide CREATE TABLE or ALTER TABLE documentation.

In addition, the Unsupported SQL wiki page has:

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, this is a 2009 wiki page, but other documents support the comment.

However, SQLite will retain your SQL comments in DDL. If you provide it to the sqlite3 CLI tool:

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

Then you get these from the .schema command:

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

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

In MySQL Workbench, you can add comments to the tables and columns in the MySQL database.

Does Sqlite support adding comments to tables and columns?

I don’t think so. The "SQL As Understood By SQLite" page does not mention table or column comments, nor does it provide CREATE TABLE or ALTER TABLE documentation.

In addition, the Unsupported SQL wiki page has:

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, this is a 2009 wiki page, but other documents support the comment.

However, SQLite will retain your SQL comments in DDL. If you provide it to the sqlite3 CLI tool:

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

Then you get these from the .schema command:

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

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

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 909 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.