Difference between revisions of "CREATE DATABASE"
Helengeorge (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 8: | Line 8: | ||
==See Also== | ==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]], [[RESTORE DATABASE]], [[SET EXCLUSIVE]], [[SQL USE|USE]] | + | [[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]], [[SQL USE|USE]] |
Line 14: | Line 14: | ||
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. | ||
− | 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 | + | 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== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
+ | 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 | // cre_dat.sql | ||
CREATE DATABASE hr; | CREATE DATABASE hr; | ||
Line 37: | Line 52: | ||
==Products== | ==Products== | ||
− | Recital | + | Recital Server, Recital |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] |
Latest revision as of 10:20, 26 August 2011
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