Skip to Main Content
Oracle in a Nutshell
book

Oracle in a Nutshell

by Rick Greenwald, David C. Kreines
December 2002
Intermediate to advanced content levelIntermediate to advanced
928 pages
85h 29m
English
O'Reilly Media, Inc.
Content preview from Oracle in a Nutshell

Character Datatypes

Character datatypes can store any string value, including the string representations of numeric values. Assigning a value larger than the length specified for a character datatype results in a runtime error. You can use string functions, such as UPPER, LOWER, SUBSTR, and SOUNDEX, on standard character value types (but not on large character value types, which we describe under “Large Object Datatypes”).

The character datatypes are:

CHAR/CHARACTER[(n [CHAR | BYTE])]

Stores character values with a fixed length. A CHAR datatype can have between 1 and 2000 characters. If you don’t explicitly specify a length for a CHAR, it assumes the default length of 1. If you assign a value that’s shorter than the length specified for the CHAR datatype, Oracle will automatically pad the value with blanks. With Oracle9i, you can specify n with the keywords of BYTE or CHAR.

VARCHAR2(n [CHAR | BYTE]) and VARCHAR(n [CHAR | BYTE])

Store variable-length character strings. Although you must assign a length to a VARCHAR2 datatype, the length is the maximum length for a value, rather than the required length. Values assigned to a VARCHAR2 datatype are not padded with blanks. The VARCHAR2 datatype can have up to 4000 characters.

At this time, the VARCHAR datatype and the VARCHAR2 datatype are synonymous in Oracle8 and later versions, but Oracle recommends the use of VARCHAR2, because future changes may cause VARCHAR and VARCHAR2 to diverge.

With Oracle9i, you can specify n with the keywords ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Internals

Oracle Internals

Donald K. Burleson
Oracle PL/SQL

Oracle PL/SQL

Lewis Cunningham
Oracle Essentials: Oracle9i, Oracle8i and Oracle8, Second Edition

Oracle Essentials: Oracle9i, Oracle8i and Oracle8, Second Edition

Rick Greenwald, Robert Stackowiak, Jonathan Stern

Publisher Resources

ISBN: 0596003366Errata Page