Difference between revisions of "CREATE DATABASE"
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
CREATE DATABASE [IF NOT EXISTS] <database name> | CREATE DATABASE [IF NOT EXISTS] <database name> | ||
+ | |||
+ | [METADATA <JSON>] | ||
==See Also== | ==See Also== | ||
Line 10: | Line 12: | ||
==Description== | ==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 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 <JSON> clause is used to associate metadata with the database. The <JSON> is a JSON encoded character string. | ||
==Example== | ==Example== |
Revision as of 06:51, 18 February 2016
Contents
Purpose
Creates a database with the specified name
Syntax
CREATE DATABASE [IF NOT EXISTS] <database name>
[METADATA <JSON>]
See Also
ADATABASES(), ADD TABLE, ALTER INDEX, ALTER TABLE, CLOSE DATABASES, CLOSE TABLES, COMPILE DATABASE, COPY DATABASE, CREATE TABLE, CREATE INDEX, CREATE VIEW, DATABASE(), 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, 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.
The METADATA <JSON> clause is used to associate metadata with the database. The <JSON> is a JSON encoded character string.
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));