Creating a Database (Creating Metadata)
Go Up to Creating Metadata
CREATE DATABASE establishes a new database and its associated system tables, which describe the internal structure of the database. SQL programs can select the data in most of these tables just as in any user-created table.
In its most elementary form, the syntax for
CREATE DATABASE is:
EXEC SQL CREATE DATABASE '<filespec>';
CREATE DATABASE must appear before any other
CREATE statements. It requires one parameter, the name of a database to create. For example, the following statement creates a database named
EXEC SQL CREATE DATABASE 'countries.ib';
There are optional parameters for
CREATE DATABASE. For example, when an application running on a client attempts to connect to an InterBase server in order to create a database, it may be expected to provide
PASSWORD parameters before the connection is established. Other parameters specify the database page size, the number and size of multi-file databases, and the default character set for the database.
Specifying a Default Character Set
A default character set designation of a database specifies the character set the server uses to transliterate and store
VARCHAR, and text Blob data in the database when no other character set information is provided. A default character set should always be specified for a database when it is created with
To specify a default character set, use the
DEFAULT CHARACTER SET clause of
CREATE DATABASE. For example, the following statement creates a database that uses the ISO8859_1 character set:
EXEC SQL CREATE DATABASE 'europe.ib' DEFAULT CHARACTER SET ISO8859_1;
If you do not specify a character set, the character set defaults to
NONE. Using character set
NONE means that there is no character set assumption for columns; data is stored and retrieved just as you originally entered it. You can load any character set into a column defined with
NONE, but you cannot later move that data into another column that has been defined with a different character set. In this case, no transliteration is performed between the source and destination character sets, and errors may occur during assignment.
For a complete description of the
DEFAULT CHARACTER SET clause and a list of the character sets supported by InterBase, see the Data Definition Guide.