PostgreSQL — Syntax
SQL Statements
-- Select
SELECT * FROM users;
-- Insert
INSERT INTO users (name, email) VALUES ('John', 'john@example.com');
-- Update
UPDATE users SET name = 'Jane' WHERE id = 1;
-- Delete
DELETE FROM users WHERE id = 1;
Syntax Rules
| Rule | Description |
|---|---|
| Case insensitive | SELECT = select |
| Semicolons | End statements |
| Comments | -- or /* */ |
| Strings | Single quotes |
Comments
-- Single line comment
/*
Multi-line
comment
*/
psql Commands
| Command | Description |
|---|---|
| \l | List databases |
| \c db | Connect to database |
| \dt | List tables |
| \d table | Describe table |
| \q | Quit |
| ? | Help |
Mini Practice
- Write SELECT statement
- Insert data
- Update records
- Delete data
Up Next
Continue with Databases — creating databases.
Related Topics
Frequently Asked Questions about Syntax
What is Syntax in PostgreSQL?
Syntax is a fundamental concept in PostgreSQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Syntax?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Syntax.
Why is Syntax important in PostgreSQL?
Syntax is essential for PostgreSQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.