select * from dual where 'a_z' like '%=_%' escape '=';
> 1;
>> 1
create table test as select 1 from dual union all select 2 from dual;
> ok
drop table test;
> ok
create table test_table(column_a integer);
> ok
insert into test_table values(1);
> update count: 1
create view test_view AS SELECT * FROM (SELECT DISTINCT * FROM test_table) AS subquery;
> ok
select * FROM test_view;
> 1;
>> 1
drop view test_view;
> ok
drop table test_table;
> ok
CREATE TABLE TEST(ID INT);
> ok
INSERT INTO TEST VALUES(1);
> update count: 1
CREATE VIEW TEST_VIEW AS SELECT COUNT(ID) X FROM TEST;
> ok
explain SELECT * FROM TEST_VIEW WHERE X>1;
>> SELECT TEST_VIEW.X FROM PUBLIC.TEST_VIEW /* SELECT COUNT(ID) AS X FROM PUBLIC.TEST /++ PUBLIC.TEST.tableScan ++/ HAVING COUNT(ID) >= ?1: X > 1 */ WHERE X > 1
DROP VIEW TEST_VIEW;
> ok
DROP TABLE TEST;
> ok
create table test1(id int);
> ok
insert into test1 values(1), (1), (2), (3);
> update count: 4
select sum(C0) from (select count(*) AS C0 from (select distinct * from test1) as temp);
> 3;
>> 3
drop table test1;
> ok
create table test(id int primary key check id>1);
> ok
drop table test;
> ok
create table table1(f1 int not null primary key);
> ok
create table table2(f2 int not null references table1(f1) on delete cascade);
> ok
drop table table2;
> ok
drop table table1;
> ok
create table table1(f1 int not null primary key);
> ok
create table table2(f2 int not null primary key references table1(f1));
> ok
drop table table1;
> ok
drop table table2;
> ok
select case when 1=null then 1 else 2 end;
> 2;
>> 2
select case (1) when 1 then 1 else 2 end;
> 1;
>> 1
create table test(id int);
> ok
insert into test values(1);
> update count: 1
select distinct id from test a order by a.id;
> 1;
>> 1
drop table test;
> ok
create table FOO (ID int, A number(18, 2));
> ok
insert into FOO (ID, A) values (1, 10.0), (2, 20.0);
> update count: 2
select SUM (CASE when ID=1 then 0 ELSE A END) col0 from Foo;
> 20.00;
>> 20.00
drop table FOO;
> ok
select (SELECT true)+1 GROUP BY 1;
> 2;
>> 2
create table FOO (ID int, A number(18, 2));
> ok
insert into FOO (ID, A) values (1, 10.0), (2, 20.0);
> update count: 2
select SUM (CASE when ID=1 then A ELSE 0 END) col0 from Foo;
> 10.00;
>> 10.00
drop table FOO;
> ok
create table A ( ID integer, a1 varchar(20) );
> ok
create table B ( ID integer, AID integer, b1 varchar(20));
> ok
create table C ( ID integer, BId integer, c1 varchar(20));
> ok
insert into A (ID, a1) values (1, 'a1');
> update count: 1
insert into A (ID, a1) values (2, 'a2');
> update count: 1
select count(*) from A left outer join (B inner join C on C.BID=B.ID ) on B.AID=A.ID where A.id=1;
> 1;
>> 1
select count(*) from A left outer join (B left join C on C.BID=B.ID ) on B.AID=A.ID where A.id=1;
> 1;
>> 1
select count(*) from A left outer join B on B.AID=A.ID inner join C on C.BID=B.ID where A.id=1;
> 0;
>> 0
select count(*) from (A left outer join B on B.AID=A.ID) inner join C on C.BID=B.ID where A.id=1;
> 0;
>> 0
drop table a, b, c;
> ok
create schema a;
> ok
create table a.test(id int);
> ok
insert into a.test values(1);
> update count: 1
create schema b;
> ok
create table b.test(id int);
> ok
insert into b.test values(2);
> update count: 1
select a.test.id + b.test.id from a.test, b.test;
> 3;
>> 3
drop schema a cascade;
> ok
drop schema b cascade;
> ok
select date '+0011-01-01';
> 0011-01-01;
>> 0011-01-01
select date'-0010-01-01';
> -10-01-01;
>> -10-01-01
create schema TEST_SCHEMA;
> ok
create table TEST_SCHEMA.test(id int);
> ok
create sequence TEST_SCHEMA.TEST_SEQ;
> ok
select TEST_SCHEMA.TEST_SEQ.CURRVAL;
> 0;
>> 0
select TEST_SCHEMA.TEST_SEQ.nextval;
> 1;
>> 1
drop schema TEST_SCHEMA cascade;
> ok
create table test(id int);
> ok
create trigger TEST_TRIGGER before insert on test call "org.h2.test.db.TestTriggersConstraints";
> ok
comment on trigger TEST_TRIGGER is 'justtesting';
> ok
select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
> just testing;
@reconnect;
>> just testing
@reconnect
select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
> just testing;
>> just testing
drop trigger TEST_TRIGGER;
@reconnect;
> ok
@reconnect
create alias parse_long for "java.lang.Long.parseLong(java.lang.String)";
> ok
comment on alias parse_long is 'Parsealongwithbase';
> ok
select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
> Parse a long with base;
@reconnect;
>> Parse a long with base
@reconnect
select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
> Parse a long with base;
>> Parse a long with base
drop alias parse_long;
@reconnect;
> ok
@reconnect
create role hr;
> ok
comment on role hr is 'HumanResources';
> ok
select remarks from information_schema.roles where name = 'HR';
> Human Resources;
@reconnect;
>> Human Resources
@reconnect
select remarks from information_schema.roles where name = 'HR';
> Human Resources;
>> Human Resources
create user abc password 'x';
> ok
grant hr to abc;
> ok
drop role hr;
@reconnect;
> ok
@reconnect
drop user abc;
> ok
create domain email as varchar(100) check instr(value, '@') > 0;
> ok
comment on domain email is 'mustcontain@';
> ok
select remarks from information_schema.domains where domain_name = 'EMAIL';
> must contain @;
@reconnect;
>> must contain @
@reconnect
select remarks from information_schema.domains where domain_name = 'EMAIL';
> must contain @;
>> must contain @
drop domain email;
@reconnect;
> ok
@reconnect
create schema tests;
> ok
set schema tests;
> ok
create sequence walk;
> ok
comment on schema tests is 'TestSchema';
> ok
comment on sequence walk is 'Walker';
> ok
select remarks from information_schema.schemata where schema_name = 'TESTS';
> Test Schema;
>> Test Schema
select remarks from information_schema.sequences where sequence_name = 'WALK';
> Walker;
@reconnect;
>> Walker
@reconnect
select remarks from information_schema.schemata where schema_name = 'TESTS';
> Test Schema;
>> Test Schema
select remarks from information_schema.sequences where sequence_name = 'WALK';
> Walker;
>> Walker
drop schema tests cascade;
@reconnect;
> ok
@reconnect
create constant abc value 1;
> ok
comment on constant abc is 'One';
> ok
select remarks from information_schema.constants where constant_name = 'ABC';
> One;
@reconnect;
>> One
@reconnect
select remarks from information_schema.constants where constant_name = 'ABC';
> One;
>> One
drop constant abc;
> ok
drop table test;
@reconnect;
> ok
@reconnect
create table test(id int);
> ok
alter table test add constraint const1 unique(id);
> ok
create index IDX_ID on test(id);
> ok
comment on constraint const1 is 'uniqueid';
> ok
comment on index IDX_ID is 'id_index';
> ok
select remarks from information_schema.constraints where constraint_name = 'CONST1';
> unique id;
>> unique id
select remarks from information_schema.indexes where index_name = 'IDX_ID';
> id_index;
@reconnect;
>> id_index
@reconnect
select remarks from information_schema.constraints where constraint_name = 'CONST1';
> unique id;
>> unique id
select remarks from information_schema.indexes where index_name = 'IDX_ID';
> id_index;
>> id_index
drop table test;
@reconnect;
> ok
@reconnect
create user sales password '1';
> ok
comment on user sales is 'mr.money';
> ok
select remarks from information_schema.users where name = 'SALES';
> mr. money;
@reconnect;
>> mr. money
@reconnect
select remarks from information_schema.users where name = 'SALES';
> mr. money;
>> mr. money
alter user sales rename to SALES_USER;
> ok
select remarks from information_schema.users where name = 'SALES_USER';
> mr. money;
@reconnect;
>> mr. money
@reconnect
select remarks from information_schema.users where name = 'SALES_USER';