Adding Data With the INSERT Statement

Previous
Previous
Next
Next

You can use the SQL INSERT statement to add a row of data to a table. The data inserted must be valid for the datatype and size of each column of the table. See "Managing Database Objects With Object Browser".

Example: Using the SQL INSERT Statement to Add Rows to a Table shows how to use INSERT to add a row to the employees table. In the first INSERT statement, values are inserted into all columns in a row of the table. In the second INSERT statement, values are inserted only into the specified columns of the table and the remaining columns are set to NULL. If the those remaining columns had been specified with a NOT NULL constraint for the table, an error would occur. For information about constraints, see "Managing Tables" and "NOT NULL Constraint".

Using the SQL INSERT Statement to Add Rows to a Table

-- the following inserts data for all the columns in a row
INSERT INTO employees VALUES 
  (10, 'Enrique', 'Borges', 'enrique.borges', '555.111.2222', 
   '01-AUG-05', 'AC_MGR', 9000, .1, 101, 110);

-- the following inserts data into the columns specified by name
-- NULLs are inserted in those columns not explicitly named 
INSERT INTO employees (employee_id, last_name, email, hire_date, job_id, salary)
  VALUES (11, 'Doe', 'jane.doe', '31-AUG-05', 'SH_CLERK', 2400); 

-- the following shows the rows that were inserted 
SELECT employee_id, last_name FROM employees 
  WHERE employee_id = 10 or employee_id = 11;


See Also:

Oracle Database SQL Reference for information about the INSERT statement