In PostgreSQL, you can write comments in SQL queries using two different styles:
-
Single-line comments: Use
--
to comment out a single line or part of a line.sql SELECT * FROM users; -- This selects all users
-
Multi-line comments: Use
/* */
to comment out multiple lines or a section of your query.sql /* This is a multi-line comment. You can use it for longer explanations. */ SELECT * FROM users;
Both types of comments will be ignored by PostgreSQL when executing the query.