background image
<< Adding, Changing, and Deleting Data | Using DELETE Statements >>
<< Adding, Changing, and Deleting Data | Using DELETE Statements >>

Using UPDATE Statements

Adding, Changing, and Deleting Data
2-28 Oracle Database 2 Day Developer's Guide
In
Example 2­46
, you will use the
INSERT
function to add a new row to the
employees
table.
Example 2­46 Using the INSERT Statement When All Information Is Available
INSERT INTO employees VALUES
(10, 'George', 'Gordon', 'GGORDON', '650.506.2222',
'01-JAN-07', 'SA_REP', 9000, .1, 148, 80);
The results of the query appear.
1 row created.
Your result shows that the new row has been successfully added to the
employees
table.
When all of the information is not available at the time a new record is added to the
database,
Example 2­47
shows how you can insert values only into the specified
known columns of the table and then set the remaining columns to
NULL
.
Note that if the columns that are set to
NULL
are specified with a
NOT NULL
constraint,
this would generate an error.
Example 2­47 Using the INSERT Statement When Some Information Is Not Available
INSERT INTO employees VALUES
(20, 'John', 'Keats', 'JKEATS', '650.506.3333',
'01-JAN-07', 'SA_REP', NULL, .1, 148, 80);
The results of the query appear.
1 row created.
Your result shows that the new row has been successfully added to the
employees
table.
Updating Information
When you use the
UPDATE
statement to update data in a row of a table, the new data
must be valid for the data type and size of each column of the table.
The general syntax of the
UPDATE
command looks like the following. Note that the
columns that are altered must be identified, and the matching conditions must be met.
UPDATE
table_name
SET
column_name
=
value
;
WHERE
condition
;
To update information in a row that is missing data, the missing data column should
be specified. In
Example 2­48
, you will update the
salary
column for a previously
inserted record.
Example 2­48 Using the UPDATE Statement to Add Missing Data
UPDATE employees
SET salary = 8500
See Also:
Oracle Database SQL Language Reference for information about
INSERT