FirebirdSQL logo

Who Can Create a Database

The CREATE DATABASE statement can be executed by:

Examples Using CREATE DATABASE

  1. Creating a database in Windows, located on disk D with a page size of 4,096.The owner of the database will be the user wizard.The database will be in Dialect 1, and will use WIN1251 as its default character set.

    SET SQL DIALECT 1;
    CREATE DATABASE 'D:\test.fdb'
    USER 'wizard' PASSWORD 'player'
    PAGE_SIZE = 4096 DEFAULT CHARACTER SET WIN1251;
  2. Creating a database in the Linux operating system with a page size of 8,192 (default).The owner of the database will be the user wizard.The database will be in Dialect 3 and will use UTF8 as its default character set, with UNICODE_CI_AI as the default collation.

    CREATE DATABASE '/home/firebird/test.fdb'
    USER 'wizard' PASSWORD 'player'
    DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;
  3. Creating a database on the remote server “baseserver” with the path specified in the alias “test” that has been defined previously in the file databases.conf.The TCP/IP protocol is used.The owner of the database will be the user wizard.The database will be in Dialect 3 and will use UTF8 as its default character set.

    CREATE DATABASE 'baseserver:test'
    USER 'wizard' PASSWORD 'player'
    DEFAULT CHARACTER SET UTF8;
  4. Creating a database in Dialect 3 with UTF8 as its default character set.The primary file will contain up to 10,000 pages with a page size of 8,192.As soon as the primary file has reached the maximum number of pages, Firebird will start allocating pages to the secondary file test.fdb2.If that file is filled up to its maximum as well, test.fdb3 becomes the recipient of all new page allocations.As the last file, it has no page limit imposed on it by Firebird.New allocations will continue for as long as the file system allows it or until the storage device runs out of free space.If a LENGTH parameter were supplied for this last file, it would be ignored.

    SET SQL DIALECT 3;
    CREATE DATABASE 'baseserver:D:\test.fdb'
    USER 'wizard' PASSWORD 'player'
    PAGE_SIZE = 8192
    DEFAULT CHARACTER SET UTF8
    FILE 'D:\test.fdb2'
    STARTING AT PAGE 10001
    FILE 'D:\test.fdb3'
    STARTING AT PAGE 20001;
  5. Creating a database in Dialect 3 with UTF8 as its default character set.The primary file will contain up to 10,000 pages with a page size of 8,192.As far as file size and the use of secondary files are concerned, this database will behave exactly like the one in the previous example.

    SET SQL DIALECT 3;
    CREATE DATABASE 'baseserver:D:\test.fdb'
    USER 'wizard' PASSWORD 'player'
    PAGE_SIZE = 8192
    LENGTH 10000 PAGES
    DEFAULT CHARACTER SET UTF8
    FILE 'D:\test.fdb2'
    FILE 'D:\test.fdb3'
    STARTING AT PAGE 20001;