# Tables

Open **Tables** in the sidebar to see every table in the database. Use **Search tables** to find one, and the schema filter to switch between schemas. Select a table to open it.

Each table has three tabs: **Data** for its rows (see [Data](https://fakebase.studio/docs/studio-data.md)), **Columns**, and **RLS**.

[Creating a table in Fakebase Studio](https://fakebase.studio/docs/9a_create_table_demo.mp4)

## Create a table

1. Choose **New table**, or press **⌘N**.
2. Enter a **Name** and an optional **Description**.
3. Add columns. For each one, set the name, type, and default value, and whether it's the primary key. Under **Extra options** you can make it nullable, unique, an identity column, or an array.
4. Optionally add foreign keys with **Add foreign key relation**.
5. Save. Studio creates the table in the schema shown at the top of the form.

## Rename or delete a table

Open the table's menu (**⋮**) in the list, or right-click it:

- **Change table name** renames the table. Its rows, indexes, and constraints stay.
- **Delete table** removes the table and all its data.

The `_fakebase_migrations` table holds your migration history, so it can't be renamed or deleted.

## Columns

Open a table and choose the **Columns** tab.

[Adding and editing columns in Fakebase Studio](https://fakebase.studio/docs/9b_manage_col_demo.mp4)

- **Add a column:** choose **Add column**, set its name, type, default value, and constraints, then save.
- **Edit a column:** open the column's menu and choose **Edit column**. You can change its name, type, default value, and constraints.
- **Remove a column:** open the column's menu and choose **Remove column**. Studio tells you when a column can't be removed, for example the last column of a table, or one that another table's foreign key points to.

## Foreign keys

Add a foreign key while you create a table, or later from the column it belongs to:

1. Open the **Columns** tab and edit the column.
2. Choose **Add foreign key**.
3. Pick the schema, table, and column it references.
4. Choose what happens when the referenced row is updated or removed.
5. Save.

To remove a foreign key, edit the column and remove it from **Foreign Keys**. To see how all your tables connect, open [Schema](https://fakebase.studio/docs/studio-schema.md).

## Row-level security

The **RLS** tab shows whether row-level security is on for the table, and each policy with its command and its **USING** and **WITH CHECK** expressions. Select a policy to copy its details.

This tab is read-only. To change policies, write the SQL in a [migration](https://fakebase.studio/docs/migrations.md).

---

## Next steps

- [Data](https://fakebase.studio/docs/studio-data.md): Browse, insert, edit, and delete table rows in Fakebase Studio.
- [Schema](https://fakebase.studio/docs/studio-schema.md): See every table and the foreign keys between them as a diagram in Fakebase Studio.
