Skip Headers
Oracle® TimesTen In-Memory Database SQL Reference
Release 11.2.1

Part Number E13070-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

INSERT

The INSERT statement adds rows to a table.

The following expressions can be used in the VALUES clause of an INSERT statement:

Required privilege

No privilege is required for the table owner.

INSERT for another user's table.

SQL syntax

INSERT INTO [Owner.]TableName [(Column [,...])]
VALUES (SingleRowValues)
[RETURNING|RETURN Expression[,...] INTO DataItem[,...]]

The SingleRowValues parameter has the syntax:

{NULL|{?|:DynamicParameter}|{Constant}| DEFAULT}[,...]

Parameters

Parameter Description
Owner The owner of the table into which data is inserted.
TableName Name of the table into which data is inserted.
Column Each column in this list is assigned a value from SingleRowValues.

If you omit one or more of the table's columns from this list, then the value of the omitted column in the inserted row is the column default value as specified when the table was created or last altered. If any omitted column has a NOT NULL constraint and has no default value, then the database returns an error.

If you omit a list of columns completely, then you must specify values for all columns in the table

?

:DynamicParameter

Place holder for a dynamic parameter in a prepared SQL statement. The value of the dynamic parameter is supplied when the statement is executed.
Constant A specific value. See "Constants".
DEFAULT Specifies that the column should be updated with the default value.
Expression Valid expression syntax. See Chapter 3, "Expressions".
DataItem Host variable or PL/SQL variable that stores the retrieved Expression value.

Description

Examples

A new single row is added to the purchasing.vendors table.

INSERT INTO purchasing.vendors
VALUES (9016,
       'Secure Systems, Inc.',
       'Jane Secret',
       '454-255-2087',
       '1111 Encryption Way',
       'Hush',
       'MD',
       '00007',
       'discount rates are secret');

:pno and :pname are dynamic parameters whose values are supplied at runtime.

INSERT INTO purchasing.parts (partnumber, partname)
  VALUES (:pno, :pname);

Return the annual salary and job_id of a new employee. Declare the variables sal and jobid with the same data types as salary and job_id. Insert the row into employees. Print the variables for verification.

Command> VARIABLE sal12 NUMBER(8,2);
Command> VARIABLE jobid VARCHAR2(10) INLINE NOT NULL;

Command> INSERT INTO employees(employee_id, last_name, email, hire_date, 
       > job_id, salary)
       > VALUES (211,'Doe','JDOE',sysdate,'ST_CLERK',2400)
       > RETURNING salary*12, job_id INTO :sal12,:jobid;
1 row inserted.

PRINT sal12 jobid;
SAL12                 : 28800
JOBID                 : ST_CLERK

See also


CREATE TABLE
INSERT...SELECT
Chapter 3, "Expressions"