Comment
Adds a comment or removes an existing comment for an existing table or column object.
COMMENT
COMMENT ON (TABLE | COLUMN) <object_name> IS (<string_literal> | NULL);Create or remove a comment for a TABLE or COLUMN object of name object_name. The comment must be a string literal or NULL. If NULL, the comment is removed.
Only super-users or owners of the object can modify comments on the object.
Column and table comments can be viewed either in the information_schema system tables, or in the result of the SHOW CREATE TABLE command run on the relevant table.
Examples
Create a table and add a comments to it.
CREATE TABLE employees (id INT, salary BIGINT);
-- Add a comment to the 'employees' table
COMMENT ON TABLE employees IS 'This table stores employee information';
-- Add a comment to the 'salary' column
COMMENT ON COLUMN employees.salary IS 'Stores the salary of the employee';Show the comments and the DDL of the table.
SHOW CREATE TABLE employees;
CREATE TABLE employees /* This table stores employee information */ (
id INTEGER,
salary BIGINT /* Stores the salary of the employee */);
1 rows returned.View the table and column comment in respective system table.
Last updated