Skip to content

How to get Mysql Table Comments

Let’s assume that we have a table with the following table schema:

CREATE TABLE employee (
        id INT NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'The primary key for employee',
        name varchar(50) NOT NULL  COMMENT 'The name of the employee',
        about TEXT NOT NULL COMMENT 'Short note about this employee'
) COMMENT='Table which holds data about employee';

Run below SQL query to see the employee table information:

SHOW FULL COLUMNS FROM employee;

The output of the preceding command will look like below shown:

Show table comments

By using the following command you can see the comment of table

SELECT table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name='employee';

The output of the preceding command will look like below shown:

Show table column comments

By using the following command you can see the comments of each column of the given table and not the comments from the fields.

SELECT a.COLUMN_NAME, a.COLUMN_COMMENT
FROM information_schema.COLUMNS a 
WHERE a.TABLE_NAME = 'employee';

The output of the preceding command will look like below shown:

5 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments