---
layout: article
title: Tables
description: Efficiently deploy your Appwrite tables using the Command-Line Tool (CLI).
---

**Before proceeding**

Ensure you [**install**](/docs/tooling/command-line/installation#getting-started) the CLI, [**log in**](/docs/tooling/command-line/installation#login) to your Appwrite account, and [**initialize**](/docs/tooling/command-line/installation#initialization) your Appwrite project.

Create and manage your tables using the CLI commands. The Appwrite CLI also helps you push your project's databases and tables schema from one project to another.

# Initialize table

Create a new table using the following command:

```sh
appwrite init tables
```

# Pull table

You can also pull your existing Appwrite tables and databases from the Appwrite Console using the `pull` command in the folder containing your `appwrite.config.json` file.

```sh
appwrite pull tables
```

# appwrite.config.json

After [initializing](/docs/tooling/command-line/installation#initialization) your Appwrite project and pulling your existing tables, your `appwrite.config.json` file should look similar to the following:

```json
{
    "projectId": "<PROJECT_ID>",
    "endpoint": "https://<REGION>.cloud.appwrite.io/v1",
    "tablesDB": [
        {
            "$id": "<DATABASE_ID>",
            "name": "songs",
            "$createdAt": "2023-07-01T18:35:27.802+00:00",
            "$updatedAt": "2023-08-01T21:41:41.663+00:00",
            "enabled": true
        }
    ],
    "tables": [
        {
            "$id": "<TABLE_ID>",
            "$permissions": [
                "create(\"any\")",
                "read(\"any\")",
                "update(\"any\")",
                "delete(\"any\")"
            ],
            "databaseId": "<DATABASE_ID>",
            "name": "music",
            "enabled": true,
            "rowSecurity": false,
            "columns": [
                {
                    "key": "userID",
                    "type": "varchar",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "size": 100,
                    "default": null
                },
                {
                    "key": "name",
                    "type": "varchar",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "size": 100,
                    "default": null
                },
                {
                    "key": "cloudinaryId",
                    "type": "varchar",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "size": 100,
                    "default": null
                },
                {
                    "key": "user",
                    "type": "varchar",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "size": 100,
                    "default": null
                },
                {
                    "key": "audio",
                    "type": "varchar",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "size": 200,
                    "default": null
                },
                {
                    "key": "genre",
                    "type": "varchar",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "size": 500,
                    "default": null
                },
                {
                    "key": "artist",
                    "type": "varchar",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "size": 500,
                    "default": null
                }
            ],
            "indexes": []
        }
    ]
}
```

You can also move the `tablesDB` and `tables` arrays into separate JSON files with the `includes` field.

[Learn more about multi-file configuration](/docs/tooling/command-line/installation#multi-file-configuration)

## Column types and formats

Each entry in a table's `columns` array uses `type` to select its base data type. For `"type": "string"`, `format` selects a specialized string validator: `email`, `url`, `ip`, or `enum`. For example, an email column is a string with an email format, not `"type": "email"`.

The following values are supported by the [CLI 27.3.0 schema dispatcher](https://github.com/appwrite/sdk-for-cli/blob/9d267aba479afce4a75dee6fefce96ded58f4d50/internal/schema/operations.go#L180-L226). Availability also depends on your Appwrite server version.

| Config `type` | Usage |
| --- | --- |
| `varchar` | Plain text with a maximum `size`. Use this for new plain text columns on servers that support it. |
| `string` | Legacy plain text with a maximum `size`, or a formatted string using one of the formats below. |
| `text`, `mediumtext`, `longtext` | Larger text values. These types do not use `size`. |
| `integer`, `bigint` | Whole numbers, with optional `min` and `max` bounds. |
| `double` | Floating-point numbers, with optional `min` and `max` bounds. Maps to the `float` API endpoint. |
| `boolean` | `true` or `false` values. |
| `datetime` | Date and time values in ISO 8601 format. This is a type, not a string format. |
| `relationship` | Relationships to another table, configured with fields such as `relatedTable` and `relationType`. |
| `point`, `linestring`, `polygon` | Spatial values. `linestring` maps to the `line` API endpoint. |

The CLI commands `create-float-column` and `update-float-column` use **float** in their names, but the corresponding JSON entry must use `"type": "double"`, not `"type": "float"`.

### String formats

Use `"type": "string"` for all four formats, even when other plain text columns use `varchar`. Adding `format` to `varchar` does not select a formatted-string endpoint.

| Config `format` | Accepted values |
| --- | --- |
| `email` | Email addresses. |
| `url` | URLs. |
| `ip` | IP addresses. |
| `enum` | One of the strings in the required `elements` array. |

Omit `format` for plain text. Formatted strings do not need `size`; enums need `elements` instead. Do not use arbitrary JSON Schema formats such as `uuid`: the CLI only dispatches the four formats listed above, and an unrecognized string format falls back to plain string creation.

`array` is a separate boolean modifier, not a type. For example, `"type": "varchar", "array": true` stores a list of strings. Spatial and relationship creation do not accept this modifier. There is no `"type": "array"` or arbitrary `"type": "object"` in this dispatcher.

### Column configuration examples

The following JSON array contains complete column definitions for plain text, email, enum, floating-point numbers, and a list of strings. Add the entries you need to a table's `columns` array in `appwrite.config.json`. Keep any existing columns you want to retain: removing a column from the configuration can delete it when you push.

```json
[
    {
        "key": "title",
        "type": "varchar",
        "size": 255,
        "required": true,
        "array": false
    },
    {
        "key": "contactEmail",
        "type": "string",
        "format": "email",
        "required": true,
        "array": false
    },
    {
        "key": "publicationStatus",
        "type": "string",
        "format": "enum",
        "elements": ["draft", "published", "archived"],
        "required": false,
        "array": false,
        "default": "draft"
    },
    {
        "key": "rating",
        "type": "double",
        "required": false,
        "array": false,
        "min": 0,
        "max": 5,
        "default": 2.5
    },
    {
        "key": "tags",
        "type": "varchar",
        "size": 100,
        "required": false,
        "array": true
    }
]
```

Include `key`, `type`, and `required` for these columns, plus `size` for plain `varchar` or legacy `string` columns, and `elements` for enums. An enum's default must be one of its `elements`; a numeric default must fall within its bounds. Do not set a default for required columns or array columns.

The same `type` and `format` distinction applies to legacy collection `attributes`. Keep the plain text type returned by your server when pulling an existing schema; changing `string` to `varchar` is a type change, not just a spelling change. Changing a column's type requires recreation and can lose its data.

# Push table

Use the `push` command in the folder containing your `appwrite.config.json` file to push the changes you made.

```sh
appwrite push tables
```

# Commands

The tables-db command allows you to create structured tables of rows, queries, and filter lists of rows. Appwrite TablesDB CLI commands generally follow the following syntax:

```sh
appwrite tables-db [COMMAND] [OPTIONS]
```

| Command | Description |
| --- | --- |
| `list-tables [options]` | Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. |
| `create-table [options]` | Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. |
| `get-table [options]` | Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. |
| `update-table [options]` | Update a table by its unique ID. |
| `delete-table [options]` | Delete a table by its unique ID. Only users with write permissions have access to delete this resource. |
| `list-columns [options]` | List columns in the table. |
| `create-boolean-column [options]` | Create a boolean column. |
| `update-boolean-column [options]` | Update a boolean column. Changing the 'default' value will not update already existing rows. |
| `create-datetime-column [options]` | Create a date time column according to the ISO 8601 standard. |
| `update-datetime-column [options]` | Update a date time column. Changing the 'default' value will not update already existing rows. |
| `create-email-column [options]` | Create an email column. |
| `update-email-column [options]` | Update an email column. Changing the 'default' value will not update already existing rows. |
| `create-enum-column [options]` | Create an enumeration column. The 'elements' param acts as a white-list of accepted values for this column. |
| `update-enum-column [options]` | Update an enum column. Changing the 'default' value will not update already existing rows. |
| `create-float-column [options]` | Create a float column. Optionally, minimum and maximum values can be provided. |
| `update-float-column [options]` | Update a float column. Changing the 'default' value will not update already existing rows. |
| `create-integer-column [options]` | Create an integer column. Optionally, minimum and maximum values can be provided. |
| `update-integer-column [options]` | Update an integer column. Changing the 'default' value will not update already existing rows. |
| `create-ip-column [options]` | Create IP address column. |
| `update-ip-column [options]` | Update an ip column. Changing the 'default' value will not update already existing rows. |
| `create-relationship-column [options]` | Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). |
| `create-string-column [options]` | Create a string column. |
| `update-string-column [options]` | Update a string column. Changing the 'default' value will not update already existing rows. |
| `create-text-column [options]` | Create a text column. |
| `update-text-column [options]` | Update a text column. Changing the 'default' value will not update already existing rows. |
| `create-url-column [options]` | Create a URL column. |
| `update-url-column [options]` | Update an url column. Changing the 'default' value will not update already existing rows. |
| `get-column [options]` | Get column by ID. |
| `delete-column [options]` | Deletes an column. |
| `update-relationship-column [options]` | Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). |
| `list-indexes [options]` | List indexes in the table. |
| `create-index [options]` | Creates an index on the columns listed. Your index should include all the columns you will query in a single request. Columns can be 'key', 'fulltext', and 'unique'. |
| `get-index [options]` | Get index by ID. |
| `delete-index [options]` | Delete an index. |
| `list-table-logs [options]` | Get the table activity logs list by its unique ID. |
