SQL in Hindi Insert Into Statement




INSERT INTO Statement का उपयोग Table पर नया Record को Insert करने के लिए किया जाता है.

SQL INSERT Table मे एक या अधिक Records को भी Insert करने के लिये उपयोग किया जाता है.

INSERT Statement के Two Syntax होते है और ये इस पर निर्भर होते है और ये यह मालूम करते है की आप इस पर एक या एक से अधिक Records को डाल रहे है.

Syntax with columns name

INSERT INTO table_name(column1,column2,..,columnN)
VALUES (value1, value2,..,valueN);

यहाँ पर Column1, Column2,...ColumnN एक Table मे Column के Name है जिसमे आप अपने Data को Insert करा सकते हो.

Syntax

INSERT INTO table_name
VALUES (value1, value2,..,valueN);

Sample Table

Supplier Id Supplier Name City State
120 Microsoft Spokane Washington
210 Green Sector Los Angeles California
340 Electronics San Francisco California
490 Verizon Irving Houston
700 Food and Kindred Products Little Rock Arkansas Arkansas
200 Aurora Health Care Milwaukee Wisconsin
450 Pearson Industries Green Bay Wisconsin Wisconsin
150 Transportation Equipment Augusta Georgia Georgia
870 Printing and Publishing Marietta Georgia Georgia

Example

INSERT Statement का उपयोग और VALUES Keyword का उपयोग करके एक Record को एक Table में INSERT करना होता है.

Employee Id Employee Name
120 Ramesh
210 Khilan
340 Hardik
490 Komal
700 Muffy
200 Shweta
450 Rupal
150 Shankar
870 Rajesh

अब नई Category मे Record को Insert करते है.

INSERT INTO categories
(category_id, category_name)
VALUES
(870, 'Rajesh');

SELECT * FROM Employee;

Output

Example

INSERT Statement के अंदर आप SELECT Statement को रखकर आप Multiples Records को Inserts कर सकते हो.

Employee Number Last Name First Name salary
7856 Grace Anna 80000
7126 Lane Anna 30000
7836 Bee Bettie 40000
7156 Bell Betty 89000
7056 Grace Emma 60000
7446 Michelle Sarah 70000

अब हम कुछ Employee की Information को Customers Table मे Insert करते है.

INSERT INTO customers
(customer_id, last_name, first_name)
SELECT employee_number AS customer_id, last_name, first_name
FROM employees
WHERE employee_number < 7156;

Output