SQL Text Data Types
VARCHAR, TEXT, and CHAR all hold text — the difference is length limits and padding behavior.
What & Why
VARCHAR(n) holds text up to n characters. TEXT holds text of any length, with no limit declared. CHAR(n) holds exactly n characters, padding shorter values with spaces.
See How It Works
TEXT TYPE BEHAVIOR
| Type | Behavior |
|---|---|
| VARCHAR(50) | Stores up to 50 characters; the campaign names shown here fit. |
| TEXT | Stores text without a declared length limit. |
| CHAR(10) | Stores `Spring` with four trailing spaces so the value occupies 10 characters. |
CHAR pads values to its fixed length. TEXT and VARCHAR are usually safer choices for variable-length business text.
Now You Try
Practice this concept
Marketing wants active campaign names and channels, demonstrating exact text filtering.
Available schema
marketingPrefix tables with marketing.table_name.
namechannelstatusmarketing.campaigns| Column | Type |
|---|---|
| id | integer |
| name | text |
| channel | text |
| spend | numeric |
| start_date | date |
| end_date | date |
| status | text |
| target_segment | text |
| legacy_id | text |
query.sql
Sign up free to try it on a real business scenario