Skip to main content

Connect and query a database instance

info

Lakebase Provisioned is the original Lakebase offering that uses provisioned compute you scale manually. For supported regions, see Region availability. For the latest version of Lakebase, with autoscaling compute, scale-to-zero, branching, and instant restore, see Lakebase Autoscaling.

New Lakebase instances will be created as Autoscaling projects. Rollout starts March 12, 2026. For details, see Autoscaling by default.

This page describes how to connect to a Lakebase Provisioned database instance from the SQL editor and external SQL clients.

Before you begin

  • You have a corresponding Postgres role for your Databricks identity. See Postgres roles.
  • Your Postgres role is granted the necessary permissions to access the database, schema, or table.
  • You can authenticate to the database instance. See Authenticate to a database instance.

Connect from the SQL editor

Create a new SQL query in the SQL editor.

  1. Click App icon. Apps in the top right corner and select Lakebase Postgres.
  2. Click Provisioned to open the Provisioned instances page.
  3. Select the database instance you want to run PostgreSQL queries on.
  4. Click New Query in the upper-right.
  5. To run a read-only query on readable secondaries:
    1. Click the compute resources drop-down menu and select your compute that has the (Read-only) label.
    2. Click Switch.
  6. Select the desired database and schema in the dropdown selector next to Run all.
  7. Write a PostgreSQL query, and click Run all.

Limitations

  • The query access control list (ACL) permissions model applies. Execution happens with the Databricks identity of the user who clicks Run. Anyone with at least CAN VIEW access on the query can see the results as they appear in the SQL Editor.
  • Connection-scoped objects such as temporary tables and transactions work in a single cell only. They do not work across different Run clicks, as each is its own session.
  • If $$ blocks contain statements that have semicolons, only the results for the last statement are shown.

Connect from SQL clients

You can access a database instance from external tools such as psql, DBeaver, and pgAdmin4.

Connect with psql

  1. Click App icon. Apps in the top right corner and select Lakebase Postgres.
  2. Click Provisioned to open the Provisioned instances page.
  3. Select the database instance you want to access.
  4. Click Connection details.
  5. Copy the Connect with PSQL string.
  6. Paste the command into your terminal and run it.