-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create comments.md under postgresql (#4540)
* Create comments.md under postgresql * Update content/postgresql/concepts/comments/comments.md * Fixed reviews * Fixed review * Fix review * minor changes * Update comments.md ---------
- Loading branch information
1 parent
fa48e77
commit 0a04ccf
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
Title: 'Comments' | ||
Description: 'Comments in PostgreSQL are explanatory lines ignored by the compiler, enhancing code clarity and maintenance.' | ||
Subjects: | ||
- 'Code Foundations' | ||
- 'Computer Science' | ||
- 'Web Development' | ||
Tags: | ||
- 'Comments' | ||
- 'Database' | ||
- 'PostgreSQL' | ||
CatalogContent: | ||
- 'getting-started-off-platform-for-data-science' | ||
- 'paths/design-databases-with-postgresql' | ||
- 'paths/computer-science' | ||
--- | ||
|
||
In PostgreSQL, **comments** are annotations added to SQL code to provide information about the code without affecting its execution. They are primarily used for documentation purposes and to enhance code readability. Comments in PostgreSQL can be single-line or multi-line and are initiated with `--` for single-line comments and, `/* */` for multi-line comments. | ||
|
||
## Syntax | ||
|
||
- Single-line comment: | ||
|
||
```sql | ||
-- This is a single-line comment | ||
``` | ||
|
||
- Multi-line comment: | ||
|
||
```sql | ||
/* | ||
This is a | ||
multi-line comment | ||
*/ | ||
``` | ||
|
||
## Example | ||
|
||
Here's an example of how comments are used in PostgreSQL: | ||
|
||
```sql | ||
-- Selects employee IDs and their names from the employees table. | ||
SELECT id, name | ||
FROM employees; | ||
|
||
/* | ||
Selects all columns from the departments table. | ||
This query retrieves detailed information about departments. | ||
*/ | ||
SELECT * | ||
FROM departments; | ||
``` | ||
|
||
> **Note:** In the above example, comments are used to describe what the following SQL statement does. The PostgreSQL compiler will ignore these comments when executing the SQL code. |