← Back to PostgreSQL Course | Chapter 1: Introduction | Lesson 4 of 7

psql की Basics

psql PostgreSQL का command-line client है: आप SQL और एक backslash से शुरू होने वाले shortcuts type करते हैं।

In this page:

  1. psql Basics
Syntax
sql
psql -U username -d database_name -h host
\l
\c database_name
\dt
\d table_name
\q

psql Basics

psql -U user -d database -h host से connect करें। Useful meta-commands हैं \l (databases list करें), \c name (connect करें), \dt (tables list करें), \d table (एक table describe करें), \du (roles), \x (expanded display), \i file.sql (एक file चलाएँ), \timing, और \q (quit)।

SQL statements एक semicolon से खत्म होते हैं।

Note: psql commands की पूरी list के लिए \? type करें।

उदाहरण: psql basics

bash
$ psql -U postgres
postgres=# \l
postgres=# \c shop
You are now connected to database "shop" as user "postgres".
shop=# \dt
        List of relations
 Schema |   Name    | Type  |  Owner
--------+-----------+-------+----------
 public | customers | table | postgres
shop=# \d customers
shop=# \q

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. SQL के अंत में semicolon भूल जाना
  2. meta-commands के लिए SQL इस्तेमाल करना
  3. बिना table name के \d type करना और एक लंबी list पाना
चैप्टर सारांश
  • psql interactive client है
  • Meta-commands एक backslash से शुरू होते हैं
  • \l \c \dt \d basics हैं
  • SQL एक semicolon से खत्म होता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.