Access a database instance from the SQL editor
Preview
This feature is in Public Preview in the following regions: us-east-1
, us-west-2
, eu-west-1
, ap-southeast-1
, ap-southeast-2
, eu-central-1
, us-east-2
, ap-south-1
.
This page describes how to access a Lakebase database instance from the SQL editor to run PostgreSQL commands and queries.
Before you begin
Verify that you meet the following requirements before connecting:
- You have a corresponding Postgres role to log in to the database instance. See Create and manage Postgres roles for Databricks identities.
- Your Postgres role is granted the necessary permissions to access the database, schema, or table.
The database instance creator already has the necessary permissions to access the database instance from the SQL editor. The instance creator can also add additional users to the instance and can grant Postgres permissions to the user.
Create a new query
Create a new SQL query in the SQL editor.
- Click Compute in the workspace sidebar.
- Click Database instances.
- Select the database instance you want to run PostgreSQL queries on.
- Click New Query in the upper-right.
Run queries
To run PostgreSQL queries, select the appropriate database and schema in the dropdown selector.
- Select the desired database and schema in the dropdown selector next to Run all.
- View databases, schemas, tables, and columns in PostgreSQL Databases
.
- You can fill in a table reference from the Schema Browser by clicking
next to the desired table.
- Write a PostgreSQL query, and click Run all.
Supported functionality and limitations
- The query access control list (ACL) permissions model applies:
- The 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. They do not work across different Run clicks, as each is its own session.
$$
blocks don’t work if statements inside have semicolons.