# Tables and columns

Source: https://cubibase.com/docs/database/tables

Also available: [Markdown version](https://cubibase.com/docs/database/tables.md) · [llms.txt](https://cubibase.com/llms.txt) · [full site content](https://cubibase.com/llms-full.txt)

Create tables from the Console. Every table is an ordinary PostgreSQL table in the public schema, with Row Level Security enabled from the start.

## The rules a table follows

- Names are lowercase: a letter first, then letters, digits, and underscores (up to 41 characters).
- Exactly one primary key column, chosen at creation. You cannot add or drop a primary key later.
- Up to 64 columns per table.
- Columns can be added and dropped later — except the primary key and the user column used for row policies.

> **important**: Decide the user column when you create the table: the ownership policy is created with it. To protect an existing table another way, write your own policy on the Policies screen.

## Column types

| Type | PostgreSQL type | Typical use |
| --- | --- | --- |
| `uuid` | `uuid` | Primary keys, references to user ids |
| `text` | `text` | Names, emails, the user column |
| `integer` | `integer` | Counters, small numbers |
| `bigint` | `bigint` | Large counters, external ids |
| `boolean` | `boolean` | Flags |
| `timestamptz` | `timestamptz` | Timestamps with time zone |
| `jsonb` | `jsonb` | Flexible structured data |
| `numeric` | `numeric` | Exact decimals, money |
| `double` | `double precision` | Floating-point measurements |

Columns are `NOT NULL` by default; mark a column nullable when it may be empty. Available defaults are `gen_random_uuid()`, `now()`, `true`, and `false`.

## A worked example

The `customers` table used throughout these docs:

**customers**

| Column | Type | Constraints |
| --- | --- | --- |
| `id` | `uuid` | Primary key · default `gen_random_uuid()` |
| `name` | `text` | Not null |
| `email` | `text` | Not null |
| `plan` | `text` | Not null |
| `owner_id` | `text` | Not null · user column |

With `owner_id` set as the user column, the API role can only read and write rows whose `owner_id` equals the JWT subject of the caller. The Console keeps full access through a separate developer policy.

## Changing a table later

| Change | Supported? | How |
| --- | --- | --- |
| Add a column | Yes | Table screen → add column (not as a primary key) |
| Drop a column | Yes | Except the primary key and the user column |
| Add a primary key | No | Create the table with the right key |
| Attach a user column | No | Recreate the table, or write an equivalent policy on the Policies screen |
| Run DDL in the SQL editor | No | The editor is read-only; use the table screen |

> **note**: A new table starts unexposed: the Data API treats it as not found until you turn on at least one operation.

## Additional resources

- [Exposing tables](https://cubibase.com/docs/database/exposure) Turn on the operations your app needs.
- [Row-level security](https://cubibase.com/docs/database/row-level-security) What the user column actually creates.
- [Writing rows](https://cubibase.com/docs/data-api/writing) Insert, update, and delete over HTTP.
