, , ,

INSERT Statement

The INSERT statement allows you to insert a single record or multiple records into a table.
The general syntax for an insert statement is insert into tablename (column_list) values (valuesl_list), where tablename is the
name of the table you want to insert data into, column_list is the list of columns for which you will define values on the record being added, and values_list is the list of those values you will define. The datatype of the data you add as values in the values list must correspond to the datatype for the column identified in that same position in the column list.
The syntax for the INSERT statement is:

INSERT INTO table_name
(column-1, column-2, … column-n) VALUES (value-1, value-2, … value-n);

Example 1:
INSERT INTO  XX_PO_HEADERS_ALL
(PO_ID, PO_NUMBER, SUPPLIER_NAME) VALUES(6, 10, ‘ARCODA’)

Example 2:
you may not necessarily need to define explicit columns of the table. You only need to do that when you don’t plan to populate every column in the record you are inserting with a value.
insert into employee
values (‘02039′,’WALLA’,’RAJENDRA’,60000,’01-JAN-96′,’604B’);

Example 3:
INSERT INTO suppliers
(supplier_id, supplier_name) SELECT account_no, name FROM customers WHERE city = ‘Newark’;

Example 4:
The following is an example of how you might insert 3 rows into the suppliers table in Oracle.
INSERT ALL
INTO  XX_PO_HEADERS_ALL(PO_ID, PO_NUMBER, SUPPLIER_NAME) VALUES(4, 10, ‘ARCODA’)
INTO  XX_PO_HEADERS_ALL(PO_ID, PO_NUMBER, SUPPLIER_NAME) VALUES(5, 10, ‘ARCODA’)
Select * from dual

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply