Welcome back

Sign in with GitHub, Google, or your email and password

or

Don't have an account? Create one

Manage Tables

Manage columns

Add, update, and remove columns on a PostgreSQL table in Fakebase Studio.

Adding and editing columns in Fakebase Studio

Open a table, then choose the Columns tab. You can add, edit, and remove columns without writing SQL.

The same changes can be pasted into the SQL editor. The examples below continue the orders table from Manage Tables.

Add a column

  1. Open a table and go to Columns.
  2. Choose Add column.
  3. Set the name, type, default, and constraints.
  4. Confirm.

You can also attach a foreign key while adding the column. See Relations.

ALTER TABLE public.orders
  ADD COLUMN status text NOT NULL DEFAULT 'pending';

Edit a column

Open the column row menu and choose Edit column. You can change the name, type, default, and constraints such as primary key, nullable, unique, and CHECK.

ALTER TABLE public.orders
  RENAME COLUMN status TO order_status;

ALTER TABLE public.orders
  ALTER COLUMN order_status SET DEFAULT 'open',
  ALTER COLUMN order_status SET NOT NULL;

ALTER TABLE public.orders
  ADD CONSTRAINT orders_order_status_check
  CHECK (order_status IN ('open', 'pending', 'paid', 'cancelled'));

Remove a column

Open the column row menu and choose Remove column. Fakebase also removes constraints that belong only to that column.

You cannot remove the last column on a table, a column that is part of a composite constraint, or a column referenced by another table's foreign key.

ALTER TABLE public.orders
  DROP COLUMN order_status;