How to create a database in SQL Server 2014 using the dBeaver GUI tool?
3 Answers
It isn't supported yet, as devs explain:
Database create not yet supported for SQL Server (will be added as a part of #810).
You can create database by commands like below:
--create where
USE master;
GO
--check if exists
IF DB_ID (N'MyDatabaseTest') IS NULL
DROP DATABASE MyOptionsTest;
GO
--create database
CREATE DATABASE MyDatabaseTest
COLLATE SQL_Latin1_General_CP1_CI_AS
WITH TRUSTWORTHY ON, DB_CHAINING ON;
GO
--Verifying collation and option settings.
SELECT name, collation_name, is_trustworthy_on, is_db_chaining_on
FROM sys.databases
WHERE name = N'MyOptionsTest';
GO
If you want to delete existing one, use below command:
IF DB_ID (N'MyDatabaseTest') IS NOT NULL
DROP DATABASE MyDatabaseTest;
Answer
Just to make this clear for anyone wondering how to create a database in DBeaver:
You cannot create a database in DBeaver.
This is already the answer to the question.
Beyond the answer
You can only connect to a database that is already there.
What is more, DBeaver does not install the database driver that you need to make the needed database when you make a new connection. DBeaver only installs the drivers for the DBeaver GUI (Graphical User Interface), that is what you see running at a cold start. You need to download and install the database driver yourself and set up a database yourself. Just make a new one in the console or in another GUI. Taking up the comment from above:
CREATE DATABASE YourDatabase
is the minimal code required.
And only then, you can connect to it:
With the host, port, database, username and password that depends on your settings outside of DBeaver.
I did this only for PostgreSQL, but it should be the same for SQL Server. Before I had installed PostgreSQL, DBeaver threw:
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Connection refused: connect
After installing PostgreSQL, DBeaver said that it did not know the databases, but the error was gone. After making the database with pgAdmin 4, I could see everything in DBeaver as well.
CREATE DATABASE YourDatabase
is the minimal code required.