SQL Oracle data types
SQL Oracle data types
Oracle offers the following basic data types:
• char(n): Fixed-length character data (string), n characters long. The maximum size for
n is 255 bytes (2000 in Oracle8). Note that a string of type char is always padded on
right with blanks to full length of n. (+ can be memory consuming).
Example: char(40)
• varchar2(n): Variable-length character string. The maximum size for n is 2000 (4000 in
Oracle8). Only the bytes used for a string require storage. Example: varchar2(80)
• number(o, d): Numeric data type for integers and reals. o = overall number of digits, d
= number of digits to the right of the decimal point.
Maximum values: o =38, d= −84 to +127. Examples: number(, number(5,2)
Note that, e.g., number(5,2) cannot contain anything larger than 999.99 without resulting
in an error. Data types derived from number are int[eger], dec[imal], smallint
and real.
• date: Date data type for storing date and time.
The default format for a date is: DD-MMM-YY. Examples: ’13-OCT-94’, ’07-JAN-98’
1
• long: Character data up to a length of 2GB. Only one long column is allowed per table.
Note: In Oracle-SQL there is no data type boolean. It can, however, be simulated by using
either char(1) or number(1).
As long as no constraint restricts the possible values of an attribute, it may have the special
value null (for unknown). This value is different from the number 0, and it is also different
from the empty string ’’.
• char(n): Fixed-length character data (string), n characters long. The maximum size for
n is 255 bytes (2000 in Oracle8). Note that a string of type char is always padded on
right with blanks to full length of n. (+ can be memory consuming).
Example: char(40)
• varchar2(n): Variable-length character string. The maximum size for n is 2000 (4000 in
Oracle8). Only the bytes used for a string require storage. Example: varchar2(80)
• number(o, d): Numeric data type for integers and reals. o = overall number of digits, d
= number of digits to the right of the decimal point.
Maximum values: o =38, d= −84 to +127. Examples: number(, number(5,2)
Note that, e.g., number(5,2) cannot contain anything larger than 999.99 without resulting
in an error. Data types derived from number are int[eger], dec[imal], smallint
and real.
• date: Date data type for storing date and time.
The default format for a date is: DD-MMM-YY. Examples: ’13-OCT-94’, ’07-JAN-98’
1
• long: Character data up to a length of 2GB. Only one long column is allowed per table.
Note: In Oracle-SQL there is no data type boolean. It can, however, be simulated by using
either char(1) or number(1).
As long as no constraint restricts the possible values of an attribute, it may have the special
value null (for unknown). This value is different from the number 0, and it is also different
from the empty string ’’.
Similar topics
» What Are the Oracle Built-in Data Types?
» What Are the ANSI Data Types Supported in Oracle?
» How Many Categories of Data Types?
» How Many Data Types Are Supported?
» How Many Types of Tables Supported by Oracle?
» What Are the ANSI Data Types Supported in Oracle?
» How Many Categories of Data Types?
» How Many Data Types Are Supported?
» How Many Types of Tables Supported by Oracle?
Permissions in this forum:
You cannot reply to topics in this forum
Sun Jan 31, 2010 12:35 am by Micheal
» Accessing tables of other users in SQL
Sun Jan 31, 2010 12:34 am by Micheal
» Grouping commands in SQL
Sun Jan 31, 2010 12:32 am by Micheal
» Operations on Result Sets in SQL
Sun Jan 31, 2010 12:31 am by Micheal
» Subqueries in SQL
Sun Jan 31, 2010 12:30 am by Micheal
» Joining Relations in SQL
Sun Jan 31, 2010 12:28 am by Micheal
» Delete comand in SQL
Sun Jan 31, 2010 12:27 am by Micheal
» Update command in SQL
Sun Jan 31, 2010 12:26 am by Micheal
» Insert command in SQL
Sun Jan 31, 2010 12:23 am by Micheal