---
layout: article
title: Tables
description: Organize your data with Appwrite Tables. Explore how to create and configure tables to store and structure your data effectively.
---
Appwrite uses tables as containers of rows. Each tables contains many rows identical in structure.
The terms tables and rows are used because the Appwrite JSON REST API resembles the API of a traditional NoSQL database, making it intuitive and user-friendly, even though Appwrite uses SQL under the hood.

That said, Appwrite is designed to support both SQL and NoSQL database adapters like MariaDB, MySQL, or MongoDB in future versions.

# Create table {% #create-table %}
You can create tables using the Appwrite Console, a [Server SDK](/docs/sdks#server), or using the [CLI](/docs/tooling/command-line/installation).
{% tabs %}

{% tabsitem #console title="Console" %}
You can create a table by heading to the **Databases** page, navigate to a [database](/docs/products/databases/databases), and click **Create table**.

{% /tabsitem %}

{% tabsitem #server-sdk title="Server SDK" %}
You can also create tables programmatically using a [Server SDK](/docs/sdks#server). Appwrite [Server SDKs](/docs/sdks#server) require an [API key](/docs/advanced/platform/api-keys).

{% multicode %}

```server-nodejs
const sdk = require('node-appwrite');

// Init SDK
const client = new sdk.Client();

const tablesDB = new sdk.TablesDB(client);

client
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<PROJECT_ID>') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;

const promise = tablesDB.createTable({
    databaseId: '<DATABASE_ID>',
    tableId: '<TABLE_ID>',
    name: '<NAME>',
    columns: [
        {
            key: 'email',
            type: 'email',
            required: true
        },
        {
            key: 'name',
            type: 'varchar',
            size: 255,
            required: true
        },
        {
            key: 'bio',
            type: 'text',
            required: false
        },
        {
            key: 'content',
            type: 'mediumtext',
            required: false
        },
        {
            key: 'data',
            type: 'longtext',
            required: false
        },
        {
            key: 'age',
            type: 'integer',
            required: false
        },
        {
            key: 'score',
            type: 'float',
            required: false
        },
        {
            key: 'total_views',
            type: 'bigint',
            required: false
        },
        {
            key: 'is_active',
            type: 'boolean',
            required: true
        },
        {
            key: 'created_at',
            type: 'datetime',
            required: false
        },
        {
            key: 'status',
            type: 'enum',
            elements: ['draft', 'published', 'archived'],
            required: true
        },
        {
            key: 'ip_address',
            type: 'ip',
            required: false
        },
        {
            key: 'website',
            type: 'url',
            required: false
        },
        {
            key: 'location',
            type: 'point',
            required: false
        },
        {
            key: 'path',
            type: 'line',
            required: false
        },
        {
            key: 'area',
            type: 'polygon',
            required: false
        },
        {
            key: 'related_items',
            type: 'relationship',
            relatedTableId: '<RELATED_TABLE_ID>',
            relationType: 'manyToMany',
            twoWay: true,
            twoWayKey: 'items',
            onDelete: 'cascade',
            required: false
        }
    ],
    indexes: [
        {
            key: 'idx_email',
            type: 'unique',
            attributes: ['email']
        },
        {
            key: 'idx_name',
            type: 'key',
            attributes: ['name']
        },
        {
            key: 'idx_name_fulltext',
            type: 'fulltext',
            attributes: ['name']
        }
    ]
});

promise.then(function (response) {
    console.log(response);
}, function (error) {
    console.log(error);
});
```
```deno
import * as sdk from "npm:node-appwrite";

// Init SDK
let client = new sdk.Client();

let tablesDB = new sdk.TablesDB(client);

client
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<PROJECT_ID>') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;

let promise = tablesDB.createTable({
    databaseId: '<DATABASE_ID>',
    tableId: '<TABLE_ID>',
    name: '<NAME>',
    columns: [
        {
            key: 'email',
            type: 'email',
            required: true
        },
        {
            key: 'name',
            type: 'varchar',
            size: 255,
            required: true
        },
        {
            key: 'bio',
            type: 'text',
            required: false
        },
        {
            key: 'content',
            type: 'mediumtext',
            required: false
        },
        {
            key: 'data',
            type: 'longtext',
            required: false
        },
        {
            key: 'age',
            type: 'integer',
            required: false
        },
        {
            key: 'score',
            type: 'float',
            required: false
        },
        {
            key: 'total_views',
            type: 'bigint',
            required: false
        },
        {
            key: 'is_active',
            type: 'boolean',
            required: true
        },
        {
            key: 'created_at',
            type: 'datetime',
            required: false
        },
        {
            key: 'status',
            type: 'enum',
            elements: ['draft', 'published', 'archived'],
            required: true
        },
        {
            key: 'ip_address',
            type: 'ip',
            required: false
        },
        {
            key: 'website',
            type: 'url',
            required: false
        },
        {
            key: 'location',
            type: 'point',
            required: false
        },
        {
            key: 'path',
            type: 'line',
            required: false
        },
        {
            key: 'area',
            type: 'polygon',
            required: false
        },
        {
            key: 'related_items',
            type: 'relationship',
            relatedTableId: '<RELATED_TABLE_ID>',
            relationType: 'manyToMany',
            twoWay: true,
            twoWayKey: 'items',
            onDelete: 'cascade',
            required: false
        }
    ],
    indexes: [
        {
            key: 'idx_email',
            type: 'unique',
            attributes: ['email']
        },
        {
            key: 'idx_name',
            type: 'key',
            attributes: ['name']
        },
         {
            key: 'idx_name_fulltext',
            type: 'fulltext',
            attributes: ['name']
        }
    ]
});

promise.then(function (response) {
    console.log(response);
}, function (error) {
    console.log(error);
});
```
```php
<?php

use Appwrite\Client;
use Appwrite\Services\TablesDB;

$client = new Client();

$client
    ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
    ->setProject('<PROJECT_ID>') // Your project ID
    ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;

$tablesDB = new TablesDB($client);

$result = $tablesDB->createTable(
    databaseId: '<DATABASE_ID>',
    tableId: '<TABLE_ID>',
    name: '<NAME>',
    columns: [
        [
            'key' => 'email',
            'type' => 'email',
            'required' => true
        ],
        [
            'key' => 'name',
            'type' => 'varchar',
            'size' => 255,
            'required' => true
        ],
        [
            'key' => 'bio',
            'type' => 'text',
            'required' => false
        ],
        [
            'key' => 'content',
            'type' => 'mediumtext',
            'required' => false
        ],
        [
            'key' => 'data',
            'type' => 'longtext',
            'required' => false
        ],
        [
            'key' => 'age',
            'type' => 'integer',
            'required' => false
        ],
        [
            'key' => 'score',
            'type' => 'float',
            'required' => false
        ],
        [
            'key' => 'total_views',
            'type' => 'bigint',
            'required' => false
        ],
        [
            'key' => 'is_active',
            'type' => 'boolean',
            'required' => true
        ],
        [
            'key' => 'created_at',
            'type' => 'datetime',
            'required' => false
        ],
        [
            'key' => 'status',
            'type' => 'enum',
            'elements' => ['draft', 'published', 'archived'],
            'required' => true
        ],
        [
            'key' => 'ip_address',
            'type' => 'ip',
            'required' => false
        ],
        [
            'key' => 'website',
            'type' => 'url',
            'required' => false
        ],
        [
            'key' => 'location',
            'type' => 'point',
            'required' => false
        ],
        [
            'key' => 'path',
            'type' => 'line',
            'required' => false
        ],
        [
            'key' => 'area',
            'type' => 'polygon',
            'required' => false
        ],
        [
            'key' => 'related_items',
            'type' => 'relationship',
            'relatedTableId' => '<RELATED_TABLE_ID>',
            'relationType' => 'manyToMany',
            'twoWay' => true,
            'twoWayKey' => 'items',
            'onDelete' => 'cascade',
            'required' => false
        ]
    ],
    indexes: [
        [
            'key' => 'idx_email',
            'type' => 'unique',
            'attributes' => ['email']
        ],
        [
            'key' => 'idx_name',
            'type' => 'key',
            'attributes' => ['name']
        ],
        [
            'key' => 'idx_name_fulltext',
            'type' => 'fulltext',
            'attributes' => ['name']
        ]
    ]
);
```
```python
from appwrite.client import Client
from appwrite.services.tables_db import TablesDB

client = Client()

(client
  .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
  .set_project('<PROJECT_ID>') # Your project ID
  .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)

tablesDB = TablesDB(client)

result = tablesDB.create_table(
    database_id='<DATABASE_ID>',
    table_id='<TABLE_ID>',
    name='<NAME>',
    columns=[
        {
            'key': 'email',
            'type': 'email',
            'required': True
        },
        {
            'key': 'name',
            'type': 'varchar',
            'size': 255,
            'required': True
        },
        {
            'key': 'bio',
            'type': 'text',
            'required': False
        },
        {
            'key': 'content',
            'type': 'mediumtext',
            'required': False
        },
        {
            'key': 'data',
            'type': 'longtext',
            'required': False
        },
        {
            'key': 'age',
            'type': 'integer',
            'required': False
        },
        {
            'key': 'score',
            'type': 'float',
            'required': False
        },
        {
            'key': 'total_views',
            'type': 'bigint',
            'required': False
        },
        {
            'key': 'is_active',
            'type': 'boolean',
            'required': True
        },
        {
            'key': 'created_at',
            'type': 'datetime',
            'required': False
        },
        {
            'key': 'status',
            'type': 'enum',
            'elements': ['draft', 'published', 'archived'],
            'required': True
        },
        {
            'key': 'ip_address',
            'type': 'ip',
            'required': False
        },
        {
            'key': 'website',
            'type': 'url',
            'required': False
        },
        {
            'key': 'location',
            'type': 'point',
            'required': False
        },
        {
            'key': 'path',
            'type': 'line',
            'required': False
        },
        {
            'key': 'area',
            'type': 'polygon',
            'required': False
        },
        {
            'key': 'related_items',
            'type': 'relationship',
            'relatedTableId': '<RELATED_TABLE_ID>',
            'relationType': 'manyToMany',
            'twoWay': True,
            'twoWayKey': 'items',
            'onDelete': 'cascade',
            'required': False
        }
    ],
    indexes=[
        {
            'key': 'idx_email',
            'type': 'unique',
            'attributes': ['email']
        },
        {
            'key': 'idx_name',
            'type': 'key',
            'attributes': ['name']
        },
        {
            'key': 'idx_name_fulltext',
            'type': 'fulltext',
            'attributes': ['name']
        }
    ]
)
```
```ruby
require 'Appwrite'

include Appwrite

client = Client.new
    .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
    .set_project('<PROJECT_ID>') # Your project ID
    .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key

tablesDB = TablesDB.new(client)

response = tablesDB.create_table(
    database_id: '<DATABASE_ID>',
    table_id: '<TABLE_ID>',
    name: '<NAME>',
    columns: [
        {
            key: 'email',
            type: 'email',
            required: true
        },
        {
            key: 'name',
            type: 'varchar',
            size: 255,
            required: true
        },
        {
            key: 'bio',
            type: 'text',
            required: false
        },
        {
            key: 'content',
            type: 'mediumtext',
            required: false
        },
        {
            key: 'data',
            type: 'longtext',
            required: false
        },
        {
            key: 'age',
            type: 'integer',
            required: false
        },
        {
            key: 'score',
            type: 'float',
            required: false
        },
        {
            key: 'total_views',
            type: 'bigint',
            required: false
        },
        {
            key: 'is_active',
            type: 'boolean',
            required: true
        },
        {
            key: 'created_at',
            type: 'datetime',
            required: false
        },
        {
            key: 'status',
            type: 'enum',
            elements: ['draft', 'published', 'archived'],
            required: true
        },
        {
            key: 'ip_address',
            type: 'ip',
            required: false
        },
        {
            key: 'website',
            type: 'url',
            required: false
        },
        {
            key: 'location',
            type: 'point',
            required: false
        },
        {
            key: 'path',
            type: 'line',
            required: false
        },
        {
            key: 'area',
            type: 'polygon',
            required: false
        },
        {
            key: 'related_items',
            type: 'relationship',
            relatedTableId: '<RELATED_TABLE_ID>',
            relationType: 'manyToMany',
            twoWay: true,
            twoWayKey: 'items',
            onDelete: 'cascade',
            required: false
        }
    ],
    indexes: [
        {
            key: 'idx_email',
            type: 'unique',
            attributes: ['email']
        },
        {
            key: 'idx_name',
            type: 'key',
            attributes: ['name']
        },
        {
            key: 'idx_name_fulltext',
            type: 'fulltext',
            attributes: ['name']
        }
    ]
)

puts response.inspect
```
```csharp
using Appwrite;
using Appwrite.Services;
using Appwrite.Models;

var client = new Client()
    .SetEndPoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
    .SetProject("<PROJECT_ID>") // Your project ID
    .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

var tablesDB = new TablesDB(client);

Table result = await tablesDB.CreateTable(
    databaseId: "<DATABASE_ID>",
    tableId: "<TABLE_ID>",
    name: "<NAME>",
    columns: new List<Dictionary<string, object>>
    {
        new Dictionary<string, object>
        {
            { "key", "email" },
            { "type", "email" },
            { "required", true }
        },
        new Dictionary<string, object>
        {
            { "key", "name" },
            { "type", "varchar" },
            { "size", 255 },
            { "required", true }
        },
        new Dictionary<string, object>
        {
            { "key", "bio" },
            { "type", "text" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "content" },
            { "type", "mediumtext" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "data" },
            { "type", "longtext" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "age" },
            { "type", "integer" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "score" },
            { "type", "float" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "total_views" },
            { "type", "bigint" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "is_active" },
            { "type", "boolean" },
            { "required", true }
        },
        new Dictionary<string, object>
        {
            { "key", "created_at" },
            { "type", "datetime" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "status" },
            { "type", "enum" },
            { "elements", new List<string> { "draft", "published", "archived" } },
            { "required", true }
        },
        new Dictionary<string, object>
        {
            { "key", "ip_address" },
            { "type", "ip" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "website" },
            { "type", "url" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "location" },
            { "type", "point" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "path" },
            { "type", "line" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "area" },
            { "type", "polygon" },
            { "required", false }
        },
        new Dictionary<string, object>
        {
            { "key", "related_items" },
            { "type", "relationship" },
            { "relatedTableId", "<RELATED_TABLE_ID>" },
            { "relationType", "manyToMany" },
            { "twoWay", true },
            { "twoWayKey", "items" },
            { "onDelete", "cascade" },
            { "required", false }
        }
    },
    indexes: new List<Dictionary<string, object>>
    {
        new Dictionary<string, object>
        {
            { "key", "idx_email" },
            { "type", "unique" },
            { "attributes", new List<string> { "email" } }
        },
        new Dictionary<string, object>
        {
            { "key", "idx_name" },
            { "type", "key" },
            { "attributes", new List<string> { "name" } }
        },
        new Dictionary<string, object>
        {
            { "key", "idx_name_fulltext" },
            { "type", "fulltext" },
            { "attributes", new List<string> { "name" } }
        }
    });
```
```dart
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
  Client client = Client();
  Databases tablesDB = TablesDB(client);

  client
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<PROJECT_ID>') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
  ;

  Future result = tablesDB.createTable(
    databaseId: '<DATABASE_ID>',
    tableId: '<TABLE_ID>',
    name: '<NAME>',
    columns: [
        {
            'key': 'email',
            'type': 'email',
            'required': true
        },
        {
            'key': 'name',
            'type': 'varchar',
            'size': 255,
            'required': true
        },
        {
            'key': 'bio',
            'type': 'text',
            'required': false
        },
        {
            'key': 'content',
            'type': 'mediumtext',
            'required': false
        },
        {
            'key': 'data',
            'type': 'longtext',
            'required': false
        },
        {
            'key': 'age',
            'type': 'integer',
            'required': false
        },
        {
            'key': 'score',
            'type': 'float',
            'required': false
        },
        {
            'key': 'total_views',
            'type': 'bigint',
            'required': false
        },
        {
            'key': 'is_active',
            'type': 'boolean',
            'required': true
        },
        {
            'key': 'created_at',
            'type': 'datetime',
            'required': false
        },
        {
            'key': 'status',
            'type': 'enum',
            'elements': ['draft', 'published', 'archived'],
            'required': true
        },
        {
            'key': 'ip_address',
            'type': 'ip',
            'required': false
        },
        {
            'key': 'website',
            'type': 'url',
            'required': false
        },
        {
            'key': 'location',
            'type': 'point',
            'required': false
        },
        {
            'key': 'path',
            'type': 'line',
            'required': false
        },
        {
            'key': 'area',
            'type': 'polygon',
            'required': false
        },
        {
            'key': 'related_items',
            'type': 'relationship',
            'relatedTableId': '<RELATED_TABLE_ID>',
            'relationType': 'manyToMany',
            'twoWay': true,
            'twoWayKey': 'items',
            'onDelete': 'cascade',
            'required': false
        }
    ],
    indexes: [
        {
            'key': 'idx_email',
            'type': 'unique',
            'attributes': ['email']
        },
        {
            'key': 'idx_name',
            'type': 'key',
            'attributes': ['name']
        },
        {
            'key': 'idx_name_fulltext',
            'type': 'fulltext',
            'attributes': ['name']
        }
    ],
  );

  result
    .then((response) {
      print(response);
    }).catchError((error) {
      print(error.response);
  });
}
```
```kotlin
import io.appwrite.Client
import io.appwrite.services.TablesDB

val client = Client(context)
    .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<PROJECT_ID>") // Your project ID
    .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key

val tablesDB = TablesDB(client)

val response = tablesDB.createTable(
    databaseId = "<DATABASE_ID>",
    tableId = "<TABLE_ID>",
    name = "<NAME>",
    columns = listOf(
        mapOf(
            "key" to "email",
            "type" to "email",
            "required" to true
        ),
        mapOf(
            "key" to "name",
            "type" to "varchar",
            "size" to 255,
            "required" to true
        ),
        mapOf(
            "key" to "bio",
            "type" to "text",
            "required" to false
        ),
        mapOf(
            "key" to "content",
            "type" to "mediumtext",
            "required" to false
        ),
        mapOf(
            "key" to "data",
            "type" to "longtext",
            "required" to false
        ),
        mapOf(
            "key" to "age",
            "type" to "integer",
            "required" to false
        ),
        mapOf(
            "key" to "score",
            "type" to "float",
            "required" to false
        ),
        mapOf(
            "key" to "total_views",
            "type" to "bigint",
            "required" to false
        ),
        mapOf(
            "key" to "is_active",
            "type" to "boolean",
            "required" to true
        ),
        mapOf(
            "key" to "created_at",
            "type" to "datetime",
            "required" to false
        ),
        mapOf(
            "key" to "status",
            "type" to "enum",
            "elements" to listOf("draft", "published", "archived"),
            "required" to true
        ),
        mapOf(
            "key" to "ip_address",
            "type" to "ip",
            "required" to false
        ),
        mapOf(
            "key" to "website",
            "type" to "url",
            "required" to false
        ),
        mapOf(
            "key" to "location",
            "type" to "point",
            "required" to false
        ),
        mapOf(
            "key" to "path",
            "type" to "line",
            "required" to false
        ),
        mapOf(
            "key" to "area",
            "type" to "polygon",
            "required" to false
        ),
        mapOf(
            "key" to "related_items",
            "type" to "relationship",
            "relatedTableId" to "<RELATED_TABLE_ID>",
            "relationType" to "manyToMany",
            "twoWay" to true,
            "twoWayKey" to "items",
            "onDelete" to "cascade",
            "required" to false
        )
    ),
    indexes = listOf(
        mapOf(
            "key" to "idx_email",
            "type" to "unique",
            "attributes" to listOf("email")
        ),
        mapOf(
            "key" to "idx_name",
            "type" to "key",
            "attributes" to listOf("name")
        ),
        mapOf(
            "key" to "idx_name_fulltext",
            "type" to "fulltext",
            "attributes" to listOf("name")
        )
    )
)
```
```java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.TablesDB;
import java.util.*;

Client client = new Client()
    .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<PROJECT_ID>") // Your project ID
    .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

Databases tablesDB = new TablesDB(client);

List<Map<String, Object>> columns = Arrays.asList(
    new HashMap<String, Object>() {{
        put("key", "email");
        put("type", "email");
        put("required", true);
    }},
    new HashMap<String, Object>() {{
        put("key", "name");
        put("type", "varchar");
        put("size", 255);
        put("required", true);
    }},
    new HashMap<String, Object>() {{
        put("key", "bio");
        put("type", "text");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "content");
        put("type", "mediumtext");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "data");
        put("type", "longtext");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "age");
        put("type", "integer");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "score");
        put("type", "float");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "total_views");
        put("type", "bigint");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "is_active");
        put("type", "boolean");
        put("required", true);
    }},
    new HashMap<String, Object>() {{
        put("key", "created_at");
        put("type", "datetime");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "status");
        put("type", "enum");
        put("elements", Arrays.asList("draft", "published", "archived"));
        put("required", true);
    }},
    new HashMap<String, Object>() {{
        put("key", "ip_address");
        put("type", "ip");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "website");
        put("type", "url");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "location");
        put("type", "point");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "path");
        put("type", "line");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "area");
        put("type", "polygon");
        put("required", false);
    }},
    new HashMap<String, Object>() {{
        put("key", "related_items");
        put("type", "relationship");
        put("relatedTableId", "<RELATED_TABLE_ID>");
        put("relationType", "manyToMany");
        put("twoWay", true);
        put("twoWayKey", "items");
        put("onDelete", "cascade");
        put("required", false);
    }}
);

List<Map<String, Object>> indexes = Arrays.asList(
    new HashMap<String, Object>() {{
        put("key", "idx_email");
        put("type", "unique");
        put("attributes", Arrays.asList("email"));
    }},
    new HashMap<String, Object>() {{
        put("key", "idx_name");
        put("type", "key");
        put("attributes", Arrays.asList("name"));
    }},
    new HashMap<String, Object>() {{
        put("key", "idx_name_fulltext");
        put("type", "fulltext");
        put("attributes", Arrays.asList("name"));
    }}
);

tablesDB.createTable(
    "<DATABASE_ID>",
    "<TABLE_ID>",
    "<NAME>",
    columns,
    indexes,
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);
```
```swift
import Appwrite

let client = Client()
    .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<PROJECT_ID>") // Your project ID
    .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key

let tablesDB = TablesDB(client)

let table = try await tablesDB.createTable(
    databaseId: "<DATABASE_ID>",
    tableId: "<TABLE_ID>",
    name: "<NAME>",
    columns: [
        [
            "key": "email",
            "type": "email",
            "required": true
        ],
        [
            "key": "name",
            "type": "varchar",
            "size": 255,
            "required": true
        ],
        [
            "key": "bio",
            "type": "text",
            "required": false
        ],
        [
            "key": "content",
            "type": "mediumtext",
            "required": false
        ],
        [
            "key": "data",
            "type": "longtext",
            "required": false
        ],
        [
            "key": "age",
            "type": "integer",
            "required": false
        ],
        [
            "key": "score",
            "type": "float",
            "required": false
        ],
        [
            "key": "total_views",
            "type": "bigint",
            "required": false
        ],
        [
            "key": "is_active",
            "type": "boolean",
            "required": true
        ],
        [
            "key": "created_at",
            "type": "datetime",
            "required": false
        ],
        [
            "key": "status",
            "type": "enum",
            "elements": ["draft", "published", "archived"],
            "required": true
        ],
        [
            "key": "ip_address",
            "type": "ip",
            "required": false
        ],
        [
            "key": "website",
            "type": "url",
            "required": false
        ],
        [
            "key": "location",
            "type": "point",
            "required": false
        ],
        [
            "key": "path",
            "type": "line",
            "required": false
        ],
        [
            "key": "area",
            "type": "polygon",
            "required": false
        ],
        [
            "key": "related_items",
            "type": "relationship",
            "relatedTableId": "<RELATED_TABLE_ID>",
            "relationType": "manyToMany",
            "twoWay": true,
            "twoWayKey": "items",
            "onDelete": "cascade",
            "required": false
        ]
    ],
    indexes: [
        [
            "key": "idx_email",
            "type": "unique",
            "attributes": ["email"]
        ],
        [
            "key": "idx_name",
            "type": "key",
            "attributes": ["name"]
        ],
        [
            "key": "idx_name_fulltext",
            "type": "fulltext",
            "attributes": ["name"]
        ]
    ]
)
```
```server-rust
use appwrite::Client;
use appwrite::services::tables_db::TablesDB;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new()
        .set_endpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
        .set_project("<PROJECT_ID>") // Your project ID
        .set_key("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key

    let tables_db = TablesDB::new(&client);

    let table = tables_db.create_table(
        "<DATABASE_ID>",
        "<TABLE_ID>",
        "<NAME>",
        None,       // permissions
        None,       // row_security
        None,       // enabled
        Some(vec![
            json!({
                "key": "email",
                "type": "email",
                "required": true
            }),
            json!({
                "key": "name",
                "type": "varchar",
                "size": 255,
                "required": true
            }),
            json!({
                "key": "bio",
                "type": "text",
                "required": false
            }),
            json!({
                "key": "content",
                "type": "mediumtext",
                "required": false
            }),
            json!({
                "key": "data",
                "type": "longtext",
                "required": false
            }),
            json!({
                "key": "age",
                "type": "integer",
                "required": false
            }),
            json!({
                "key": "score",
                "type": "float",
                "required": false
            }),
            json!({
                "key": "total_views",
                "type": "bigint",
                "required": false
            }),
            json!({
                "key": "is_active",
                "type": "boolean",
                "required": true
            }),
            json!({
                "key": "created_at",
                "type": "datetime",
                "required": false
            }),
            json!({
                "key": "status",
                "type": "enum",
                "elements": ["draft", "published", "archived"],
                "required": true
            }),
            json!({
                "key": "ip_address",
                "type": "ip",
                "required": false
            }),
            json!({
                "key": "website",
                "type": "url",
                "required": false
            }),
            json!({
                "key": "location",
                "type": "point",
                "required": false
            }),
            json!({
                "key": "path",
                "type": "line",
                "required": false
            }),
            json!({
                "key": "area",
                "type": "polygon",
                "required": false
            }),
            json!({
                "key": "related_items",
                "type": "relationship",
                "relatedTableId": "<RELATED_TABLE_ID>",
                "relationType": "manyToMany",
                "twoWay": true,
                "twoWayKey": "items",
                "onDelete": "cascade",
                "required": false
            }),
        ]),
        Some(vec![
            json!({
                "key": "idx_email",
                "type": "unique",
                "attributes": ["email"]
            }),
            json!({
                "key": "idx_name",
                "type": "key",
                "attributes": ["name"]
            }),
            json!({
                "key": "idx_name_fulltext",
                "type": "fulltext",
                "attributes": ["name"]
            }),
        ]),
    ).await?;

    println!("{:?}", table);
    Ok(())
}
```
{% /multicode %}

You can also configure **permissions** in the `createTable` method. Learn more about the `createTable` method in the [API references](/docs/references).
{% /tabsitem %}

{% tabsitem #cli title="CLI" %}

{% info title="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.
{% /info %}


To create your table using the CLI, first use the `appwrite init tables` command to initialize your table.

```sh
appwrite init tables
```

Then push your table using the `appwrite push tables` command.

```sh
appwrite push tables
```

This will create your table in the Console with all of your `appwrite.json` configurations.

{% arrow_link href="/docs/tooling/command-line/tables#commands" %}
Learn more about the CLI tables commands
{% /arrow_link %}

{% /tabsitem %}

{% /tabs %}

{% info title="AI suggestions" %}
Enable **AI suggestions** to generate columns and indexes based on your table name and existing database structure. [Learn more about AI suggestions](/docs/products/databases/ai-suggestions).
{% /info %}

# Permissions {% #permissions %}
Appwrite uses permissions to control data access.
For security, only users that are granted permissions can access a resource.
This helps prevent accidental data leaks by forcing you to make more conscious decisions around permissions.

By default, Appwrite doesn't grant permissions to any users when a new table is created.
This means users can't create new rows or read, update, and delete existing rows.

[Learn about configuring permissions](/docs/products/databases/permissions).

# Columns {% #columns %}
All rows in a table follow the same structure.
Columns are used to define the structure of your rows and help the Appwrite's API validate your users' input.
Add your first column by clicking the **Add column** button.

You can choose between the following types.

| Column    | Description                                                      |
|--------------|------------------------------------------------------------------|
| `varchar`    | String column. Fully indexable if size < 768. Maximum 16,383 characters. |
| `text`       | Text column. Prefix indexing only. Maximum 16,383 characters. |
| `mediumtext` | Text column. Prefix indexing only. Maximum 4,194,303 characters. |
| `longtext`   | Text column. Prefix indexing only. Maximum 1,073,741,823 characters. |
| `integer`    | Integer column. 32-bit signed, range -2,147,483,648 to 2,147,483,647. |
| `bigint`     | Big integer column. 64-bit signed, range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Ideal for timestamps, large counters, or IDs that exceed 32-bit limits. |
| `float`      | Float column.                                                 |
| `boolean`    | Boolean column.                                               |
| `datetime`   | Datetime column formatted as an ISO 8601 string.              |
| `enum`       | Enum column.                                                  |
| `ip`         | IP address column for IPv4 and IPv6.                          |
| `email`      | Email address column.                                         |
| `url`        | URL column.                                                   |
| `point`      | Geographic point specified as `[longitude, latitude]`.       |
| `line`       | Geographic line represented by an ordered list of coordinates. |
| `polygon`    | Geographic polygon representing a closed area; supports interior holes. |
| `relationship` | Relationship column relates one table to another. [Learn more about relationships.](/docs/products/databases/relationships) |
| `string`     | **Deprecated.** Use `varchar`, `text`, `mediumtext`, or `longtext` instead. |

If an column must be populated in all rows, set it as `required`.
If not, you may optionally set a default value.
Additionally, decide if the column should be a single value or an array of values.

If needed, you can change an column's key, default value, size (for text columns), and whether it is required or not after creation.

You can increase a varchar column's size without any restrictions. When decreasing size, you must ensure that your existing data is less than or equal to the new size, or the operation will fail.

# Indexes {% #indexes %}

Databases use indexes to quickly locate data without having to search through every row for matches.
To ensure the best performance, Appwrite recommends an index for every column queried.
If you plan to query multiple columns in a single query, creating an index with **all** queried columns will yield optimal performance.

The following indexes are currently supported:

| Type       | Description                                                                                                  |
|------------|--------------------------------------------------------------------------------------------------------------|
| `key`      | Plain Index to allow queries.                                                                                 |
| `unique`   | Unique Index to disallow duplicates.                                                                          |
| `fulltext` | For searching within text columns. Required for the [search query method](/docs/products/databases/queries#query-class).     |

You can create an index by navigating to your table's **Indexes** tab or by using your favorite [Server SDK](/docs/sdks#server).
