mirror of
https://github.com/chaisql/chai.git
synced 2025-09-26 19:51:21 +08:00
37 lines
1005 B
SQL
37 lines
1005 B
SQL
-- test: basic
|
|
CREATE TABLE test(a int primary key);
|
|
SELECT name, sql FROM __chai_catalog WHERE type = 'table' AND name = 'test';
|
|
/* result:
|
|
{
|
|
"name": 'test',
|
|
"sql": 'CREATE TABLE test (a INTEGER NOT NULL, CONSTRAINT test_pk PRIMARY KEY (a))'
|
|
}
|
|
*/
|
|
|
|
-- test: duplicate
|
|
CREATE TABLE test(a int primary key);
|
|
CREATE TABLE test(a int primary key);
|
|
-- error:
|
|
|
|
-- test: if not exists
|
|
CREATE TABLE test(a int primary key);
|
|
CREATE TABLE IF NOT EXISTS test(b int primary key);
|
|
SELECT name, sql FROM __chai_catalog WHERE type = 'table' AND name = 'test';
|
|
/* result:
|
|
{
|
|
"name": 'test',
|
|
"sql": 'CREATE TABLE test (a INTEGER NOT NULL, CONSTRAINT test_pk PRIMARY KEY (a))'
|
|
}
|
|
*/
|
|
|
|
-- test: if not exists, twice
|
|
CREATE TABLE IF NOT EXISTS test(a int primary key);
|
|
CREATE TABLE IF NOT EXISTS test(a int primary key);
|
|
SELECT name, sql FROM __chai_catalog WHERE type = 'table' AND name = 'test';
|
|
/* result:
|
|
{
|
|
"name": 'test',
|
|
"sql": 'CREATE TABLE test (a INTEGER NOT NULL, CONSTRAINT test_pk PRIMARY KEY (a))'
|
|
}
|
|
*/
|