SQL Data Types

 In SQL there are three main data types: string, numeric, and date and time.

String data types:

CHAR(size) 
It is used to store character data within the predefined length. It can be stored up to 2000 bytes.(8000 characters)
NCHAR(size)
It is used to store national character data within the predefined length. It can be stored up to 2000 bytes. (8000 characters)
VARCHAR2(size)
It is used to store variable string data within the predefined length. It can be stored up to 4000 byte.(16000 characters)
VARCHAR(size)
It is the same as VARCHAR2(size). You can also use VARCHAR(size), but it is suggested to use VARCHAR2(size)
NVARCHAR2(size)
It is used to store Unicode string data within the predefined length. We have to must specify the size of NVARCHAR2 data type.Unicode.It can be stored up to 4000 bytes.




Numeric Data Types:

NUMBER(p,s)
It contains precision p and scale s. The precision p can range from 1 to 38, and the scale s can range from -84 to 127. P represents the total number of all digits and S represents the two digits after the decimal
FLOAT(p)
It is a subtype of the NUMBER data type. The precision p can range from 1 to 126.
BINARY_FLOAT
It is used for binary precision( 32-bit). It requires 5 bytes, including length byte.
BINARY_DOUBLE
It is used for double binary precision (64-bit). It requires 9 bytes, including length byte.




Date and Time Data Types:

DATE
It is used to store a valid date-time format with a fixed length. Its range varies from January 1, 4712 BC to December 31, 9999 AD.
TIMESTAMP
It is used to store the valid date in YYYY-MM-DD with time hh:mm:ss format.




Large Object Data Types (LOB Types):

BLOB
It is used to specify unstructured binary data. Its range goes up to 2 32 -1 bytes or 4 GB. 
BFILE
It is used to store binary data in an external file. Its range goes up to 2 32 -1 bytes or 4 GB.
CLOB
It is used for single-byte character data. Its range goes up to 2 32 -1 bytes or 4 GB. t stores large amounts of character data
NCLOB
It is used to specify single byte or fixed length multibyte national character set (NCHAR) data. Its range is up to 2 32 -1 bytes or 4 GB.

Post a Comment

Previous Post Next Post

Contact Form