?? renameindex.out
字號(hào):
ij> -- rename index tests--autocommit off;ij> ---- negative tests---- rename a non-existing index-- should fail because there is no index by name i1t1rename index i1t1 to i1rt1;ERROR 42X65: Index 'I1T1' does not exist.ij> ---- rename as some existing index namecreate table t1(c11 int, c12 int);0 rows inserted/updated/deletedij> create index i1t1 on t1(c11);0 rows inserted/updated/deletedij> create index i2t1 on t1(c12);0 rows inserted/updated/deletedij> rename index i1t1 to i2t1;ERROR X0Y32: Index 'I2T1' already exists in Schema 'APP'.ij> drop table t1;0 rows inserted/updated/deletedij> ---- rename a system table's indexset schema sys;0 rows inserted/updated/deletedij> -- will fail because it is a system tablerename index syscolumns_index1 to newName;ERROR X0Y56: 'RENAME INDEX' is not allowed on the System table 'SYS.SYSCOLUMNS'.ij> set schema app;0 rows inserted/updated/deletedij> ---- rename an index when a view is on a tablecreate table t1(c11 int, c12 int);0 rows inserted/updated/deletedij> create index t1i1 on t1(c11);0 rows inserted/updated/deletedij> create view v1 as select * from t1;0 rows inserted/updated/deletedij> select * from v1;C11 |C12 -----------------------ij> -- this succeeds with no exceptionsrename index t1i1 to t1i1r;0 rows inserted/updated/deletedij> -- this succeeds with no exceptionsselect * from v1;C11 |C12 -----------------------ij> drop view v1;0 rows inserted/updated/deletedij> drop table t1;0 rows inserted/updated/deletedij> -- another test for viewscreate table t1(c11 int not null primary key, c12 int);0 rows inserted/updated/deletedij> create index i1t1 on t1(c11);0 rows inserted/updated/deletedWARNING 01504: The new index is a duplicate of an existing index: xxxxGENERATED-IDxxxx.ij> create view v1 as select * from t1;0 rows inserted/updated/deletedij> -- following rename shouldn't failrename index i1t1 to i1rt1;ERROR 42X65: Index 'I1T1' does not exist.ij> drop view v1;0 rows inserted/updated/deletedij> -- even though there is no index i1t1 it still doesn't failcreate view v1 as select * from t1;0 rows inserted/updated/deletedij> -- this succeeds with no exceptionsselect * from v1;C11 |C12 -----------------------ij> rename index i1rt1 to i1t1;ERROR 42X65: Index 'I1RT1' does not exist.ij> -- now succeedsselect * from v1;C11 |C12 -----------------------ij> drop view v1;0 rows inserted/updated/deletedij> drop table t1;0 rows inserted/updated/deletedij> ---- cannot rename an index when there is an open cursor on itcreate table t1(c11 int, c12 int);0 rows inserted/updated/deletedij> create index i1 on t1(c11);0 rows inserted/updated/deletedij> get cursor c1 as 'select * from t1';ij> -- following rename should fail because of the cursor c1rename index i1 to i1r;ERROR X0X95: Operation 'RENAME INDEX' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.ij> close c1;ij> -- following rename should pass because cursor c1 has been closedrename index i1 to i1r;0 rows inserted/updated/deletedij> drop table t1;0 rows inserted/updated/deletedij> ---- creating a prepared statement on a tablecreate table t1(c11 int not null primary key, c12 int);0 rows inserted/updated/deletedij> -- bug 5685create index i1 on t1(c11);0 rows inserted/updated/deletedWARNING 01504: The new index is a duplicate of an existing index: xxxxGENERATED-IDxxxx.ij> autocommit off;ij> prepare p1 as 'select * from t1 where c11 > ?';ij> execute p1 using 'values (1)';C11 |C12 -----------------------ij> -- doesn't failrename index i1 to i1r;ERROR 42X65: Index 'I1' does not exist.ij> -- statement passesexecute p1 using 'values (1)';C11 |C12 -----------------------ij> remove p1;ij> autocommit on;ij> drop table t1;0 rows inserted/updated/deletedij> ---- positive tests-- a column with an index on it can be renamedcreate table t3(c31 int not null primary key, c32 int);0 rows inserted/updated/deletedij> create index i1_t3 on t3(c32);0 rows inserted/updated/deletedij> rename index i1_t3 to i1_3r;0 rows inserted/updated/deletedij> -- make sure that i1_t3 did get renamed. Following rename should fail to prove that.rename index i1_t3 to i1_3r;ERROR 42X65: Index 'I1_T3' does not exist.ij> drop table t3;0 rows inserted/updated/deletedij> ---- creating a prepared statement on a tableautocommit off;ij> create table t3(c31 int not null primary key, c32 int);0 rows inserted/updated/deletedij> create index i1_t3 on t3(c32);0 rows inserted/updated/deletedij> prepare p3 as 'select * from t3 where c31 > ?';ij> execute p3 using 'values (1)';C31 |C32 -----------------------ij> -- can rename with no errorsrename index i1_t3 to i1_t3r;0 rows inserted/updated/deletedij> execute p3 using 'values (1)';C31 |C32 -----------------------ij> rename index i1_t3r to i1_t3;0 rows inserted/updated/deletedij> -- this should pass know because we restored the original index nameexecute p3 using 'values (1)';C31 |C32 -----------------------ij> remove p3;ij> autocommit on;ij> drop table t3;0 rows inserted/updated/deletedij>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -