CREATE DATABASE

From Recital Documentation Wiki
Revision as of 10:20, 26 August 2011 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Creates a database with the specified name


Syntax

CREATE DATABASE [IF NOT EXISTS] <database name>


See Also

ADATABASES(), ADD TABLE, ALTER INDEX, ALTER TABLE, BACKUP DATABASE, CLOSE DATABASES, CLOSE TABLES, COMPILE DATABASE, COPY DATABASE, CREATE TABLE, CREATE INDEX, CREATE VIEW, DATABASE(), DB_DATADIR, DBUSED(), DISPLAY DATABASE, DISPLAY INDEXES, DISPLAY SCHEMAS, DISPLAY TABLES, DROP DATABASE, DROP INDEX, DROP TABLE, GETENV(), LIST DATABASE, LIST INDEXES, LIST SCHEMAS, LIST TABLES, OPEN DATABASE, PACK DATABASE, REBUILD DATABASE, REINDEX DATABASE, REMOVE TABLE, RESTORE DATABASE, SET DATADIR, SET EXCLUSIVE, 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.

Databases in Recital are implemented as directories containing files that correspond to the tables and associated files in the database. Operating System file protection can be applied individually to the files for added security. Since there are no tables in a database when it is initially created, the CREATE DATABASE statement creates an empty directory. The directory is created as a sub-directory of the Recital data directory. The environment variable DB_DATADIR points to the current Recital data directory and can be queried using the GETENV() function. Files from other directories can be added to the database using the ADD TABLE command or via the database catalog and SET AUTOCATALOG functionality.


Example

CREATE DATABASE hr
OPEN 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))
 
// MySQL Compatible example
// cre_dat.sql
CREATE DATABASE hr;
USE 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));


Products

Recital Server, Recital