SQL : Writing comments in SQL

In PostgreSQL, you can write comments in SQL queries using two different styles:

  1. Single-line comments: Use -- to comment out a single line or part of a line. sql SELECT * FROM users; -- This selects all users

  2. 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.

links

social