Skip to main content

Manage databases

Beta

Lakebase Postgres (Autoscaling Beta) is the next version of Lakebase, available for evaluation only. For production workloads, use Lakebase Public Preview. See choosing between versions to understand which version is right for you.

A database is a container for SQL objects such as schemas, tables, views, functions, and indexes. In Lakebase, a database exists within a branch of a project, with a limit of 500 databases per branch.

Database overview

Each project's default branch is created with a database called databricks_postgres, which is owned by the Postgres role for your Databricks identity (for example, user@databricks.com).

Databases created in the Lakebase App are created in the Postgres public schema default.

View databases

To view databases for a branch, navigate to your branch's Roles & Databases tab in the Lakebase App.

View databases in the LKB App

The databases section displays information about all databases in the selected branch:

Detail

Description

Database name

The name of the database

Owner

The Postgres role that owns and has full privileges on the database

Created

When the database was created

Last updated

The last time the database was updated

Create a database

You can create additional Postgres databases on your branch using the Lakebase App or SQL commands.

To create a database using the Lakebase App:

  1. Navigate to your branch's Roles & Databases tab in the Lakebase App.
  2. Click Add database, enter a database name following Postgres naming conventions, and select the owner role.
important

Some database names are reserved and cannot be used: databricks_postgres (already used as the default database name), postgres, template0, template1.

Manage databases with SQL

Create a database

Create databases using standard Postgres SQL commands:

SQL
CREATE DATABASE my_application_db
WITH OWNER = my_app_role
ENCODING = 'UTF8';
note

Databases created using SQL commands will automatically appear in the Lakebase App under your branch's Roles & Databases tab.

List databases

View all databases in your project:

SQL
SELECT datname, datowner, encoding
FROM pg_database
WHERE datistemplate = false;

Switch between databases

Switch to a different database:

Monitor database size

Check the logical size of a database:

SQL
SELECT
datname AS database_name,
pg_size_pretty(pg_database_size(datname)) AS size
FROM pg_database
WHERE datistemplate = false
ORDER BY pg_database_size(datname) DESC;

Delete a database

important

Deleting a database permanently removes all schemas, tables, and data within that database. This action cannot be undone.

To delete a database using the Lakebase App:

  1. Navigate to your branch's Roles & Databases tab in the Lakebase App.
  2. Click the Kebab menu icon. menu for the database, select Delete database, and enter the database name to confirm.

To delete using SQL:

SQL
-- Drop the database
DROP DATABASE database_to_delete;