SQL Data Types

     A data type defines what kind of value a column can contain.  Each column in a database table is required to have a name and a data type.data types

   SQL developers have to decide what types of data will be stored inside each and every table column when creating a SQL table. The data type is a label and a guideline for SQL to understand what type of data is expected inside of each column, and it also identifies how SQL will interact with the stored data.

The following table lists the general data types in SQL:

Data Type Description
char(size) Character string. Fixed-length size. Maximum size of 2000 bytes.
nchar(size) Character string. Fixed-length size NLS string Space padded. Maximum size of 2000 bytes.
varchar2(size) Character string . Fixed-length NLS string Space padded. Maximum size of 4000 bytes.
nvarchar2(size) Character string. Variable-length NLS string. Maximum size of 4000 bytes.
long Variable-length strings. Maximum size of 2GB.
number(p,s) Where p is the precision and s is the scale.

For example, number(9,2) is a number that has 7 digits before the decimal and 2 digits after the decimal.

Precision can range from 1 to 38.
Scale can range from -84 to 127.

numeric(p,s) Where p is the precision and s is the scale.

For example, number(8,2) is a number that has 6 digits before the decimal and 2 digits after the decimal.

Precision can range from 1 to 38.

date A date between Jan 1, 4712 BC and Dec 31, 9999 AD.
timestamp (fractional seconds precision) IIncludes year, month, day, hour, minute, and seconds.

fractional seconds precision must be a number between 0 and 9. (default is 6)

timestamp (fractional seconds precision) with time zone Includes year, month, day, hour, minute, and seconds; with a time zone displacement value.

For example:
timestamp(5) with time zone

timestamp (fractional seconds precision) with local time zone Includes year, month, day, hour, minute, and seconds; with a time zone expressed as the session time zone.For example:
timestamp(4) with local time zone
bfile File locators that point to a binary file on the server file system (outside the database).

Maximum file size of 264-1 bytes.

blob Stores unstructured binary large objects.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage).

clob Stores single-byte and multi-byte character data.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage) of character data.

nclob Stores unicode data.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage) of character text data.

Advertisements