# CREATE TABLE / DROP TABLE — the table lifecycle

Control-plane statements — DynamoDB's own PartiQL has **no DDL**, so these are a DynoStudio dialect surface that lowers to the native AWS calls (`CreateTable`, `DeleteTable`), with the plan disclosed in the "Executes as" strip before anything runs. A read-only stage refuses all mutating control-plane work.

## Syntax

```sql
CREATE TABLE "table" (
  PARTITION KEY name STRING | NUMBER | BINARY,   -- or S | N | B
  [SORT KEY name type]
) WITH BILLING = ON_DEMAND | PROVISIONED (RCU n, WCU n)

DROP TABLE "table"        -- DELETE TABLE is an accepted spelling
```

Each key attribute's type is **required**: DynamoDB fixes key types at creation and can't change them later, so the studio refuses a key with no explicit type rather than guess one. Guide: [Tables, indexes & replicas](https://www.kanject.com/docs/dynostudio-partiql-ddl/).

## Use cases

### Create a table, billed on demand

The default for new workloads — no capacity planning; the table is `CREATING` until DynamoDB brings it `ACTIVE`, and the status line says so.

```sql
CREATE TABLE "stage.Ledger" (
  PARTITION KEY pk STRING,
  SORT KEY sk STRING
) WITH BILLING = ON_DEMAND
```

_Executes as:_ CreateTable · keys pk (S) / sk (S) · BillingMode: PAY_PER_REQUEST

_Quote this example:_ https://www.kanject.com/docs/dynostudio-create-table/#create-on-demand

### Create a table with provisioned capacity

Steady, predictable traffic can beat on-demand pricing — name the read and write units explicitly.

```sql
CREATE TABLE "stage.Metrics" (
  PARTITION KEY metricId STRING,
  SORT KEY at NUMBER
) WITH BILLING = PROVISIONED (RCU 50, WCU 25)
```

_Executes as:_ CreateTable · keys metricId (S) / at (N) · ProvisionedThroughput: 50 RCU / 25 WCU

- A numeric sort key (`at NUMBER`) orders numerically — the right shape for epoch timestamps.

_Quote this example:_ https://www.kanject.com/docs/dynostudio-create-table/#create-provisioned

### Drop a table — deliberately hard

Irreversible, so the run opens a confirmation that stays **disarmed until you type the exact table name** — the same stance the AWS Console takes.

```sql
DROP TABLE "stage.Ledger"
```

_Executes as:_ DeleteTable · confirmation gate: type the table name to arm

- A set-based `DELETE FROM … WHERE` is a bulk *data* write from [DELETE](https://www.kanject.com/docs/dynostudio-delete/) — the two never collide.

_Quote this example:_ https://www.kanject.com/docs/dynostudio-create-table/#drop-table

## Try it

**Try it · CREATE TABLE**

```sql
CREATE TABLE "stage.Ledger" (
  PARTITION KEY pk STRING,
  SORT KEY sk STRING
) WITH BILLING = ON_DEMAND
```

_Executes as:_ CreateTable · stage.Ledger — The exact control-plane call, disclosed before consent — a read-only stage refuses it.

_Result:_ Table stage.Ledger · CREATING → ACTIVE

_Run it live in DynoStudio:_ https://www.kanject.com/dynostudio/

> **Key types are forever:** DynamoDB cannot change a key attribute's type after creation — a string `pk` stays a string. Model the key shape first (see [DynamoDB basics](https://www.kanject.com/docs/dynostudio-dynamodb-basics/) on access-pattern-first design); everything else about an item can vary later, but the keys can't.

Related: [Tables, indexes & replicas](https://www.kanject.com/docs/dynostudio-partiql-ddl/) · [CREATE GSI](https://www.kanject.com/docs/dynostudio-create-gsi/) · [Marker indexes](https://www.kanject.com/docs/dynostudio-marker-indexes/) · [DELETE](https://www.kanject.com/docs/dynostudio-delete/) for removing data.

---
_Source: https://www.kanject.com/docs/dynostudio-create-table/ · Kanject Docs_
