开发者

How do I add long comments to mysql tables and columns?

Mysql support very short comments i.e. only 60 character.

I use comments to document the table so that I can recall its use when I look back after a few years. but with char length of 60 its not po开发者_开发百科ssible to document everything.

is there any way to add long comments to tables in mysql?


If the standard method isn't good enough, don't use it. Create your own meta-tables along the lines of:

mymetadata:
    tablename     varchar(50)
    description   varchar(2000)

(adding schemas and indexes as appropriate).

Then populate that table rather than using the standard method. There's little functional difference between show create table mytable and select description from mymetadata where tablename = 'mytable'.

By the way, the MySQL 5.6 doco states that the limit is 1024 characters. It's been so since 5.5.3. Before that (all the way back to 5.0), it claims that 255 characters were okay. So I'm not sure where your claim of sixty characters came from, unless you're using a very old MySQL.


The best way to document a database is a ERD model with sufficient comments in it.

If your ERD tool supports it, you can create the necessary SQL scripts to apply the comments to the database from within your model. Depending on the tool you might have the ability to add a long and a short description, and use the short description for the database comment.

Thus you have a visual documentation that is in sync with the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜