CREATE DATABASE

From Lianjapedia
Jump to: navigation, search

Purpose

Creates a database with the specified name

Syntax

CREATE DATABASE [IF NOT EXISTS] <database name>

[METADATA <expC>]

See Also

ADATABASES(), ADD TABLE, ALTER INDEX, ALTER TABLE, CLOSE DATABASES, CLOSE TABLES, COLUMNMETADATA(), COMPILE DATABASE, COPY DATABASE, CREATE TABLE, CREATE INDEX, CREATE VIEW, DATABASE(), DATABASEMETADATA(), DBUSED(), DISPLAY DATABASE, DISPLAY INDEXES, DISPLAY SCHEMAS, DISPLAY TABLES, DROP DATABASE, DROP INDEX, DROP TABLE, GETENV(), LIST DATABASE, LIST INDEXES, LIST SCHEMAS, LIST TABLES, METADATA_DECODE(), METADATA_ENCODE(), METADATA_FINDTYPE(), OPEN DATABASE, PACK DATABASE, REBUILD DATABASE, REINDEX DATABASE, REMOVE TABLE, SET DATADIR, SET EXCLUSIVE, TABLEMETADATA(), TABLEMETADATAVERSION(), USE

Description

The CREATE DATABASE command creates a new database with the specified name. An error occurs if the database already exists unless the IF NOT EXISTS clause is specified.

The METADATA <expC> clause is used to associate metadata with the database. Database metadata is stored in the <database-basename>.cad file in the database's directory.

See Lianja MetaData API for more information on creating and using MetaData.

After creation, the database will be open.

Example

CREATE DATABASE hr
CREATE TABLE staff;
  (staff_no CHAR(6) NOT NULL UNIQUE,;
  lastname CHAR(15) NOT NULL,;
  firstname CHAR(10),;
  hiredate DATE,;
  location CHAR(15),;
  supervisor CHAR(6),;
  salary DECIMAL(6,0),;
  picture VARBINARY,;
  history LONG VARCHAR,;
  commission DECIMAL(4,1))