Datatypes are used to specify the type of data that a column can store in a table.
Choosing the correct datatype helps in:
- Efficient storage of data
- Data validation
- Better performance
- Maintaining data integrity
Oracle SQL mainly provides:
- Numeric Datatypes
- Character (Alphanumeric) Datatypes
- Date Datatype
- Size: 4 Bytes
- Accepts only integer values.
- Does not accept decimal values.
column_name INT;age INT;18
25
100
18.5
25.75
-
Size: Up to 21 Bytes
-
Accepts:
- Integers
- Decimal numbers
- Positive values
- Negative values
column_name NUMBER;salary NUMBER;Where:
-
P → Precision
- Total number of digits.
-
S → Scale
- Number of digits after decimal point.
percentage NUMBER(4,2);| Value | Result |
|---|---|
| 8 | Valid |
| 73.69 | Valid |
| 61.3 | Valid |
| 61.3267 | Invalid |
| 564 | Invalid |
| 100 | Invalid |
Oracle provides two important character datatypes:
- CHAR(size)
- VARCHAR2(size)
-
Accepts:
- Alphabets
- Numbers
- Special characters
-
Fixed length datatype.
-
Static in nature.
-
Maximum size: 2000 characters.
column_name CHAR(size);name CHAR(10);If we store:
Sachin
The remaining memory is reserved and unused.
Hence:
- Memory may be wasted.
- Fixed storage is allocated.
-
Accepts:
- Alphabets
- Numbers
- Special characters
-
Variable length datatype.
-
Dynamic in nature.
-
Maximum size: 4000 characters.
column_name VARCHAR2(size);name VARCHAR2(10);If we store:
Sachin
Only the required memory is allocated.
Hence:
- Memory is not wasted.
- Better storage utilization.
| CHAR | VARCHAR2 |
|---|---|
| Fixed Length | Variable Length |
| Static | Dynamic |
| Wastes Memory | Efficient Memory Usage |
| Maximum 2000 Characters | Maximum 4000 Characters |
The DATE datatype is used to store:
- Date
- Month
- Year
DD-MM-YYYY
29-May-2000
YYYY-MM-DD
2000-05-29
| Datatype | Description |
|---|---|
| INT | Stores Integer Values |
| NUMBER | Stores Integers and Decimal Values |
| NUMBER(P,S) | Stores Numbers with Precision and Scale |
| CHAR | Fixed Length Character Data |
| VARCHAR2 | Variable Length Character Data |
| DATE | Stores Date Values |
This file provides complete Oracle SQL Datatypes notes including Numeric, Character, and Date datatypes with syntax, examples, differences, and interview-oriented explanations for beginners and SQL learners.
Happy Learning and Keep Practicing SQL!