Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

Datatypes

Datatypes

Each value manipulated by Oracle has a datatype. A value’s datatype associates a fixed set of properties with the value. These properties cause Oracle to treat values of one datatype differently from values of another. For example, you can add values of NUMBER datatype, but not values of RAW datatype.

When you create a table or cluster, you must specify a datatype for each of its columns. When you create a procedure or stored function, you must specify a datatype for each of its arguments. These datatypes define the domain of values that each column can contain or each argument can have. For example, DATE columns cannot accept the value February 29 (except for a leap year) or the values 2 or ’SHOE’. Each value subsequently placed in a column assumes the column’s datatype. For example, if you insert ’01-JAN-98’ into a DATE column, then Oracle treats the ’01-JAN-98’ character string as a DATE value after verifying that it translates to a valid date.

Oracle provides a number of built-in datatypes as well as several categories for user-defined types that can be used as datatypes. The syntax of Oracle datatypes appears in the diagrams that follow. The text of this section is divided into the following sections:

Oracle Built-in Datatypes

ANSI, DB2, and SQL/DS Datatypes

User-Defined Types

Oracle-Supplied Types

Note: The Oracle precompilers recognize other datatypes in embedded SQL programs. These datatypes are called external datatypes and are associated with host variables. Do not confuse built-in datatypes and user-defined types with external datatypes. For information on external datatypes, including how Oracle converts between them and built-in datatypes or user-defined types, see Pro*COBOL Precompiler Programmer’s Guide, and Pro*C/C++ Precompiler Programmer’s Guide.

2-2 Oracle9i SQL Reference

Datatypes

datatypes::=

Oracle_built_in_datatypes

ANSI_supported_datatypes

user_defined_types

Oracle_supplied_types

Oracle_built_in_datatypes::=

character_datatypes

number_datatypes

long_and_raw_datatypes

datetime_datatypes

large_object_datatypes

rowid_datatypes

character_datatypes::=

 

 

 

 

BYTE

 

 

 

 

CHAR

CHAR

(

size

 

)

 

 

 

 

BYTE

 

 

 

 

CHAR

VARCHAR2

(

size

)

NCHAR

(

size

)

 

NVARCHAR2

(

size

)

number_datatypes::=

 

,

scale

(

precision

)

NUMBER

 

 

Basic Elements of Oracle SQL 2-3

Datatypes

long_and_raw_datatypes::=

LONG

LONG RAW

RAW ( size )

datetime_datatypes::=

DATE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LOCAL

 

 

 

(

fractional_seconds_precision

)

WITH

TIME

ZONE

 

TIMESTAMP

 

 

 

 

 

 

 

 

 

 

 

(

year_precision

)

 

 

 

 

 

INTERVAL

YEAR

 

 

 

TO

MONTH

 

 

 

 

 

(

day_precision

)

 

(

fractional_seconds_precision

)

INTERVAL

DAY

 

 

 

TO

SECOND

 

 

 

large_object_datatypes::=

BLOB

CLOB

NCLOB

BFILE

rowid_datatypes::=

ROWID

( size )

UROWID

The ANSI-supported datatypes appear in the figure that follows. Table 2–6 on page 2-36 shows the mapping of ANSI-supported datatypes to Oracle built-in datatypes.

2-4 Oracle9i SQL Reference

Datatypes

ANSI_supported_datatypes::=

 

 

VARYING

 

 

 

 

 

CHARACTER

 

 

 

(

size

)

 

 

CHAR

 

 

 

 

 

 

 

 

 

 

VARYING

(

size

)

 

 

 

NCHAR

 

 

 

 

 

 

 

 

VARCHAR

(

size

)

 

 

 

 

 

 

 

CHARACTER

 

VARYING

 

 

 

NATIONAL

 

 

 

 

 

(

size

)

 

 

CHAR

 

 

 

 

 

 

NUMERIC

 

 

 

 

,

scale

 

 

 

(

precision

 

 

)

 

 

 

 

 

 

DECIMAL

DEC

INTEGER

INT

SMALLINT

( size )

FLOAT

DOUBLE PRECISION

REAL

Oracle_supplied_types::=

any_types

XML_types

spatial_type

media_types

Basic Elements of Oracle SQL 2-5

Соседние файлы в папке Oracle selected docs