Section 11 in Foundation This module covers the tests for parsing schema and DDL statements. > module Language.SQL.SimpleSQL.SQL2011Schema (sql2011SchemaTests) where > import Language.SQL.SimpleSQL.TestTypes > import Language.SQL.SimpleSQL.Syntax > sql2011SchemaTests :: TestItem > sql2011SchemaTests = Group "sql 2011 schema tests" > [ 11.1 ::= CREATE SCHEMA [ ] [ ... ] > (TestStatement ansi2011 "create schema my_schema" > $ CreateSchema [Name Nothing "my_schema"]) todo: schema name can have . schema name can be quoted iden or unicode quoted iden add schema element support: create a list of schema elements then do pairwise combinations in schema element list to test ::= | | | ::= | AUTHORIZATION | AUTHORIZATION ::= ::= DEFAULT CHARACTER SET ::= ::= | | | | | | | | | | | | | | | 11.2 ::= DROP SCHEMA ::= CASCADE | RESTRICT > ,(TestStatement ansi2011 "drop schema my_schema" > $ DropSchema [Name Nothing "my_schema"] DefaultDropBehaviour) > ,(TestStatement ansi2011 "drop schema my_schema cascade" > $ DropSchema [Name Nothing "my_schema"] Cascade) > ,(TestStatement ansi2011 "drop schema my_schema restrict" > $ DropSchema [Name Nothing "my_schema"] Restrict) 11.3
::= CREATE [
] TABLE
[ WITH ] [ ON COMMIT
ROWS ] > ,(TestStatement ansi2011 "create table t (a int, b int);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name Nothing "b") (TypeName [Name Nothing "int"]) Nothing []])
::=
| |
::= TEMPORARY ::= GLOBAL | LOCAL ::= SYSTEM VERSIONING defintely skip
::= PRESERVE | DELETE defintely skip
::=
[ {
}... ]
::= |
|
| ::= OF [ ] [ ] defintely skip ::= [ { }... ] defintely skip ::= |
| defintely skip ::= REF IS [ ] defintely skip ::= SYSTEM GENERATED | USER GENERATED | DERIVED defintely skip ::= defintely skip ::= WITH OPTIONS defintely skip ::= [ ] [ ] [ ... ] defintely skip ::= UNDER defintely skip ::= defintely skip ::=
defintely skip ::= LIKE
[ ] ::= ... ::= | | ::= INCLUDING IDENTITY | EXCLUDING IDENTITY ::= INCLUDING DEFAULTS | EXCLUDING DEFAULTS ::= INCLUDING GENERATED | EXCLUDING GENERATED ::= [ ] AS
::= WITH NO DATA | WITH DATA
::= defintely skip ::= | defintely skip ::= PERIOD FOR SYSTEM_TIME defintely skip ::= PERIOD FOR defintely skip ::= defintely skip ::= defintely skip ::= defintely skip 11.4 ::= [ ] [ | | | | ] [ ... ] [ ] ::= | ::= AS ROW START defintely skip ::= AS ROW END defintely skip ::= GENERATED ALWAYS defintely skip ::= [ ] [ ] ::= NOT NULL | | | can have more than one whitespace separated one constratint: optional name: constraint [Name] not null | unique | references | check todo: constraint characteristics > ,(TestStatement ansi2011 > "create table t (a int not null);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing ColNotNullConstraint]]) > ,(TestStatement ansi2011 > "create table t (a int constraint a_not_null not null);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef (Just [Name Nothing "a_not_null"]) ColNotNullConstraint]]) > ,(TestStatement ansi2011 > "create table t (a int unique);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing ColUniqueConstraint]]) > ,(TestStatement ansi2011 > "create table t (a int primary key);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing ColPrimaryKeyConstraint]]) references t(a,b) [ Full |partial| simepl] [perm: on update [cascade | set null | set default | restrict | no action] on delete "" > ,(TestStatement ansi2011 > "create table t (a int references u);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u(a));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] (Just $ Name Nothing "a") DefaultReferenceMatch > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u match full);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing MatchFull > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u match partial);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing MatchPartial > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u match simple);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing MatchSimple > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u on update cascade );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > RefCascade DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u on update set null );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > RefSetNull DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u on update set default );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > RefSetDefault DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u on update no action );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > RefNoAction DefaultReferentialAction]]) > ,(TestStatement ansi2011 > "create table t (a int references u on delete cascade );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > DefaultReferentialAction RefCascade]]) > ,(TestStatement ansi2011 > "create table t (a int references u on update cascade on delete restrict );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > RefCascade RefRestrict]]) > ,(TestStatement ansi2011 > "create table t (a int references u on delete restrict on update cascade );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name Nothing "u"] Nothing DefaultReferenceMatch > RefCascade RefRestrict]]) TODO: try combinations and permutations of column constraints and options > ,(TestStatement ansi2011 > "create table t (a int check (a>5));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing > [ColConstraintDef Nothing > (ColCheckConstraint $ BinOp (Iden [Name Nothing "a"]) [Name Nothing ">"] (NumLit "5"))]]) ::= GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ] > ,(TestStatement ansi2011 "create table t (a int generated always as identity);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) > (Just $ IdentityColumnSpec GeneratedAlways []) []]) > ,(TestStatement ansi2011 "create table t (a int generated by default as identity);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) > (Just $ IdentityColumnSpec GeneratedByDefault []) []]) > ,(TestStatement ansi2011 > "create table t (a int generated always as identity\n\ > \ ( start with 5 increment by 5 maxvalue 500 minvalue 5 cycle ));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) > (Just $ IdentityColumnSpec GeneratedAlways > [SGOStartWith 5 > ,SGOIncrementBy 5 > ,SGOMaxValue 500 > ,SGOMinValue 5 > ,SGOCycle]) []]) > ,(TestStatement ansi2011 > "create table t (a int generated always as identity\n\ > \ ( start with -4 no maxvalue no minvalue no cycle ));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) > (Just $ IdentityColumnSpec GeneratedAlways > [SGOStartWith (-4) > ,SGONoMaxValue > ,SGONoMinValue > ,SGONoCycle]) []]) I think is supposed to just whitespace separated. In db2 it seems to be csv, but the grammar here just seems to be whitespace separated, and it is just whitespace separated in oracle... Not completely sure though. Usually db2 is closer than oracle? generated always (valueexpr) ::= AS ::= GENERATED ALWAYS ::= > ,(TestStatement ansi2011 > "create table t (a int, \n\ > \ a2 int generated always as (a * 2));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name Nothing "a2") (TypeName [Name Nothing "int"]) > (Just $ GenerationClause > (BinOp (Iden [Name Nothing "a"]) [Name Nothing "*"] (NumLit "2"))) []]) 11.5 ::= DEFAULT ::= | | USER | CURRENT_USER | CURRENT_ROLE | SESSION_USER | SYSTEM_USER | CURRENT_CATALOG | CURRENT_SCHEMA | CURRENT_PATH | > ,(TestStatement ansi2011 "create table t (a int default 0);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) > (Just $ DefaultClause $ NumLit "0") []]) 11.6
::= [ ]
[ ]
::= | | 11.7 ::= [ ] | UNIQUE ( VALUE ) ::= UNIQUE | PRIMARY KEY ::= > ,(TestStatement ansi2011 > "create table t (a int, unique (a));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef Nothing $ TableUniqueConstraint [Name Nothing "a"] > ]) > ,(TestStatement ansi2011 > "create table t (a int, constraint a_unique unique (a));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef (Just [Name Nothing "a_unique"]) $ > TableUniqueConstraint [Name Nothing "a"] > ]) todo: test permutations of column defs and table constraints > ,(TestStatement ansi2011 > "create table t (a int, b int, unique (a,b));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name Nothing "b") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TableUniqueConstraint [Name Nothing "a", Name Nothing "b"] > ]) > ,(TestStatement ansi2011 > "create table t (a int, b int, primary key (a,b));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name Nothing "b") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TablePrimaryKeyConstraint [Name Nothing "a", Name Nothing "b"] > ]) ::= WITHOUT OVERLAPS defintely skip 11.8 ::= FOREIGN KEY [ ] > ,(TestStatement ansi2011 > "create table t (a int, b int,\n\ > \ foreign key (a,b) references u(c,d) match full on update cascade on delete restrict );" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name Nothing "b") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TableReferencesConstraint > [Name Nothing "a", Name Nothing "b"] > [Name Nothing "u"] > (Just [Name Nothing "c", Name Nothing "d"]) > MatchFull RefCascade RefRestrict > ]) > ,(TestStatement ansi2011 > "create table t (a int,\n\ > \ constraint tfku1 foreign key (a) references u);" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef (Just [Name Nothing "tfku1"]) $ > TableReferencesConstraint > [Name Nothing "a"] > [Name Nothing "u"] > Nothing DefaultReferenceMatch > DefaultReferentialAction DefaultReferentialAction > ]) ::= REFERENCES [ MATCH ] [ ] ::= FULL | PARTIAL | SIMPLE ::= ::= PERIOD defintely skip ::=
[ [ ] ] ::= ::= PERIOD defintely skip ::= [ ] | [ ] ::= ON UPDATE ::= ON DELETE ::= CASCADE | SET NULL | SET DEFAULT | RESTRICT | NO ACTION 11.9 ::= CHECK > ,(TestStatement ansi2011 > "create table t (a int, b int, \n\ > \ check (a > b));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name Nothing "b") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TableCheckConstraint > (BinOp (Iden [Name Nothing "a"]) [Name Nothing ">"] (Iden [Name Nothing "b"])) > ]) > ,(TestStatement ansi2011 > "create table t (a int, b int, \n\ > \ constraint agtb check (a > b));" > $ CreateTable [Name Nothing "t"] > [TableColumnDef $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name Nothing "b") (TypeName [Name Nothing "int"]) Nothing [] > ,TableConstraintDef (Just [Name Nothing "agtb"]) $ > TableCheckConstraint > (BinOp (Iden [Name Nothing "a"]) [Name Nothing ">"] (Iden [Name Nothing "b"])) > ]) TODO: lots more combos of table elements and types and the other bits in a column def 11.10 ::= ALTER TABLE
::= | | | | | | | | | 11.11 ::= ADD [ COLUMN ] alter table t add column a int alter table t add a int alter table t add a int unique not null check (a>0) > ,(TestStatement ansi2011 > "alter table t add column a int" > $ AlterTable [Name Nothing "t"] $ AddColumnDef > $ ColumnDef (Name Nothing "a") (TypeName [Name Nothing "int"]) Nothing [] > ) todo: more add column 11.12 ::= ALTER [ COLUMN ] ::= | | | | | | | | | 11.13 ::= SET > ,(TestStatement ansi2011 > "alter table t alter column c set default 0" > $ AlterTable [Name Nothing "t"] $ AlterColumnSetDefault (Name Nothing "c") > $ NumLit "0") 11.14 ::= DROP DEFAULT > ,(TestStatement ansi2011 > "alter table t alter column c drop default" > $ AlterTable [Name Nothing "t"] $ AlterColumnDropDefault (Name Nothing "c")) 11.15 ::= SET NOT NULL > ,(TestStatement ansi2011 > "alter table t alter column c set not null" > $ AlterTable [Name Nothing "t"] $ AlterColumnSetNotNull (Name Nothing "c")) 11.16 ::= DROP NOT NULL > ,(TestStatement ansi2011 > "alter table t alter column c drop not null" > $ AlterTable [Name Nothing "t"] $ AlterColumnDropNotNull (Name Nothing "c")) 11.17 ::= ADD 11.18 ::= DROP SCOPE 11.19 ::= SET DATA TYPE > ,(TestStatement ansi2011 > "alter table t alter column c set data type int;" > $ AlterTable [Name Nothing "t"] $ > AlterColumnSetDataType (Name Nothing "c") (TypeName [Name Nothing "int"])) 11.20 ::= [ ... ] | ... ::= SET GENERATED { ALWAYS | BY DEFAULT } so you have to write set generated for alter identity? and you have to use always or by default makes no sense: if you just want to restart you have to explicitly set the always or by default? you can't just leave it unchanged? you don't write as identity like with create table, this is wrong: alter table t alter column c set generated always as identity but these are ok? alter table t alter column c set generated always alter table t alter column c set generated by default ::= | SET alter table t alter column c set generated always restart alter table t alter column c set generated always restart with 4 you can just write restart but to write others you have to repeat set? each time? alter table t alter column c set generated always set increment by 5 set minvalue 0 set maxvalue 5 set cycle restart with 5 (no set before the restart in create table, it looks like this: c int generated generated always as identity (increment by 5 minvalue 0 maxvalue 5 cycle restart with 5) why gratuituous differences??? is there no way to do this: alter table t alter column c set generated as (a * 3) ?? UPDATE: alter sequence uses same syntax as create sequence, which is the same sytnax as identity in create table, so overrule the sql standard and use the same syntax in alter identity. PLAN: TODO don't implement alter table alter column generated now review the syntax for generated in db2, oracle, sql server, postgres, others? observe which features are supported, and the consistency between create table and alter table try to find some people to ask if the standard really is this much of a mess or I have misunderstood the grammer, or maybe there is a good reason for the inconsistencies? 11.21 ::= DROP IDENTITY alter table t alter column c drop identity included in the generated plan above 11.22 ::= DROP EXPRESSION alter table t alter column c drop expression included in the generated plan above 11.23 ::= DROP [ COLUMN ] > ,(TestStatement ansi2011 > "alter table t drop column c" > $ AlterTable [Name Nothing "t"] $ > DropColumn (Name Nothing "c") DefaultDropBehaviour) > ,(TestStatement ansi2011 > "alter table t drop c cascade" > $ AlterTable [Name Nothing "t"] $ > DropColumn (Name Nothing "c") Cascade) > ,(TestStatement ansi2011 > "alter table t drop c restrict" > $ AlterTable [Name Nothing "t"] $ > DropColumn (Name Nothing "c") Restrict) 11.24 ::= ADD
> ,(TestStatement ansi2011 > "alter table t add constraint c unique (a,b)" > $ AlterTable [Name Nothing "t"] $ > AddTableConstraintDef (Just [Name Nothing "c"]) > $ TableUniqueConstraint [Name Nothing "a", Name Nothing "b"]) > ,(TestStatement ansi2011 > "alter table t add unique (a,b)" > $ AlterTable [Name Nothing "t"] $ > AddTableConstraintDef Nothing > $ TableUniqueConstraint [Name Nothing "a", Name Nothing "b"]) 11.25 ::= ALTER CONSTRAINT todo 11.26 ::= DROP CONSTRAINT > ,(TestStatement ansi2011 > "alter table t drop constraint c" > $ AlterTable [Name Nothing "t"] $ > DropTableConstraintDef [Name Nothing "c"] DefaultDropBehaviour) > ,(TestStatement ansi2011 > "alter table t drop constraint c restrict" > $ AlterTable [Name Nothing "t"] $ > DropTableConstraintDef [Name Nothing "c"] Restrict) 11.27 ::= ADD
[ ] defintely skip ::= ADD [ COLUMN ] ADD [ COLUMN ] defintely skip ::= defintely skip ::= defintely skip 11.28 ::= DROP defintely skip 11.29 ::= ADD defintely skip 11.30 ::= DROP SYSTEM VERSIONING defintely skip 11.31 ::= DROP TABLE
> ,(TestStatement ansi2011 > "drop table t" > $ DropTable [Name Nothing "t"] DefaultDropBehaviour) > ,(TestStatement ansi2011 > "drop table t restrict" > $ DropTable [Name Nothing "t"] Restrict) 11.32 ::= CREATE [ RECURSIVE ] VIEW
AS [ WITH [ ] CHECK OPTION ] ::= | ::= [ ] ::= OF [ ] [ ] ::= UNDER
::= [ { }... ] ::= | ::= WITH OPTIONS ::= CASCADED | LOCAL ::= > ,(TestStatement ansi2011 > "create view v as select * from t" > $ CreateView False [Name Nothing "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name Nothing "t"]] > }) Nothing) > ,(TestStatement ansi2011 > "create recursive view v as select * from t" > $ CreateView True [Name Nothing "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name Nothing "t"]] > }) Nothing) > ,(TestStatement ansi2011 > "create view v(a,b) as select * from t" > $ CreateView False [Name Nothing "v"] (Just [Name Nothing "a", Name Nothing "b"]) > (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name Nothing "t"]] > }) Nothing) > ,(TestStatement ansi2011 > "create view v as select * from t with check option" > $ CreateView False [Name Nothing "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name Nothing "t"]] > }) (Just DefaultCheckOption)) > ,(TestStatement ansi2011 > "create view v as select * from t with cascaded check option" > $ CreateView False [Name Nothing "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name Nothing "t"]] > }) (Just CascadedCheckOption)) > ,(TestStatement ansi2011 > "create view v as select * from t with local check option" > $ CreateView False [Name Nothing "v"] Nothing > (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name Nothing "t"]] > }) (Just LocalCheckOption)) 11.33 ::= DROP VIEW
> ,(TestStatement ansi2011 > "drop view v" > $ DropView [Name Nothing "v"] DefaultDropBehaviour) > ,(TestStatement ansi2011 > "drop view v cascade" > $ DropView [Name Nothing "v"] Cascade) 11.34 ::= CREATE DOMAIN [ AS ] [ ] [ ... ] [ ] ::= [ ] [ ] > ,(TestStatement ansi2011 > "create domain my_int int" > $ CreateDomain [Name Nothing "my_int"] > (TypeName [Name Nothing "int"]) > Nothing []) > ,(TestStatement ansi2011 > "create domain my_int as int" > $ CreateDomain [Name Nothing "my_int"] > (TypeName [Name Nothing "int"]) > Nothing []) > ,(TestStatement ansi2011 > "create domain my_int int default 0" > $ CreateDomain [Name Nothing "my_int"] > (TypeName [Name Nothing "int"]) > (Just (NumLit "0")) []) > ,(TestStatement ansi2011 > "create domain my_int int check (value > 5)" > $ CreateDomain [Name Nothing "my_int"] > (TypeName [Name Nothing "int"]) > Nothing [(Nothing > ,BinOp (Iden [Name Nothing "value"]) [Name Nothing ">"] (NumLit "5"))]) > ,(TestStatement ansi2011 > "create domain my_int int constraint gt5 check (value > 5)" > $ CreateDomain [Name Nothing "my_int"] > (TypeName [Name Nothing "int"]) > Nothing [(Just [Name Nothing "gt5"] > ,BinOp (Iden [Name Nothing "value"]) [Name Nothing ">"] (NumLit "5"))]) 11.35 ::= ALTER DOMAIN ::= | | | 11.36 ::= SET > ,(TestStatement ansi2011 > "alter domain my_int set default 0" > $ AlterDomain [Name Nothing "my_int"] > $ ADSetDefault $ NumLit "0") 11.37 ::= DROP DEFAULT > ,(TestStatement ansi2011 > "alter domain my_int drop default" > $ AlterDomain [Name Nothing "my_int"] > $ ADDropDefault) 11.38 ::= ADD > ,(TestStatement ansi2011 > "alter domain my_int add check (value > 6)" > $ AlterDomain [Name Nothing "my_int"] > $ ADAddConstraint Nothing > $ BinOp (Iden [Name Nothing "value"]) [Name Nothing ">"] (NumLit "6")) > ,(TestStatement ansi2011 > "alter domain my_int add constraint gt6 check (value > 6)" > $ AlterDomain [Name Nothing "my_int"] > $ ADAddConstraint (Just [Name Nothing "gt6"]) > $ BinOp (Iden [Name Nothing "value"]) [Name Nothing ">"] (NumLit "6")) 11.39 ::= DROP CONSTRAINT > ,(TestStatement ansi2011 > "alter domain my_int drop constraint gt6" > $ AlterDomain [Name Nothing "my_int"] > $ ADDropConstraint [Name Nothing "gt6"]) 11.40 ::= DROP DOMAIN > ,(TestStatement ansi2011 > "drop domain my_int" > $ DropDomain [Name Nothing "my_int"] DefaultDropBehaviour) > ,(TestStatement ansi2011 > "drop domain my_int cascade" > $ DropDomain [Name Nothing "my_int"] Cascade) 11.41 ::= CREATE CHARACTER SET [ AS ] [ ] ::= GET 11.42 ::= DROP CHARACTER SET 11.43 ::= CREATE COLLATION FOR FROM [ ] ::= ::= NO PAD | PAD SPACE 11.44 ::= DROP COLLATION 11.45 ::= CREATE TRANSLATION FOR TO FROM ::= ::= ::= | ::= ::= 11.46 ::= DROP TRANSLATION 11.47 ::= CREATE ASSERTION CHECK [ ] > ,(TestStatement ansi2011 > "create assertion t1_not_empty CHECK ((select count(*) from t1) > 0);" > $ CreateAssertion [Name Nothing "t1_not_empty"] > $ BinOp (SubQueryExpr SqSq $ > makeSelect > {qeSelectList = [(App [Name Nothing "count"] [Star],Nothing)] > ,qeFrom = [TRSimple [Name Nothing "t1"]] > }) > [Name Nothing ">"] (NumLit "0")) 11.48 ::= DROP ASSERTION [ ] > ,(TestStatement ansi2011 > "drop assertion t1_not_empty;" > $ DropAssertion [Name Nothing "t1_not_empty"] DefaultDropBehaviour) > ,(TestStatement ansi2011 > "drop assertion t1_not_empty cascade;" > $ DropAssertion [Name Nothing "t1_not_empty"] Cascade) 11.49 ::= CREATE TRIGGER ON
[ REFERENCING ] ::= BEFORE | AFTER | INSTEAD OF ::= INSERT | DELETE | UPDATE [ OF ] ::= ::= [ FOR EACH { ROW | STATEMENT } ] [ ] ::= WHEN ::= | BEGIN ATOMIC { }... END ::= ... ::= OLD [ ROW ] [ AS ] | NEW [ ROW ] [ AS ] | OLD TABLE [ AS ] | NEW TABLE [ AS ] ::= ::= ::= ::= ::= 11.50 ::= DROP TRIGGER 11.51 ::= CREATE TYPE ::= [ ] [ AS ] [ ] [ ] ::= [ ... ] ::= | | | | | | ::= UNDER ::= ::= | | ::= [ { }... ] ::= ::= INSTANTIABLE | NOT INSTANTIABLE ::= FINAL | NOT FINAL ::= | | ::= REF USING ::= REF FROM ::= REF IS SYSTEM GENERATED ::= CAST SOURCE AS REF WITH ::= ::= CAST REF AS SOURCE WITH ::= ::= [ { }... ] ::= CAST SOURCE AS DISTINCT WITH ::= ::= CAST DISTINCT AS SOURCE WITH ::= ::= [ { }... ] ::= | ::= [ SELF AS RESULT ] [ SELF AS LOCATOR ] [ ] ::= OVERRIDING 1 ::= [ INSTANCE | STATIC | CONSTRUCTOR ] METHOD [ SPECIFIC ] ::= [ ] ::= ... ::= | | | | 11.52 ::= [ ] [ ] ::= 11.53 ::= ALTER TYPE ::= | | | | 11.54 ::= ADD ATTRIBUTE 11.55 ::= DROP ATTRIBUTE RESTRICT 11.56 ::= ADD 11.57 ::= ADD 11.58 ::= DROP RESTRICT ::= [ INSTANCE | STATIC | CONSTRUCTOR ] METHOD 11.59 ::= DROP TYPE 11.60 ::= ::= | ::= CREATE ::= CREATE ::= PROCEDURE ::= { | } ::= [ [ { }... ] ] ::= [ ] [ ] [ RESULT ] [ DEFAULT ] ::= | ::= IN | OUT | INOUT ::= [ ] ::= AS LOCATOR ::= FUNCTION [ ] ::= SPECIFIC METHOD | [ INSTANCE | STATIC | CONSTRUCTOR ] METHOD [ ] FOR ::= [ ... ] ::= | | SPECIFIC | | | | | ::= NEW SAVEPOINT LEVEL | OLD SAVEPOINT LEVEL ::= DYNAMIC RESULT SETS ::= PARAMETER STYLE ::= STATIC DISPATCH ::= RETURNS ::= [ ] | ::= TABLE
::=
[ {
}... ]
::= ::= CAST FROM ::= [ ] ::= [ ] ::= | ::= [ ] ::= SQL SECURITY INVOKER | SQL SECURITY DEFINER ::= ::= EXTERNAL [ NAME ] [ ] [ ] [ ] ::= EXTERNAL SECURITY DEFINER | EXTERNAL SECURITY INVOKER | EXTERNAL SECURITY IMPLEMENTATION DEFINED ::= SQL | GENERAL ::= DETERMINISTIC | NOT DETERMINISTIC ::= NO SQL | CONTAINS SQL | READS SQL DATA | MODIFIES SQL DATA ::= RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT ::= ::= TRANSFORM GROUP { | } ::= ::= [ { }... ] ::= FOR TYPE 11.61 ::= ALTER ::= ... ::= | | | | | NAME ::= RESTRICT 11.62 ::= DROP 11.63 ::= CREATE CAST AS WITH [ AS ASSIGNMENT ] ::= ::= ::= 11.64 ::= DROP CAST AS 11.65 ::= CREATE ORDERING FOR ::= | ::= EQUALS ONLY BY ::= ORDER FULL BY ::= | | ::= RELATIVE WITH ::= MAP WITH ::= STATE [ ] ::= ::= 11.66 ::= DROP ORDERING FOR 11.67 ::= CREATE { TRANSFORM | TRANSFORMS } FOR ... ::= ::= ::= [ ] ::= | ::= TO SQL WITH ::= FROM SQL WITH ::= ::= 11.68 ::= ALTER { TRANSFORM | TRANSFORMS } FOR ... ::= ::= [ { }... ] ::= | 11.69 ::= ADD 11.70 ::= DROP [ ] ::= TO SQL | FROM SQL 11.71 ::= DROP { TRANSFORM | TRANSFORMS } FOR ::= ALL | ::= 11.72 ::= CREATE SEQUENCE [ ] ::= ... ::= | ::= ... ::= | ::= | | | ::= AS ::= START WITH ::= ::= INCREMENT BY ::= ::= MAXVALUE | NO MAXVALUE ::= ::= MINVALUE | NO MINVALUE ::= ::= CYCLE | NO CYCLE > ,(TestStatement ansi2011 > "create sequence seq" > $ CreateSequence [Name Nothing "seq"] []) > ,(TestStatement ansi2011 > "create sequence seq as bigint" > $ CreateSequence [Name Nothing "seq"] > [SGODataType $ TypeName [Name Nothing "bigint"]]) > ,(TestStatement ansi2011 > "create sequence seq as bigint start with 5" > $ CreateSequence [Name Nothing "seq"] > [SGOStartWith 5 > ,SGODataType $ TypeName [Name Nothing "bigint"] > ]) 11.73 ::= ALTER SEQUENCE ::= ... ::= | ::= RESTART [ WITH ] ::= > ,(TestStatement ansi2011 > "alter sequence seq restart" > $ AlterSequence [Name Nothing "seq"] > [SGORestart Nothing]) > ,(TestStatement ansi2011 > "alter sequence seq restart with 5" > $ AlterSequence [Name Nothing "seq"] > [SGORestart $ Just 5]) > ,(TestStatement ansi2011 > "alter sequence seq restart with 5 increment by 5" > $ AlterSequence [Name Nothing "seq"] > [SGORestart $ Just 5 > ,SGOIncrementBy 5]) 11.74 ::= DROP SEQUENCE > ,(TestStatement ansi2011 > "drop sequence seq" > $ DropSequence [Name Nothing "seq"] DefaultDropBehaviour) > ,(TestStatement ansi2011 > "drop sequence seq restrict" > $ DropSequence [Name Nothing "seq"] Restrict) > ]