oracle pl sql error oracle pl sql error oracle pl sql error
 

INSERT Oracle Statement


The Insert statement allows you to insert a single record or multiple records into a table.

The syntax for the Insert INTO statement is:

INSERT INTO table (column-1, column-2, ... column-n) VALUES (value-1, value-2, ... value-n);

Example #1 - insert sql server

Let's take a look at a very simple example.

INSERT INTO supplier (supplier_id, supplier_name) VALUES (24553, 'IBM');

This would result in one record being inserted into the supplier table. This new record would have a supplier_id of 24553 and a supplier_name of IBM.

Example #2 - More complex example

You can also perform more complicated inserts using sub-selects.

For example:

INSERT INTO supplier (supplier_id, supplier_name) SELECT account_no, name FROM customers WHERE city = 'Newark';

By placing a "select" in the insert statement, you can perform multiples inserts quickly.

With this type of insert, you may wish to check for the number of rows being inserted. You can determine the number of rows that will be inserted by running the following SQL statement before performing the insert.

SELECT count(*) FROM customers WHERE city = 'Newark';

 

 
 

Frequently Asked Questions


Question:  I am setting up a database with clients. I know that you use the "insert" statement to insert information in the database, but how do I make sure that I do not enter the same client information again?

Answer:  You can make sure that you do not insert duplicate information by using the EXISTS condition.

For example, if you had a table named clients with a primary key of client_id, you could use the following statement:

INSERT INTO clients (client_id, client_name, client_type) SELECT supplier_id, supplier_name, 'advertising' FROM suppliers WHERE not exists (select * from clients where clients.client_id = suppliers.supplier_id);

This statement inserts multiple records with a subselect.

If you wanted to insert a single record, you could use the following statement:

INSERT INTO clients (client_id, client_name, client_type) SELECT 10345, 'IBM', 'advertising' FROM dual WHERE not exists (select * from clients where clients.client_id = 10345);

The use of the dual table allows you to enter your values in a select statement, even though the values are not currently stored in a table.

Learn more about the Exists condition. Learn more about the pl sql Oracle Learn more about the Oracle sql server Learn more about the stored procedure Oracle

 
 
 
 
Oracle news Oracle guide
     
  29-11-2006 Guida Oracle 10g
     
  30-02-2007 Oracle Server
     
  29-02-2007 Oracle Errors
Functions Oracle Functions
Delete Delete
Between Between
Check Check
Count Count
Datatypes Datatypes
Delete Oracle Delete Statement
Distinct Distinct
Exists Exists
Functions Functions
Grant revoke Grant Revoke
Group by Oracle Group by
Having Having
Oracle Function in Oracle Function in
Indexes Indexes
Insert Oracle update
Intersect Intersect
Isnull Is null
Joins Joins
Substr Substr
 
Oracle Functions PLSQL  l  Exceptions  l  Oracle Errors  l  Oracle Collaborations Suite  l  Products  l  Contact
Oracle errors ora