This topic provides recommendations on table comments in OceanBase Database.
Commenting on each table field helps users better understand the table and each field, facilitating coherent development among developers. Table comments are a favorable supplement to database design documents and a natural feature description.
You can add comments to a table by using two methods:
Add comments to a table when you create the table. Example:
obclient> CREATE TABLE student( id INT PRIMARY KEY AUTO_INCREMENT COMMENT 'Student No.', nameVARCHAR(200) COMMENT 'Name', ageint COMMENT 'Age') COMMENT='Student information';After you create the table, use the
ALTERstatement to add comments. Example:obclient> CREATE TABLE student( id INT PRIMARY KEY AUTO_INCREMENT , name VARCHAR(200) , age int); obclient> ALTER TABLE student COMMENT 'Student information'; obclient> ALTER TABLE student MODIFY COLUMN id COMMENT 'Student No.'; obclient> ALTER TABLE student MODIFY COLUMN name COMMENT 'Name'; obclient> ALTER TABLE student MODIFY COLUMN age COMMENT 'Age';We recommend that you use the second method to add comments, that is, use the
ALTERstatement after the table is created. This method facilitates follow-up table maintenance.