> For the complete documentation index, see [llms.txt](https://docs.acpt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acpt.io/custom-content-types/tables.md).

# Tables

Define custom database table schemas with columns, indexes, and foreign keys.

A **Table** defines the schema for a custom MySQL table. ACPT creates and manages the actual database table for you. Each table belongs to one [Table Group](https://docs.acpt.io/custom-content-types/table-groups.md) and can hold any number of records.

## The create/edit wizard

Creating or editing a table opens a four-step wizard.

<figure><img src="https://3235524095-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fiyf0tSKPgXiyoQ3zV3I6%2Fuploads%2Fgit-blob-ec00e79c68ddb26e36bd41801d75164084d15353%2Fcct-create-table-general.png?alt=media" alt="CCT create table – General step"><figcaption><p>Step 1 of the table creation wizard: General settings.</p></figcaption></figure>

### Step 1 — General

| Field                   | Description                                                                                                                                     |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**                | Table name in the database (snake\_case, no spaces). Required.                                                                                  |
| **Label**               | Human-readable label.                                                                                                                           |
| **Table Group**         | Which group this table belongs to.                                                                                                              |
| **ID strategy**         | How the primary key is generated (see below).                                                                                                   |
| **Expose via REST API** | If enabled, records are accessible via the `/wp-json/acpt/v1/{tableName}` endpoint.                                                             |
| **Menu icon**           | Dashicon displayed in the admin sidebar.                                                                                                        |
| **Menu position**       | Numeric position in the admin menu.                                                                                                             |
| **Capability**          | Minimum WordPress capability required to access the table admin.                                                                                |
| **Charset**             | Database character set (default: `utf8mb4`).                                                                                                    |
| **Collation**           | Database collation (default: `utf8mb4_unicode_ci`).                                                                                             |
| **Timestamps**          | Automatically add `created_at` and `updated_at` columns.                                                                                        |
| **Soft delete**         | Adds a `deleted_at` column for non-destructive record deletion.                                                                                 |
| **Options**             | MySQL table options, such as `ENGINE` or `COMMENT`. A new table starts with `ENGINE` set to **InnoDB** (see [Storage engine](#storage-engine)). |

### ID strategies

| Strategy            | Description                                                                                                          |
| ------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **AUTO\_INCREMENT** | Standard auto-incrementing integer primary key. Best for most use cases.                                             |
| **UUID**            | A UUID v4 string is generated for each new record. Useful for distributed systems or when IDs must not be guessable. |
| **ULID**            | A Universally Unique Lexicographically Sortable Identifier — sortable by creation time, URL-safe.                    |

### Step 2 — Columns

Define the table's columns using the [Canvas UI](https://docs.acpt.io/canvas-ui/canvas-ui.md). Drag columns to reorder them. See [Columns](https://docs.acpt.io/custom-content-types/columns.md) for all column types and settings.

<figure><img src="https://3235524095-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fiyf0tSKPgXiyoQ3zV3I6%2Fuploads%2Fgit-blob-d2499f915f887a604895b3e5ba88705e69a78d40%2Fcct-columns-canvas.png?alt=media" alt="CCT columns canvas"><figcaption><p>The Canvas UI for managing table columns.</p></figcaption></figure>

### Step 3 — Indexes

Add database indexes to improve query performance. See [Indexes](https://docs.acpt.io/custom-content-types/indexes.md).

### Step 4 — Foreign Keys

Define relationships between tables. See [Foreign Keys](https://docs.acpt.io/custom-content-types/foreign-keys.md).

## Managing Tables

Navigate to **ACPT → Custom Content Types** to see all tables.

<figure><img src="https://3235524095-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fiyf0tSKPgXiyoQ3zV3I6%2Fuploads%2Fgit-blob-05e06ee4575c0cbe813c1ce09f9bea9ec02dcea4%2Fcct-table-list.png?alt=media" alt="CCT table list"><figcaption><p>The Custom Content Types table list.</p></figcaption></figure>

The list shows:

* **Name** and **Label**
* **Schema status** — whether the MySQL table has been created
* **Stats** — record count
* **Group** — the table group the table belongs to

### Schema status

When you first save a table, ACPT attempts to create the database table automatically. If the schema is out of sync (e.g. after a column change), the list shows a **Create/Sync schema** button to regenerate the table structure.

{% hint style="info" %}
Schema changes to an existing table are applied non-destructively: new columns are added and type changes are applied. Removing a column from the schema does **not** automatically drop it from the database — use the Health Check tool to review schema drift.
{% endhint %}

### Storage engine

Custom tables should use the **InnoDB** storage engine. Engines like MyISAM have no transactions (a failed save isn't rolled back) and no [foreign keys](https://docs.acpt.io/custom-content-types/foreign-keys.md), and limit an index to 1,000 bytes, so a unique or indexed text column stops the table from being created.

**New tables.** Since 2.1.10 the wizard starts every new table with `ENGINE` set to InnoDB, even when your server's default engine is MyISAM. If you pick an engine without transactions and foreign keys, the **Options** section shows a warning:

> This engine has no foreign keys and no transactions, and an index can't be longer than 1,000 bytes, so a unique or indexed text column stops the table from being created. Use InnoDB unless you have a specific reason.

**Existing tables.** A table created before 2.1.10 on a server whose default engine is MyISAM may still be MyISAM, and still show as **Synced**, because the engine is part of its definition. The table list now shows the engine of such a table under **Schema status**, with the message "This table doesn't use InnoDB: records don't roll back and foreign keys can't be added." and a **Switch to InnoDB** action. The [Health check](https://docs.acpt.io/tools/health-check.md#custom-content-tables) lists these tables too.

**Switch to InnoDB** shows the `ALTER TABLE … ENGINE=InnoDB` statement it will run and asks for confirmation. It keeps every record and updates the table definition, so the table stays **Synced**.

{% hint style="warning" %}
MySQL rebuilds the table during the switch and locks it while it does. On a big table, run it when the site is quiet. ACPT never switches a table without asking: the Health check repair leaves your tables alone.
{% endhint %}

To check a table's engine from code, see [`get_acpt_table_status`](https://docs.acpt.io/developers/functions/get_acpt_table_status.md).

## Viewing a Table

Click the table name or **View** to open a read-only summary with four tabs: **General**, **Columns**, **Indexes**, and **Foreign Keys**.

Actions available from the view:

* **Edit** — reopen the wizard
* **Permissions** — configure access control

## Deleting a Table

Click **Delete** in the actions dropdown.

{% hint style="danger" %}
Deleting a table removes the table definition from ACPT **and drops the MySQL table**, permanently deleting all records. This action cannot be undone.
{% endhint %}
