PostgreSQL — Data Types
Numeric Types
| Type | Description |
|---|---|
| SMALLINT | 2 bytes |
| INTEGER | 4 bytes |
| BIGINT | 8 bytes |
| DECIMAL | Exact numeric |
| NUMERIC | Exact numeric |
| REAL | Floating point |
| DOUBLE | Double precision |
String Types
| Type | Description |
|---|---|
| VARCHAR(n) | Variable length |
| CHAR(n) | Fixed length |
| TEXT | Unlimited length |
Date/Time Types
| Type | Description |
|---|---|
| DATE | Date only |
| TIME | Time only |
| TIMESTAMP | Date and time |
| INTERVAL | Time interval |
Boolean
is_active BOOLEAN DEFAULT true
Array
tags TEXT[] ARRAY
JSON
data JSONB
UUID
id UUID DEFAULT gen_random_uuid()
Mini Practice
- Use numeric types
- Use string types
- Use date types
- Use special types
Up Next
Continue with Insert — inserting data.
Related Topics
Frequently Asked Questions about Data Types
What is Data Types in PostgreSQL?
Data Types is a fundamental concept in PostgreSQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Data Types?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Data Types.
Why is Data Types important in PostgreSQL?
Data Types is essential for PostgreSQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.