66 lines
2.8 KiB
Plaintext
66 lines
2.8 KiB
Plaintext
---
|
||
title: Data Types | Datasquirel docs
|
||
description: SQL data types supported by Datasquirel
|
||
page_title: Data Types
|
||
page_description: All SQL data types available for table fields in Datasquirel.
|
||
---
|
||
|
||
## Overview
|
||
|
||
Every field in a Datasquirel table has a **data type** that defines what kind of values the column can store. Datasquirel is built on MariaDB, so all standard MariaDB column types are supported.
|
||
|
||
Choosing the right data type matters for:
|
||
- **Storage efficiency** — smaller types use less disk space
|
||
- **Query performance** — properly typed columns are faster to index and compare
|
||
- **Data integrity** — the database enforces type constraints automatically
|
||
|
||
## Text Types
|
||
|
||
| Type | Description |
|
||
|------|-------------|
|
||
| `VARCHAR(n)` | Variable-length string up to `n` characters. Use for short text like names, slugs, email addresses. Maximum `n` is 65,535. |
|
||
| `TEXT` | Unlimited-length text. Use for longer content like descriptions or comments. |
|
||
| `LONGTEXT` | Very large text (up to 4 GB). Use for HTML, Markdown, or JSON stored as a string. |
|
||
| `CHAR(n)` | Fixed-length string of exactly `n` characters. Padded with spaces if shorter. |
|
||
| `ENUM(...)` | A value from a predefined list (e.g. `ENUM('draft', 'published', 'archived')`). |
|
||
|
||
## Numeric Types
|
||
|
||
| Type | Description |
|
||
|------|-------------|
|
||
| `INT` | 32-bit signed integer. Range: –2,147,483,648 to 2,147,483,647. |
|
||
| `BIGINT` | 64-bit signed integer. Use for IDs that may exceed 2 billion or for large counts. |
|
||
| `TINYINT` | 8-bit integer. Range: –128 to 127. Commonly used for boolean-like flags. |
|
||
| `SMALLINT` | 16-bit integer. Range: –32,768 to 32,767. |
|
||
| `FLOAT` | Single-precision floating-point number. |
|
||
| `DOUBLE` | Double-precision floating-point number. |
|
||
| `DECIMAL(p, s)` | Exact decimal with `p` total digits and `s` decimal places. Use for money values. |
|
||
|
||
## Date and Time Types
|
||
|
||
| Type | Description |
|
||
|------|-------------|
|
||
| `DATETIME` | A date and time value (e.g. `2024-03-15 14:30:00`). |
|
||
| `DATE` | A date without time (e.g. `2024-03-15`). |
|
||
| `TIME` | A time without date (e.g. `14:30:00`). |
|
||
| `TIMESTAMP` | A Unix timestamp. Automatically updates to the current time on row modification when configured. |
|
||
|
||
## Boolean
|
||
|
||
MariaDB does not have a native BOOLEAN type. Datasquirel uses `TINYINT(1)` for boolean fields — `1` for true, `0` for false.
|
||
|
||
## Structured Data
|
||
|
||
| Type | Description |
|
||
|------|-------------|
|
||
| `JSON` | Native JSON column. MariaDB validates and stores the value as structured JSON. |
|
||
| `LONGTEXT` | Store JSON, Markdown, or HTML as plain text when native JSON validation is not needed. |
|
||
|
||
<div className="w-full grid grid-cols-1 gap-4 items-stretch">
|
||
<DocsCard
|
||
title="VARCHAR"
|
||
description="Learn more about VARCHAR and when to use it."
|
||
href="/docs/database-reference/data-types/varchar"
|
||
/>
|
||
</div>
|