Home arrow Oracle arrow Page 3 - Oracle Database Fundamentals

Inserting Data - Oracle

In this article we will mainly focus on basic database development using Oracle. We will learn how to create new tables, alter them, insert data into the database, update data, retrieve data, delete data and drop tables. We have lots to do, so let's get started.

TABLE OF CONTENTS:
  1. Oracle Database Fundamentals
  2. Creating Database Tables
  3. Inserting Data
  4. Selecting Data
  5. Updating Data
By: Mamun Zaman
Rating: starstarstarstarstar / 103
May 01, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The syntax for an SQL insert statement is as follows:

insert into tablename values (somevalue, somevalue, ...);

Or

insert into tablename (columnname, columnname, ...) values (somevalue, somevalue, ...);

The difference between above two insert statements is the columnname part. In the first statement values will be inserted in the order of columns as specified during creation. Let's look at an example. If we want to insert the first row of our department table as specified earlier then the insert statement would be:

insert into department values ('Sales',1,1);

Our department database table would look like this after this insertion.

Dept

EmpID

DeptID

Sales

  1

1

 

 

 

insert into department values (1,'Sales',1);

Now if we use above statement, it will cause an error. Oracle is expecting the first element to be Dept, a varchar2, but it gets a number, 1. We can use the statement below to make Oracle think like us.

insert into department (DeptID, Dept, EmpID) values (1,'Sales',1);

It is better to mention the column names also, since sometimes we don't know the order of the columns.



 
 
>>> More Oracle Articles          >>> More By Mamun Zaman
 

blog comments powered by Disqus
   

ORACLE ARTICLES

- Oracle Releases Communications Network Integ...
- Oracle Releases Communications Data Model 11...
- Oracle Releases PeopleSoft PeopleTools 8.52
- Oracle Integrates Cloudera Apache Distro, My...
- Oracle Releases MySQL 5.5.18
- Oracle Announces NoSQL Database Availability
- Sorting Database Columns With the SELECT Sta...
- Retrieving Table Data with the LIKE Operator
- Using the IN and BETWEEN Operators on Tables
- Clauses and Logical Operators for Retrieving...
- Limiting Rows When Retrieving Table Data
- Using Scalar Functions for Retrieving Data
- Retrieving Data with String and Arithmatic E...
- Coding the SELECT Statement
- Oracle Releases iPad Virtual Desktop and Exa...


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap

Dev Shed Tutorial Topics: