DataType
Data type is used to specify the type of data that will be stored in a particular memory location.
Types of Data Type
CHAR
VARCHAR/ VARCHAR2
NUMBER
DATE
LARGE OBJECT
CHARACTER LARGE OBJECT
BINARY LARGE OBJECT
CHAR
CHAR datatype can accept ‘A - Z’, ‘a - z’, ‘0 - 9’, ‘special characters’ as well as ‘ Alphanumerics’.
Characters must always be enclosed within single quotes
Syntax: CHAR (SIZE)
Whenever we use CHAR datatype we must mention it’s size.
SIZE
It is used to specify number of characters it can store
The maximum no. of characters it can store is 2000 characters.
CHAR datatype follows fixed length memory allocation.
VARCHAR
VARCHAR datatype can accept ‘A - Z’, ‘a - z’, ‘0 - 9’, ‘special characters’ as well as ‘ Alphanumerics’.
Characters must always be enclosed within single quotes
Syntax: VARCHAR (SIZE)
Whenever we use VARCHAR datatype we must mention it’s size.
SIZE
It is used to specify number of characters it can store
The maximum no. of characters it can store is 2000 characters.
CHAR datatype follows variable length memory allocation.
VARCHAR2
It is an updated version of VARCHAR2 datatype
It can store up to 4000 characters
Syntax: VARCHAR (SIZE)
DATE
It is used to store the date in a particular format.
It use ORACLE specified format
‘DD-MON-YYYY’
‘DD-MON-YY’
Syntax: DATE
- e.g. ‘28-AUG-2024’, ‘28-AUG-24’
NUMBER
It is used to store the numeric value
Syntax: NUMBER(PRECISION, [SCALE])
PRECISION:
It is used to specify the number of digits to store the integer values
SCALE:
It is used to specify the number of digits to store decimal values within the precision
The default value of scale is 0
SCALE is optional
LARGE OBJECT
CHARACTER LARGE OBJECT:
It is used to store characters upto 4GB of size
BINARY LARGE OBJECT:
It is used to store binary values of images, documents, etc, upto $GB of size.