Lesson 4
Beginner Level
4 of 30 lessons
Oracle SQL Data Types
Learn about different data types in Oracle SQL including VARCHAR2, NUMBER, DATE, and more. Understanding data types is crucial for designing efficient database schemas.
Overview
Data types define the kind of data that can be stored in a column. Oracle SQL supports a wide range of data types for storing numbers, characters, dates, and more.
Common Oracle Data Types
| Data Type | Description | Example |
|---|---|---|
| VARCHAR2(n) | Variable-length character string (max n bytes) | 'John' |
| CHAR(n) | Fixed-length character string (padded with spaces) | 'A' |
| NUMBER(p,s) | Numeric values with precision and scale | 123.45 |
| DATE | Date and time values (to the second) | 25-MAR-2025 |
| CLOB | Character large object (for large text) | Used for articles, long notes |
Example
CREATE TABLE employees (
emp_id NUMBER(5),
first_name VARCHAR2(50),
salary NUMBER(8,2),
hire_date DATE
);
This statement creates a table with appropriate data types for each column.
Practice Task
- Create a table named
departmentswith columns:dept_id(NUMBER),dept_name(VARCHAR2).