SQL Comment Syntax Varies by Database: Key Differences Developers Should Know
Data analyst Michael Nocito published a guide on August 11, 2026, outlining how SQL comment syntax differs across MySQL, PostgreSQL, SQL Server, SQLite, and Oracle. The standard double-dash (--) and block comment (/* */) styles work universally, but MySQL and MariaDB uniquely support the hash (#) symbol for single-line comments. MySQL also requires at least one whitespace character after the double dash, unlike most other databases, which can cause unexpected syntax errors when scripts are moved between systems. PostgreSQL stands apart by supporting nested block comments as per the SQL standard, a feature absent in all other major databases. For maximum portability, Nocito recommends using only -- with a trailing space and always closing block comments, ensuring compatibility across all five platforms.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in