October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

PostgreSQL and MySQL Column Comments: How to Add, Change, and View Them

PostgreSQL uses COMMENT ON COLUMN for descriptions; MySQL 8.4 stores comments in column definitions. See the SQL syntax, inspection options, and key cautions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PostgreSQL lets you set a column description directly with COMMENT ON COLUMN. MySQL 8.4 stores a column comment as part of the column definition, so changing one on an existing table uses ALTER TABLE. In either database, “without a migration” means the SQL does not itself require a migration file; your team may still require all schema metadata changes to go through its deployment process.

Set a column comment in PostgreSQL

Use COMMENT ON COLUMN to add or replace a column description. For example:

As an Amazon Associate I earn from qualifying purchases.

COMMENT ON COLUMN public.customer.email IS 'Primary contact email supplied by the customer';

The command targets a column belonging to a table, view, composite type, or foreign table. Qualify the object with its schema when needed to identify it unambiguously. A new comment replaces the existing comment; use NULL or an empty string to remove it. The comment is dropped if the database object is dropped. The PostgreSQL 17 reference says this command acquires a SHARE UPDATE EXCLUSIVE lock on the object. PostgreSQL 17 COMMENT reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This is a metadata statement, not a replacement column definition. Whether you run it directly or include it in a migration is a deployment-policy decision.

View PostgreSQL column comments

In psql, use the d family of commands to inspect database objects and their descriptions. For a queryable catalog view, PostgreSQL stores optional object descriptions in pg_description; for a column comment, the column number is recorded in objsubid. PostgreSQL also provides col_description for retrieving a column description. See the pg_description catalog reference and the COMMENT reference.

Set or change a column comment in MySQL 8.4

MySQL 8.4 specifies a column comment with the column definition’s COMMENT attribute. For a new table, for example:

CREATE TABLE customer (
  email VARCHAR(320) COMMENT 'Primary contact email supplied by the customer'
);

The MySQL 8.4 manual documents a maximum column-comment length of 1024 characters. See the MySQL 8.4 CREATE TABLE reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Change the comment on an existing column

To change a comment on an existing table, use ALTER TABLE with a column-definition operation such as MODIFY COLUMN or, where appropriate, CHANGE COLUMN. The example below assumes the existing column is exactly VARCHAR(320) with no other attributes:

ALTER TABLE customer
  MODIFY COLUMN email VARCHAR(320)
    COMMENT 'Primary contact email supplied by the customer';

Do not copy that simplified definition blindly. Before applying it, check the real column definition and preserve its type, nullability, default, generated expression, visibility, and any other relevant attributes. A comment-only intent does not guarantee that every MySQL server, storage engine, or table configuration will perform the alteration instantly or without rebuilding the table; the documented operation is a column change, and its operational impact can vary. Consult the MySQL 8.4 ALTER TABLE reference and assess the change for your environment.

Inspect column comments in MySQL

MySQL 8.4 exposes column comments through SHOW FULL COLUMNS, SHOW CREATE TABLE, and INFORMATION_SCHEMA.COLUMNS.COLUMN_COMMENT. To query comments for a specific table:

SELECT COLUMN_NAME, COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'app'
  AND TABLE_NAME = 'customer';

Filtering on both schema and table avoids mixing results for tables with the same name in different databases. The COLUMNS table also reports details such as data type, nullability, and default. See the MySQL 8.4 INFORMATION_SCHEMA COLUMNS reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What differs between PostgreSQL and MySQL?

Task PostgreSQL 17 MySQL 8.4
Set or update COMMENT ON COLUMN schema.table.column IS 'Description'; Set COMMENT 'Description' in the column definition; for an existing column, use an ALTER TABLE column change.
Remove Use NULL or ''. The reviewed MySQL 8.4 reference material does not establish a specific removal instruction here; check the exact version’s syntax before clearing a comment.
Inspect psql d commands, col_description, or pg_description. SHOW FULL COLUMNS, SHOW CREATE TABLE, or INFORMATION_SCHEMA.COLUMNS.COLUMN_COMMENT.
Documented comment length Not stated in the cited PostgreSQL 17 references. Up to 1024 characters in the MySQL 8.4 CREATE TABLE reference.
How the SQL represents it A dedicated comment command. A column-definition attribute.

These details are version-specific to PostgreSQL 17 and MySQL 8.4. Check the manual for your deployed version before applying syntax or making operational assumptions.

Keep comments suitable for their visibility

Do not use column comments as a private annotation store. PostgreSQL’s documentation explicitly says that any user connected to a database can see comments for objects in that database and warns against putting security-critical information in them. PostgreSQL 17 COMMENT reference.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.