By default, SQL Editor allows executing both read (SELECT) and write (DDL/DML) SQL statements.Running DDL or DML change statements requires the
bb.sql.ddl / bb.sql.dml database permissions, granted for selected environments. Without them, SQL Editor is effectively read-only: if you attempt a DDL or DML change query, SQL Editor will direct you to create a database change plan and follow the change workflow.Workspace Admins and DBAs can always execute any SQL statements in Admin Mode.On PostgreSQL, a statement that writes data counts as DML even when it starts with
SELECT or EXPLAIN: a SELECT whose WITH clause runs INSERT, UPDATE, DELETE, or MERGE, and EXPLAIN ANALYZE of a write or of such a SELECT, which executes it. bb.sql.select alone does not run them. The DML grant is checked against the tables the statement writes, so a grant scoped to those tables is enough. SELECT ... FOR UPDATE and a plain EXPLAIN are not affected.Autocomplete

Run query
Click theRun button or use the shortcut key (⌘ + Enter) to run your queries in the SQL Editor.
If you have multiple SQL queries separated by semicolons, SQL Editor will only run the first query for now.
Oracle database links
A query that reads a table through a database link (schema.table@link) is authorized against the linked database before it runs, in SQL Editor, export, and MCP alike. It needs the same grant as querying that database directly, checked at the table level when the grant is table-scoped, and the linked database’s masking policy applies to the result.
Bytebase identifies the link’s target from the definition it synced from the instance, by matching the host, port, and service name in the link’s connect string to a data source of exactly one instance. A link that uses a TNS alias, or one added since the last sync, cannot be identified.
Max returned row count
SQL Editor can return at most 100,000 rows.
Max returned result size
The default query result size is 100 MB. You can change it under the Workspace settings.
Export data
Export re-runs your SQL statement against the database — it does not download the result set currently displayed in the tab. If the underlying data changed between the time you ran the query and the time you clicked Export, the exported rows will reflect the later state. To capture a specific point-in-time result set, copy the rows from the result panel or re-run the query immediately before exporting.The re-execution goes through the same row limit, data-source selection, and masking policy as the original query, so exported columns are masked if the policy is enforced.



EXPLAIN query
SQL Editor shows a statement’s query plan in two ways:- Before running it: open the menu next to Run and select Explain, or use the right-click menu or
⌘ + E. This shows the plan without running the statement. - After running it: switch the result from Table view to Plan. SQL Editor asks the database for a new plan of that statement and does not run it again, so the plan may differ from the one that ran. When a run has several statements, Plan is offered on the first result only. MongoDB and Elasticsearch results have no Plan view; use Explain instead.
bb.sql.explain on the database.

Esc or click Restore to bring the editor back.
Supported engines
MongoDB plans
find, aggregate, count, countDocuments, distinct, and estimatedDocumentCount only.
Type EXPLAIN yourself
TypingEXPLAIN and running it works too. Where SQL Editor recognizes the result as a plan, as on PostgreSQL and MySQL, it opens in the same viewer; otherwise it shows in the result grid. PostgreSQL’s EXPLAIN (FORMAT XML) and EXPLAIN (FORMAT YAML) show as text.
API
QueryOption.explain_format selects TEXT, JSON, XML, or YAML:
A format the engine cannot produce returns
INVALID_ARGUMENT, as does any explain request on Redis, DynamoDB, Cassandra, or Cosmos DB. A result that is a plan sets QueryResult.query_plan, with the plan’s format and whether producing it executed the statement.
Batch mode
You can batch query many databases having the same schema:


