> For the complete documentation index, see [llms.txt](https://www.pranaypourkar.co.in/the-programmers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pranaypourkar.co.in/the-programmers-guide/database/sql-databases/sql-fundamentals/sql-data-types/character-types.md).

# Character Types

## About

**Character data types** are used to store **textual data**, such as names, addresses, and descriptions. SQL provides standard character types that most relational databases support, with slight variations.

There are two main categories:

1. **Fixed-length** character types
2. **Variable-length** character types

## 1. **CHAR(n)**

* Stores **fixed-length** character strings.
* Always occupies `n` characters, **padding with spaces** if input is shorter.
* Use when all values are known to have the same length (e.g., status codes, country codes).

**Example:**\
`CHAR(5)` will store `'abc'` as `'abc '` (with two spaces).

## 2. **VARCHAR(n)** or **CHARACTER VARYING(n)**

* Stores **variable-length** character strings.
* Maximum length is `n`, but only uses as much space as needed.
* More efficient for storing strings of varying length.

**Example:**\
`VARCHAR(10)` can store `'abc'` using 3 characters instead of 10.

## 3. **TEXT** (non-standard, vendor-specific)

* Stores large text data (longer than `VARCHAR(n)` limits).
* Not part of standard SQL but supported by many databases.

## Vendor Support Overview

<table data-header-hidden><thead><tr><th width="117.2265625"></th><th width="77.76171875"></th><th width="107.15234375"></th><th width="139.4921875"></th><th></th></tr></thead><tbody><tr><td>Database</td><td><code>CHAR</code></td><td><code>VARCHAR</code></td><td><code>TEXT</code> Support</td><td>Notes</td></tr><tr><td><strong>Oracle</strong></td><td>Yes</td><td>Yes</td><td>No <code>TEXT</code>; use <code>CLOB</code></td><td>Oracle uses <code>CLOB</code> for large character data. <code>VARCHAR2</code> is preferred.</td></tr><tr><td><strong>MySQL</strong></td><td>Yes</td><td>Yes</td><td>Yes</td><td>Supports <code>TINYTEXT</code>, <code>TEXT</code>, <code>MEDIUMTEXT</code>, <code>LONGTEXT</code>.</td></tr><tr><td><strong>PostgreSQL</strong></td><td>Yes</td><td>Yes</td><td>Yes</td><td><code>TEXT</code> has no length limit and behaves like unlimited <code>VARCHAR</code>.</td></tr><tr><td><strong>SQL Server</strong></td><td>Yes</td><td>Yes</td><td>Yes (<code>TEXT</code> deprecated)</td><td>Use <code>VARCHAR(MAX)</code> instead of <code>TEXT</code>.</td></tr><tr><td><strong>SQLite</strong></td><td>Yes</td><td>Yes</td><td>Yes</td><td>Very flexible typing; <code>TEXT</code> used commonly.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/database/sql-databases/sql-fundamentals/sql-data-types/character-types.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
