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 SQL2011 "create schema my_schema" > $ CreateSchema [Name "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 SQL2011 "drop schema my_schema" > $ DropSchema [Name "my_schema"] DefaultDropBehaviour) > ,(TestStatement SQL2011 "drop schema my_schema cascade" > $ DropSchema [Name "my_schema"] Cascade) > ,(TestStatement SQL2011 "drop schema my_schema restrict" > $ DropSchema [Name "my_schema"] Restrict) 11.3
::= CREATE [
] TABLE
[ WITH ] [ ON COMMIT
ROWS ] > ,(TestStatement SQL2011 "create table t (a int, b int);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name "b") (TypeName [Name "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 SQL2011 > "create table t (a int not null);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing ColNotNullConstraint]]) > ,(TestStatement SQL2011 > "create table t (a int constraint a_not_null not null);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef (Just [Name "a_not_null"]) ColNotNullConstraint]]) > ,(TestStatement SQL2011 > "create table t (a int unique);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing ColUniqueConstraint]]) > ,(TestStatement SQL2011 > "create table t (a int primary key);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "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 SQL2011 > "create table t (a int references u);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u(a));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] (Just $ Name "a") DefaultReferenceMatch > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u match full);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing MatchFull > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u match partial);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing MatchPartial > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u match simple);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing MatchSimple > DefaultReferentialAction DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u on update cascade );" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > RefCascade DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u on update set null );" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > RefSetNull DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u on update set default );" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > RefSetDefault DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u on update no action );" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > RefNoAction DefaultReferentialAction]]) > ,(TestStatement SQL2011 > "create table t (a int references u on delete cascade );" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > DefaultReferentialAction RefCascade]]) > ,(TestStatement SQL2011 > "create table t (a int references u on update cascade on delete restrict );" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > RefCascade RefRestrict]]) > ,(TestStatement SQL2011 > "create table t (a int references u on delete restrict on update cascade );" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing $ ColReferencesConstraint > [Name "u"] Nothing DefaultReferenceMatch > RefCascade RefRestrict]]) TODO: try combinations and permutations of column constraints and options > ,(TestStatement SQL2011 > "create table t (a int check (a>5));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing > [ColConstraintDef Nothing > (ColCheckConstraint $ BinOp (Iden [Name "a"]) [Name ">"] (NumLit "5"))]]) ::= GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ] > ,(TestStatement SQL2011 "create table t (a int generated always as identity);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) > (Just $ IdentityColumnSpec GeneratedAlways []) []]) > ,(TestStatement SQL2011 "create table t (a int generated by default as identity);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) > (Just $ IdentityColumnSpec GeneratedByDefault []) []]) > ,(TestStatement SQL2011 > "create table t (a int generated always as identity\n\ > \ ( start with 5 increment by 5 maxvalue 500 minvalue 5 cycle ));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) > (Just $ IdentityColumnSpec GeneratedAlways > [SGOStartWith 5 > ,SGOIncrementBy 5 > ,SGOMaxValue 500 > ,SGOMinValue 5 > ,SGOCycle]) []]) > ,(TestStatement SQL2011 > "create table t (a int generated always as identity\n\ > \ ( start with -4 no maxvalue no minvalue no cycle ));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "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 SQL2011 > "create table t (a int, \n\ > \ a2 int generated always as (a * 2));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name "a2") (TypeName [Name "int"]) > (Just $ GenerationClause > (BinOp (Iden [Name "a"]) [Name "*"] (NumLit "2"))) []]) 11.5 ::= DEFAULT ::= | | USER | CURRENT_USER | CURRENT_ROLE | SESSION_USER | SYSTEM_USER | CURRENT_CATALOG | CURRENT_SCHEMA | CURRENT_PATH | > ,(TestStatement SQL2011 "create table t (a int default 0);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) > (Just $ DefaultClause $ NumLit "0") []]) 11.6
::= [ ]
[ ]
::= | | 11.7 ::= [ ] | UNIQUE ( VALUE ) ::= UNIQUE | PRIMARY KEY ::= > ,(TestStatement SQL2011 > "create table t (a int, unique (a));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef Nothing $ TableUniqueConstraint [Name "a"] > ]) > ,(TestStatement SQL2011 > "create table t (a int, constraint a_unique unique (a));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef (Just [Name "a_unique"]) $ > TableUniqueConstraint [Name "a"] > ]) todo: test permutations of column defs and table constraints > ,(TestStatement SQL2011 > "create table t (a int, b int, unique (a,b));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name "b") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TableUniqueConstraint [Name "a", Name "b"] > ]) > ,(TestStatement SQL2011 > "create table t (a int, b int, primary key (a,b));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name "b") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TablePrimaryKeyConstraint [Name "a", Name "b"] > ]) ::= WITHOUT OVERLAPS defintely skip 11.8 ::= FOREIGN KEY [ ] > ,(TestStatement SQL2011 > "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 "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name "b") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TableReferencesConstraint > [Name "a", Name "b"] > [Name "u"] > (Just [Name "c", Name "d"]) > MatchFull RefCascade RefRestrict > ]) > ,(TestStatement SQL2011 > "create table t (a int,\n\ > \ constraint tfku1 foreign key (a) references u);" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef (Just [Name "tfku1"]) $ > TableReferencesConstraint > [Name "a"] > [Name "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 SQL2011 > "create table t (a int, b int, \n\ > \ check (a > b));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name "b") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef Nothing $ > TableCheckConstraint > (BinOp (Iden [Name "a"]) [Name ">"] (Iden [Name "b"])) > ]) > ,(TestStatement SQL2011 > "create table t (a int, b int, \n\ > \ constraint agtb check (a > b));" > $ CreateTable [Name "t"] > [TableColumnDef $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ,TableColumnDef $ ColumnDef (Name "b") (TypeName [Name "int"]) Nothing [] > ,TableConstraintDef (Just [Name "agtb"]) $ > TableCheckConstraint > (BinOp (Iden [Name "a"]) [Name ">"] (Iden [Name "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 SQL2011 > "alter table t add column a int" > $ AlterTable [Name "t"] $ AddColumnDef > $ ColumnDef (Name "a") (TypeName [Name "int"]) Nothing [] > ) todo: more add column 11.12 ::= ALTER [ COLUMN ] ::= | | | | | | | | | 11.13 ::= SET > ,(TestStatement SQL2011 > "alter table t alter column c set default 0" > $ AlterTable [Name "t"] $ AlterColumnSetDefault (Name "c") > $ NumLit "0") 11.14 ::= DROP DEFAULT > ,(TestStatement SQL2011 > "alter table t alter column c drop default" > $ AlterTable [Name "t"] $ AlterColumnDropDefault (Name "c")) 11.15 ::= SET NOT NULL > ,(TestStatement SQL2011 > "alter table t alter column c set not null" > $ AlterTable [Name "t"] $ AlterColumnSetNotNull (Name "c")) 11.16 ::= DROP NOT NULL > ,(TestStatement SQL2011 > "alter table t alter column c drop not null" > $ AlterTable [Name "t"] $ AlterColumnDropNotNull (Name "c")) 11.17 ::= ADD 11.18 ::= DROP SCOPE 11.19 ::= SET DATA TYPE > ,(TestStatement SQL2011 > "alter table t alter column c set data type int;" > $ AlterTable [Name "t"] $ > AlterColumnSetDataType (Name "c") (TypeName [Name "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 SQL2011 > "alter table t drop column c" > $ AlterTable [Name "t"] $ > DropColumn (Name "c") DefaultDropBehaviour) > ,(TestStatement SQL2011 > "alter table t drop c cascade" > $ AlterTable [Name "t"] $ > DropColumn (Name "c") Cascade) > ,(TestStatement SQL2011 > "alter table t drop c restrict" > $ AlterTable [Name "t"] $ > DropColumn (Name "c") Restrict) 11.24 ::= ADD
> ,(TestStatement SQL2011 > "alter table t add constraint c unique (a,b)" > $ AlterTable [Name "t"] $ > AddTableConstraintDef (Just [Name "c"]) > $ TableUniqueConstraint [Name "a", Name "b"]) > ,(TestStatement SQL2011 > "alter table t add unique (a,b)" > $ AlterTable [Name "t"] $ > AddTableConstraintDef Nothing > $ TableUniqueConstraint [Name "a", Name "b"]) 11.25 ::= ALTER CONSTRAINT todo 11.26 ::= DROP CONSTRAINT > ,(TestStatement SQL2011 > "alter table t drop constraint c" > $ AlterTable [Name "t"] $ > DropTableConstraintDef [Name "c"] DefaultDropBehaviour) > ,(TestStatement SQL2011 > "alter table t drop constraint c restrict" > $ AlterTable [Name "t"] $ > DropTableConstraintDef [Name "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 SQL2011 > "drop table t" > $ DropTable [Name "t"] DefaultDropBehaviour) > ,(TestStatement SQL2011 > "drop table t restrict" > $ DropTable [Name "t"] Restrict) 11.32 ::= CREATE [ RECURSIVE ] VIEW
AS [ WITH [ ] CHECK OPTION ] ::= | ::= [ ] ::= OF [ ] [ ] ::= UNDER
::= [ { }... ] ::= | ::= WITH OPTIONS ::= CASCADED | LOCAL ::= > ,(TestStatement SQL2011 > "create view v as select * from t" > $ CreateView False [Name "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "t"]] > }) Nothing) > ,(TestStatement SQL2011 > "create recursive view v as select * from t" > $ CreateView True [Name "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "t"]] > }) Nothing) > ,(TestStatement SQL2011 > "create view v(a,b) as select * from t" > $ CreateView False [Name "v"] (Just [Name "a", Name "b"]) > (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "t"]] > }) Nothing) > ,(TestStatement SQL2011 > "create view v as select * from t with check option" > $ CreateView False [Name "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "t"]] > }) (Just DefaultCheckOption)) > ,(TestStatement SQL2011 > "create view v as select * from t with cascaded check option" > $ CreateView False [Name "v"] Nothing (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "t"]] > }) (Just CascadedCheckOption)) > ,(TestStatement SQL2011 > "create view v as select * from t with local check option" > $ CreateView False [Name "v"] Nothing > (makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "t"]] > }) (Just LocalCheckOption)) 11.33 ::= DROP VIEW
> ,(TestStatement SQL2011 > "drop view v" > $ DropView [Name "v"] DefaultDropBehaviour) > ,(TestStatement SQL2011 > "drop view v cascade" > $ DropView [Name "v"] Cascade) 11.34 ::= CREATE DOMAIN [ AS ] [ ] [ ... ] [ ] ::= [ ] [ ] > ,(TestStatement SQL2011 > "create domain my_int int" > $ CreateDomain [Name "my_int"] > (TypeName [Name "int"]) > Nothing []) > ,(TestStatement SQL2011 > "create domain my_int as int" > $ CreateDomain [Name "my_int"] > (TypeName [Name "int"]) > Nothing []) > ,(TestStatement SQL2011 > "create domain my_int int default 0" > $ CreateDomain [Name "my_int"] > (TypeName [Name "int"]) > (Just (NumLit "0")) []) > ,(TestStatement SQL2011 > "create domain my_int int check (value > 5)" > $ CreateDomain [Name "my_int"] > (TypeName [Name "int"]) > Nothing [(Nothing > ,BinOp (Iden [Name "value"]) [Name ">"] (NumLit "5"))]) > ,(TestStatement SQL2011 > "create domain my_int int constraint gt5 check (value > 5)" > $ CreateDomain [Name "my_int"] > (TypeName [Name "int"]) > Nothing [(Just [Name "gt5"] > ,BinOp (Iden [Name "value"]) [Name ">"] (NumLit "5"))]) 11.35 ::= ALTER DOMAIN ::= | | | 11.36 ::= SET > ,(TestStatement SQL2011 > "alter domain my_int set default 0" > $ AlterDomain [Name "my_int"] > $ ADSetDefault $ NumLit "0") 11.37 ::= DROP DEFAULT > ,(TestStatement SQL2011 > "alter domain my_int drop default" > $ AlterDomain [Name "my_int"] > $ ADDropDefault) 11.38 ::= ADD > ,(TestStatement SQL2011 > "alter domain my_int add check (value > 6)" > $ AlterDomain [Name "my_int"] > $ ADAddConstraint Nothing > $ BinOp (Iden [Name "value"]) [Name ">"] (NumLit "6")) > ,(TestStatement SQL2011 > "alter domain my_int add constraint gt6 check (value > 6)" > $ AlterDomain [Name "my_int"] > $ ADAddConstraint (Just [Name "gt6"]) > $ BinOp (Iden [Name "value"]) [Name ">"] (NumLit "6")) 11.39 ::= DROP CONSTRAINT > ,(TestStatement SQL2011 > "alter domain my_int drop constraint gt6" > $ AlterDomain [Name "my_int"] > $ ADDropConstraint [Name "gt6"]) 11.40 ::= DROP DOMAIN > ,(TestStatement SQL2011 > "drop domain my_int" > $ DropDomain [Name "my_int"] DefaultDropBehaviour) > ,(TestStatement SQL2011 > "drop domain my_int cascade" > $ DropDomain [Name "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 [ ] 11.48 ::= DROP ASSERTION [ ] 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 SQL2011 > "create sequence seq" > $ CreateSequence [Name "seq"] []) > ,(TestStatement SQL2011 > "create sequence seq as bigint" > $ CreateSequence [Name "seq"] > [SGODataType $ TypeName [Name "bigint"]]) > ,(TestStatement SQL2011 > "create sequence seq as bigint start with 5" > $ CreateSequence [Name "seq"] > [SGOStartWith 5 > ,SGODataType $ TypeName [Name "bigint"] > ]) 11.73 ::= ALTER SEQUENCE ::= ... ::= | ::= RESTART [ WITH ] ::= > ,(TestStatement SQL2011 > "alter sequence seq restart" > $ AlterSequence [Name "seq"] > [SGORestart Nothing]) > ,(TestStatement SQL2011 > "alter sequence seq restart with 5" > $ AlterSequence [Name "seq"] > [SGORestart $ Just 5]) > ,(TestStatement SQL2011 > "alter sequence seq restart with 5 increment by 5" > $ AlterSequence [Name "seq"] > [SGORestart $ Just 5 > ,SGOIncrementBy 5]) 11.74 ::= DROP SEQUENCE > ,(TestStatement SQL2011 > "drop sequence seq" > $ DropSequence [Name "seq"] DefaultDropBehaviour) > ,(TestStatement SQL2011 > "drop sequence seq restrict" > $ DropSequence [Name "seq"] Restrict) > ]