Skip Headers
Oracle® Database PL/SQL Language Reference
11g Release 2 (11.2)

E25519-09
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
PDF · Mobi · ePub

SELECT INTO Statement

The SELECT INTO statement retrieves values from one or more database tables (as the SQL SELECT statement does) and stores them in variables (which the SQL SELECT statement does not do).

Caution:

The SELECT INTO statement with the BULK COLLECT clause is vulnerable to aliasing, which can cause unexpected results. For details, see "SELECT BULK COLLECT INTO Statements and Aliasing".

See Also:

Oracle Database SQL Language Reference for the syntax of the SQL SELECT statement

Topics

Semantics

select_into_statement

DISTINCT or UNIQUE

Causes the database to return only one copy of each set of duplicate rows selected. Duplicate rows are those with matching values for each select_item. These two keywords are synonymous.

Restrictions on DISTINCT and UNIQUE 

  • The total number of bytes in all select_item expressions is limited to the size of a data block minus some overhead. This size is specified by the initialization parameter DB_BLOCK_SIZE.

  • No select_item expression can contain a LOB column.

ALL

(Default) Causes the database to return all rows selected, including all copies of duplicates.

*

Selects all columns.

into_clause

With this clause, the SELECT INTO statement retrieves one or more columns from a single row and stores them in either one or more scalar variables or one record variable. For more information, see "into_clause".

bulk_collect_into_clause

With this clause, the SELECT INTO statement retrieves an entire result set and stores it in one or more collection variables. For more information, see "bulk_collect_into_clause".

subquery

SQL SELECT statement (not a PL/SQL SELECT INTO statement).

alias

Another (usually short) name for the referenced column, table, or view.

rest_of_statement

Anything that can follow the FROM clause in a SQL SELECT statement, described in Oracle Database SQL Language Reference.

select_item

If the SELECT INTO statement returns no rows, PL/SQL raises the predefined exception NO_DATA_FOUND. To guard against this exception, select the result of the aggregate function COUNT(*), which returns a single value even if no rows match the condition.

numeric_literal

Literal of a numeric data type.

schema

Name of the schema that contains the table or view. Default: your schema.

db_table_or_view

Name of a database table or view.

column

Name of a column of db_table_or_view.

*

Selects all columns of db_table_or_view.

sequence

Name of a sequence.

CURRVAL

Current value in sequence.

NEXTVAL

Next value in sequence.

alias

Another (usually short) name for the referenced column, table, or view.

table_reference

Reference to a table or view for which you have the SELECT privilege, which is accessible when you run the SELECT INTO statement.

schema

Name of the schema that contains the table or view. Default: your schema.

table

Name of a database table.

view

Name of a database view.

PARTITION partition or SUBPARTITION subpartition

See Oracle Database SQL Language Reference.

@dblink

Database link, described in Oracle Database SQL Language Reference. Do not put space between @ and dblink.