Using comments

When creating a complex database, we often need to write some notes that remind us what the various objects are, and why we made certain design choices. Of course we can write this note on a file or even on paper if we prefer. But the best place to keep notes is with the database itself. For this purpose, we can use comments.

Comments are strings that are associated with a certain data structure. They can be set for columns, indexes, tables, or other objects that we have not yet discussed. In all cases, we will use a COMMENT clause to specify comments:

CREATE TABLE example ( column1 CHAR(1) NOT NULL DEFAULT '' COMMENT 'This is a column comment', INDEX idx1 (column1) COMMENT 'An index comment' ) COMMENT 'This table is just an example'; ...

Get MariaDB Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.