Reputation: 11603
I'm using DBeaver with PostgreSQL. I can open a new SQL editor with Ctl+[
But I have multiple databases in my PostgreSQL. How can I have the SQL editor run against another database?
The following doesn't work:
use <db name>;
select * from <table name>;
Upvotes: 27
Views: 38210
Reputation: 1
In the SQL Editor window, click on the database name at the top (or Ctrl+0, that's Ctrl+zero) to open the "Choose catalog/schema" dialog. Select the database (catalog) in the left pane by clicking on it, then select the schema in the right pane by double-clicking on it, which also closes the dialog. Click on the following images to see screenshots.
Open "Choose catalog/schema" dialog
Upvotes: 0
Reputation: 45
I'm connected to a MariaDB database, and the Set Active option does not show when right-clicking a "schema" (often confusingly referred to as a "database" like the "database server" is called a "database"), however, selecting "Set as default" will set it as active in an overkill way.
However, selecting "SQL Editor" then one of the options there will give you the "schema" context, as if you had selected to use that database to run queries (without needing to specify the containing schema/database).
Sorry for all the terminology ambiguity, it was not my creation.
Upvotes: 0
Reputation: 31
I've found the solution. Press Ctrl+9 and choose your destiny-base...
Upvotes: 3
Reputation: 945
You can set a different database as active in your current connection by right-clicking in the Database Navigator pane and selecting "Set active", below I am switching from 'postgres' to my 'report_service' DB (this is version 6.1.2, not sure about other versions)
EDIT: I have recently upgraded to version 6.3.5 and this now has "Set as default" in the dropdown rather than "Set active" but this seems to be roughly the same behaviour
Upvotes: 26
Reputation: 11603
You can change the currently selected database when you create new sql tabs by selecting it from the dropdown.
When you do so be sure to double-click on the schema you want to bring into focus. Then you can open new sql editors with ctrl+]
.
Upvotes: 22