⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 currentschema.sql

📁 derby database source code.good for you.
💻 SQL
字号:
-- test for CURRENT SCHEMA and optional DB2 compatible SET SCHEMA statement---- test SET SCHEMA syntax variations-- syntax is SET [CURRENT] SCHEMA [=] (<identifier> | USER | ? | '<string>')--			 SET CURRENT SQLID [=] (<identifier> | USER | ? | '<string>')--values current schema;set schema sys;values current schema;create schema app;set current schema app;values current schema;set schema =  sys;values current schema;set current schema = app;values current schema;set schema sys;-- user should use default schema if no user setset schema user;values current schema;-- see what user does when there is a usercreate schema judy;connect 'jdbc:derby:wombat;user=judy' as judy;set schema app;values current schema;set schema user;values current schema;disconnect;set connection connection0;-- check for defaultvalues current schema;-- check that current sqlid works as a synonymvalues current sqlid;-- check that sqlid still works as an identifercreate table sqlid(sqlid int);drop table sqlid;-- check that set current sqlid worksset current sqlid judy;values current schema;-- check that set sqlid doesn't work (not DB2 compatible) - should get errorset sqlid judy;-- change schema and make sure that the current schema is correctset schema sys;values current schema;set schema app;-- try using ? outside of a prepared statementset schema ?;-- use set schema in a prepared statementautocommit off;prepare p1 as 'set schema ?';-- should get error with no parametersexecute p1;-- should get error if null is usedcreate table t1(name varchar(128));insert into t1 values(null);execute p1 using 'select name from t1';-- should get error if schema doesn't existexecute p1 using 'values(''notthere'')';-- should error with empty stringexecute p1 using 'values('''')';-- should get error if wrong case usedexecute p1 using 'values(''sys'')';-- should get error if too many parametersexecute p1 using 'values(''sys'',''app'')';-- USER should return an error as it is interpreted as a string constant not an-- identifierexecute p1 using 'values(''USER'')';-- try positive testexecute p1 using 'values(''SYS'')';values current schema;rollback;autocommit on;-- -- try current schema in a number of statements typesset schema app;create table t1 ( a varchar(128));-- insertinsert into t1 values (current schema);select * from t1;set schema judy;insert into app.t1 values (current schema);select * from app.t1;-- delete where clausedelete from app.t1 where a = current schema;select * from app.t1;set current schema app;-- target listselect current schema from t1;-- where clauseselect * from t1 where a = current schema;-- update statementdelete from t1;insert into t1 values ('test');select * from t1;update t1 set a = current schema;select * from t1;set schema judy;update app.t1 set a = current schema;select * from app.t1;set schema app;drop table t1;-- defaultset schema APP;create table t1 ( a int, b varchar(128) default current schema);insert into t1 (a) values (1);set schema SYS;insert into app.t1 (a) values (1);set schema judy;insert into app.t1 (a) values (1);set schema APP;select * from t1;drop table t1;-- check constraint - this should failcreate table t1 ( a varchar(128), check (a = current schema));create table t1 ( a varchar(128), check (a = current sqlid));-- try mix casecreate schema "MiXCase";set schema "MiXCase";values current schema;set schema app;values current schema;set schema 'MiXCase';values current schema;-- following should get error - schema not foundset schema 'MIXCASE';set schema mixcase;-- try long schema names (maximum schema identifier length has been changed to 30 as part of DB2 compatibility work)create schema t23456789012345678901234567890;values current schema;set schema app;values current schema;set schema t23456789012345678901234567890;values current schema;set schema app;values current schema;set schema 'T23456789012345678901234567890';values current schema;set schema app;values current schema;autocommit off;prepare p1 as 'set schema ?';execute p1 using 'values(''T23456789012345678901234567890'')';values current schema;-- the following should fail - 129 lengthcreate schema TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT;set schema TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT;set schema 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';execute p1 using 'values(''TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT'')';rollback;autocommit on;-- clean updrop schema judy restrict;drop schema TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT restrict;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -