0% found this document useful (0 votes)
7 views

SQL Notes Chapter 2

Uploaded by

devap9407
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

SQL Notes Chapter 2

Uploaded by

devap9407
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DATATYPES

Datatypes are used to find out what type or kind of data that is given for a particular
column.
Types of datatypes
1. CHAR
2. VARCHAR/VARCHAR2
3. DATE
4. NUMBER
5. LARGE OBJECTS
a. CHARACTER LARGE OBJECTS
b. BINARY LARGE OBJECTS

1. CHAR Datatype
 It is used to store the characters.
 It accepts the following
‘a-z’, ‘A-Z’, ‘0-9’, Special characters and Alphanumeric characters
(Combination of alphabet and numbers).
 We have to write characters within (‘’) single quotes.

SYNTAX: CHAR(SIZE)
 Whenever we use char data type we have to mention the size for it.
 The maximum size of char data type is 2000ch.
 Char datatype follows “Fixed length memory allocation”.
Example: CHAR (10)
D I N G A

Used memory Unused memory/Memory wastage


2. VARCHAR/VARCHAR2
 It is used to store the characters.
 It accepts the following
‘a-z’, ‘A-Z’, ‘0-9’, Special characters and Alphanumeric characters
(Combination of alphabet and numbers).
 We have to write characters within (‘’) single quotes.
SYNTAX: VARCHAR(SIZE)
 Whenever we use varchar data type we have to mention the size for it.
 The maximum size of char data type is 2000ch.
 Char datatype follows “Variable length memory allocation”.
Example: CHAR (10)
D I N G A

Used memory Unused memory/Free memory


VARCHAR2
It is an updated version of VARCHAR datatype. The maximum size of
VARCHAR2 is 4000ch.
Syntax: VARCHAR2(SIZE)
 VARCHAR is outdated, if you assign VARCHAR to any column, compiler
will convert that into VARCHAR2 only.

Compiler
VARCHAR VARCHAR2
3.DATE
 It is used to store the date kind of data.
 It will accept oracle-based date formats are
1. ‘DD-MON-YYYY’
Example: ‘14-MAR-2024’
2. ‘DD-MON-YY’
Example: ’14-MAR-24’
Syntax: DATE

4.NUMBER
Number data type is used to accept only the numerical values that is given for a
column.
Syntax: NUMBER (PRECISION, [SCALE])
PRECISION: It is used to determine the total number of digits present in the value.
The range of precision is 1 to 38.
SCALE: It is used to determine the total number of decimal digits present in the value.
The range of scale is from -84 to 127.
Scale is not mandatory and default value of scale is 0.
Example:
Case 1: Without scale value.
NUMBER (6)
9 9 9 9 9 9
The maximum value that we can store here is 9,99,999 and we cannot store more than
9,99,999.
Case 2: When precision is more than scale.
NUMBER (4,2)
9 9 9 9

99.99 is the maximum value that we can store here.


Case 3: When precision is equal to scale.
NUMBER (3,3)
9 9 9

0.999 is the maximum value that we can store here.


Case 4: When precision is less than scale.
NUMBER (2,4)

Difference between scale and precision=S-P=4-2=2.


0 0 9 9
0.0099 is the maximum value that we can store here.
5.LARGE OBJECTS
1) CHARACTER LARGE OBJECTS:
These are used to store characters up to 4GB of size.

Syntax: CLOB

2) BINARY LARGE OBJECTS


These are used to store Binary numbers of images, documents, MP3 & MP4
files etc up to 4GB of size.

Syntax: BLOB

You might also like