Languages
[Edit]
EN

PostgreSQL - Comments

0 points
Created by:
Kelly
394

In this article, we would like to show you how to use comments in PostgreSQL.

Quick solution:

-- Single-line comment
/* 
  Multi-line
  comment
*/

Practical examples

Example 1

In this example, we use a single-line comment as a code fragment explanation:

-- Select all users
SELECT * FROM "users";

Example 2

In this we use a single-line comment to ignore a statement at the end of the line:

SELECT * FROM "users" -- WHERE "name"='Tom';

Example 3

In this example we use a multi-line comment as a code fragment explanation:

/* Select all
 from the "users" table: */
SELECT * FROM "users";

Example 4

In this example, we use a multi-line comment to ignore many statements:

/*SELECT * FROM "users";
SELECT * FROM "products";
SELECT * FROM "orders";*/
SELECT * FROM "departments";

Example 5

In this example, we use a multi-line comment to ignore part of a line:

SELECT "name", /*"surname"*/ "country" FROM "users";
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Cross technology - Comments

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join