6.3.2. The CREATE DATABASE statement

Now you can create your new database interactively. Let’s suppose that you want to create a database named test.fdb and store it in a directory named data on your D drive:

  1. SQL>create database 'D:\data\test.fdb' page_size 8192
  2. CON>user 'sysdba' password 'masterkey';
  • In the CREATE DATABASE statement it is mandatory to place quote characters (single or double) around path and password. This is different from the CONNECT statement. Quoting the user name is optional, unless it is case-sensitive or contains spaces, international characters or any other character that is not allowed in an unquoted identifier.

  • If the connection string doesn’t start with a host or protocol name, creation of the database file is attempted with your OS login as the owner. This may or may not be what you want (think of access rights if you want others to be able to connect). If you prepend localhost: or a protocol to the path or alias, the server process will create and own the file.

The database will be created and, after a few moments, the SQL prompt will reappear. You are now connected to the new database and can proceed to create some test objects in it.

But to verify that there really is a database there, let’s first type in this query:

  1. SQL>select * from rdb$relations;

Although you haven’t created any tables yet, the screen will fill up with a large amount of data! This query selects all of the rows in the system table RDB$RELATIONS, where Firebird stores the metadata for tables. An “empty” database is not really empty: it contains a number of system tables and other objects. The system tables will grow as you add more user objects to your database.

To get back to the command prompt type QUIT or EXIT, as explained in the section on connecting.