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

📄 renameindex.sql

📁 derby database source code.good for you.
💻 SQL
字号:
-- rename index tests--autocommit off;---- negative tests---- rename a non-existing index-- should fail because there is no index by name i1t1rename index i1t1 to i1rt1;---- rename as some existing index namecreate table t1(c11 int, c12 int);create index i1t1 on t1(c11);create index i2t1 on t1(c12);rename index i1t1 to i2t1;drop table t1;---- rename a system table's indexset schema sys;-- will fail because it is a system tablerename index syscolumns_index1 to newName;set schema app;---- rename an index when a view is on a tablecreate table t1(c11 int, c12 int);create index t1i1 on t1(c11);create view v1 as select * from t1;select * from v1;-- this succeeds with no exceptionsrename index t1i1 to t1i1r;-- this succeeds with no exceptionsselect * from v1;drop view v1;drop table t1;-- another test for viewscreate table t1(c11 int not null primary key, c12 int);create index i1t1 on t1(c11);create view v1 as select * from t1;-- following rename shouldn't failrename index i1t1 to i1rt1;drop view v1;-- even though there is no index i1t1 it still doesn't failcreate view v1 as select * from t1;-- this succeeds with no exceptionsselect * from v1;rename index i1rt1 to i1t1;-- now succeedsselect * from v1;drop view v1;drop table t1;---- cannot rename an index when there is an open cursor on itcreate table t1(c11 int, c12 int);create index i1 on t1(c11);get cursor c1 as 'select * from t1';-- following rename should fail because of the cursor c1rename index i1 to i1r;close c1;-- following rename should pass because cursor c1 has been closedrename index i1 to i1r;drop table t1;---- creating a prepared statement on a tablecreate table t1(c11 int not null primary key, c12 int);-- bug 5685create index i1 on t1(c11);autocommit off;prepare p1 as 'select * from t1 where c11 > ?';execute p1 using 'values (1)';-- doesn't failrename index i1 to i1r;-- statement passesexecute p1 using 'values (1)';remove p1;autocommit on;drop table t1;---- positive tests-- a column with an index on it can be renamedcreate table t3(c31 int not null primary key, c32 int);create index i1_t3 on t3(c32);rename index i1_t3 to i1_3r;-- make sure that i1_t3 did get renamed. Following rename should fail to prove that.rename index i1_t3 to i1_3r;drop table t3;---- creating a prepared statement on a tableautocommit off;create table t3(c31 int not null primary key, c32 int);create index i1_t3 on t3(c32);prepare p3 as 'select * from t3 where c31 > ?';execute p3 using 'values (1)';-- can rename with no errorsrename index i1_t3 to i1_t3r;execute p3 using 'values (1)';rename index i1_t3r to i1_t3;-- this should pass know because we restored the original index nameexecute p3 using 'values (1)';remove p3;autocommit on;drop table t3;

⌨️ 快捷键说明

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