Firebird Documentation Index → Firebird 3.0 Developer's Guide → The examples.fdb Database → Database Creation Script |
Table of Contents
The tool used here to create the database from a script is isql, that is installed with all the other executables in every Firebird server installation. You could use any other administration tool for Firebird, such as FlameRobin, SQLLY Studio, IBExpert or others.
We will assume that you are working in Windows. Obviously, the formats of path names will differ on other file systems (Linux, Apple Mac, etc.) but the isql tool works the same on all platforms.
Run isql and enter the following script after the
SQL>
prompt appears :
CREATE DATABASE 'localhost:D:\fbdata\2.5\examples.fdb' USER 'SYSDBA' PASSWORD 'masterkey' PAGE_SIZE 8192 DEFAULT CHARACTER SET UTF8;
The straight single quotes around the user and password arguments are not optional in Firebird 2.5 and lower versions because, in the CREATE DATABASE syntax, both are strings.
In Firebird 3, the rules changed. User names became identifiers and no longer require single quotes. They can be made case-sensitive by enclosing the name in DOUBLE quotes, so you need to be aware of how that user is registered in the security database. Passwords are still strings.
Quotes in the statement are not interchangeable with curly quotes, angle quotes or any other kind of quotes.
The user whose name and password are cited in the CREATE DATABASE statement becomes the owner of the database and has full access to all metadata objects. It is not essential that SYSDBA be the owner of a database. Any user can be the owner, which has the same access as SYSDBA in this database.
The actively supported versions of Firebird support the following page sizes: 4096, 8192 and 16384. The page size of 8192 is good for most cases.
The optional DEFAULT CHARACTER SET clause specifies the default character set for string data types. Character sets are applied to the CHAR, VARCHAR and BLOB TEXT data types. You can study the list of available language encodings in an Appendix to the Firebird Language Reference manual. All up-to-date programming languages support UTF8 so we choose this encoding.
Now we can exit the isql session by typing the following command:
EXIT;
Databases are accessed locally and remotely by their physical file path on the server. Before you start to use a database, it is useful and wise to register an alias for its file path and to use the alias for all connections. It saves typing and, to some degree, it offers a little extra security from snoopers by obscuring the physical location of your database file in the connection string.
In Firebird 2.5, the alias of a database is registered in the aliases.conf
file as follows:
examples = D:\fbdata\2.5\examples.fdb
In Firebird 3.0, the alias of a database is registered in the databases.conf
file. Along with the alias for the database, some database-level parameters can be configured
there: page cache size, the size of RAM for sorting and several others, e.g.,
examples = D:\fbdata\3.0\examples.fdb { DefaultDbCachePages = 16K TempCacheLimit = 512M }
You can use an alias even before the database exists. It is valid to substitute the full file path with the alias in the CREATE DATABASE statement.
Firebird Documentation Index → Firebird 3.0 Developer's Guide → The examples.fdb Database → Database Creation Script |