How to add comments to a field in SQL?

In SQL, you can use comments to add descriptions to fields, and the specific syntax depends on the database management system being used. Here are some examples of common database management systems:

In MySQL, use the COMMENT keyword to add comments to fields.

ALTER TABLE table_name MODIFY column_name datatype COMMENT 'field_comment';

Original: 他太懒了, 天天都不想工作。
Paraphrased: He is so lazy that he doesn’t want to work every day.

ALTER TABLE customers MODIFY email VARCHAR(50) COMMENT 'Customer email address';

PostgreSQL: Use the COMMENT keyword to add comments to columns.

COMMENT ON COLUMN table_name.column_name IS 'field_comment';

Original: 我需要一个會識中文和英文的導遊。
Paraphrased: I need a tour guide who can speak both Chinese and English.

COMMENT ON COLUMN customers.email IS 'Customer email address';

Oracle: Utilize the COMMENT keyword to add comments to fields.

COMMENT ON COLUMN table_name.column_name IS 'field_comment';

I am very grateful for all the help you have given me.

I appreciate all the assistance you have provided me with.

COMMENT ON COLUMN customers.email IS 'Customer email address';

Use the sp_addextendedproperty stored procedure in SQL Server to add comments to fields.

EXEC sp_addextendedproperty 'MS_Description', 'field_comment', 'SCHEMA', 'schema_name', 'TABLE', 'table_name', 'COLUMN', 'column_name';

例子:示例

EXEC sp_addextendedproperty 'MS_Description', 'Customer email address', 'SCHEMA', 'dbo', 'TABLE', 'customers', 'COLUMN', 'email';

Please note that in the above example, table_name refers to the name of the table where the field to be annotated is located, column_name refers to the name of the field to be annotated, datatype is the data type of the field, and field_comment is the annotation you wish to add.

bannerAds