-
-
Notifications
You must be signed in to change notification settings - Fork 2
CREATE DATABASE
Oxford Harrison edited this page Nov 11, 2024
·
15 revisions
Create empty database:
// (a): SQL syntax
const savepoint = await client.query(
`CREATE SCHEMA database_1`,
{ desc: 'Create description' }
);
// (b): Function-based syntax
const savepoint = await client.createDatabase(
`database_1`,
{ desc: 'Create description' }
);
Note that while the function-based syntax may read "create database", the "schema" type is implied by default.
Create conditionally:
// (a): SQL syntax
const savepoint = await client.query(
`CREATE SCHEMA IF NOT EXISTS database_1`,
{ desc: 'Create description' }
);
// (b): Function-based syntax
const savepoint = await client.createDatabase(
`database_1`,
{ desc: 'Create description', ifNotExists: true }
);
Create with tables:
// Function-based syntax
const savepoint = await client.createDatabase({
name: 'database_1',
tables: [{
name: 'table_1',
columns: []
}, {
name: 'table_2',
columns: []
}]
}, { desc: 'Create description' });