← Back to PostgreSQL Course | Chapter 4: Inserting & Modifying Data | Lesson 1 of 7

INSERT INTO का उपयोग

INSERT INTO एक table में एक नई row add करता है।

In this page:

  1. INSERT INTO
Syntax
sql
INSERT INTO table_name (column1, column2)
VALUES (value1, value2);

INSERT INTO

Columns name करें और matching values supply करें: INSERT INTO t (a, b) VALUES (1, x)। छोड़े गए columns इनका DEFAULT या NULL लेते हैं। Columns list करना statements को robust बनाता है जब table बदले। INSERT ... SELECT एक query से rows copy करता है।

Note: हमेशा INSERT statements में column names list करें।

उदाहरण: INSERT INTO

sql
CREATE TABLE members (id INTEGER PRIMARY KEY, name TEXT NOT NULL, plan TEXT DEFAULT 'free', age INTEGER);
INSERT INTO members (id, name, age) VALUES (1, 'Ada', 36);
INSERT INTO members (id, name, plan) VALUES (2, 'Bob', 'pro');
SELECT * FROM members;

-- Output:
-- id | name | plan | age
-- 1 | Ada | free | 36
-- 2 | Bob | pro | NULL
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. columns name किए बिना column order पर depend करना
  2. values की गलत संख्या
  3. text के चारों ओर quotes भूल जाना
चैप्टर सारांश
  • INSERT INTO table (cols) VALUES (values) syntax इस्तेमाल होता है
  • छोड़े गए columns defaults इस्तेमाल करते हैं
  • columns explicitly list करें
  • INSERT ... SELECT rows copy करता है
🔒

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.