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

📄 derived.out

📁 derby database source code.good for you.
💻 OUT
📖 第 1 页 / 共 2 页
字号:
ij> ---- this tests derived column lists and derived tables--create table s (a int, b int, c int, d int, e int, f int);0 rows inserted/updated/deletedij> create table t (aa int, bb int, cc int, dd int, ee int, ff int);0 rows inserted/updated/deletedij> insert into s values (0,1,2,3,4,5);1 row inserted/updated/deletedij> insert into s values (10,11,12,13,14,15);1 row inserted/updated/deletedij> -- tests without a derived table-- negative tests-- # of columns does not matchselect aa from s ss (aa);ERROR 42X32: The number of columns in the derived column list must match the number of columns in table 'S'.ij> select aa from s ss (aa, bb, cc, dd, ee, ff, gg);ERROR 42X32: The number of columns in the derived column list must match the number of columns in table 'S'.ij> -- duplicate names in derived column listselect aa from s ss (aa, ee, bb, cc, dd, aa);ERROR 42X33: The derived column list contains a duplicate column name 'AA'.ij> -- test case insensitivityselect aa from s ss (aa, bb, cc, dd, ee, AA);ERROR 42X33: The derived column list contains a duplicate column name 'AA'.ij> -- test uniqueness of namesselect aa from s ss (aa, bb, cc, dd, ee, ff), t;ERROR 42X03: Column name 'AA' is in more than one table in the FROM list.ij> -- test uniqueness of namesinsert into t select aa from s aa (aa, bb, cc, dd, ee, ff), s bb (aa, bb, cc, dd, ee, ff);ERROR 42X03: Column name 'AA' is in more than one table in the FROM list.ij> -- verify using "exposed" namesselect a from s ss (aa, bb, cc, dd, ee, ff);ERROR 42X04: Column 'A' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'A' is not a column in the target table.ij> -- positive tests-- rename the columnsselect * from s ss (f, e, d, c, b, a) where f = 0;F          |E          |D          |C          |B          |A          -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          ij> -- delimited identifiers in listselect * from s ss ("a a", "b b", "c c", "d d", "e e", "f f") where "a a" = 0;a a        |b b        |c c        |d d        |e e        |f f        -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          ij> -- uniqueness of "exposed" namesselect a, aa from s a, s b (aa, bb, cc, dd, ee, ff)	where f = ff and aa = 10;A          |AA         -----------------------10         |10         ij> select a.a, b.aa from s a, s b (aa, bb, cc, dd, ee, ff) where f = ff and b.aa = 10;A          |AA         -----------------------10         |10         ij> -- insert testsinsert into t select * from s ss (aa, bb, cc, dd, ee, ff);2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> delete from t;2 rows inserted/updated/deletedij> insert into t (aa,bb) select ff, aa from s ss (aa, bb, cc, dd, ee, ff);2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------5          |0          |NULL       |NULL       |NULL       |NULL       15         |10         |NULL       |NULL       |NULL       |NULL       ij> delete from t;2 rows inserted/updated/deletedij> -- derived tables-- negative tests-- no correlation nameselect * from (select * from s);ERROR 42X01: Syntax error: Encountered "<EOF>" at line 5, column 31.ij> -- # of columns does not matchselect aa from (select * from s) ss (aa);ERROR 42X32: The number of columns in the derived column list must match the number of columns in table 'SS'.ij> select aa from (select * from s) ss (aa, bb, cc, dd, ee, ff, gg);ERROR 42X32: The number of columns in the derived column list must match the number of columns in table 'SS'.ij> -- duplicate names in derived column listselect aa from (select * from s) ss (aa, ee, bb, cc, dd, aa);ERROR 42X33: The derived column list contains a duplicate column name 'AA'.ij> -- test case insensitivityselect aa from (select * from s) ss (aa, bb, cc, dd, ee, AA);ERROR 42X33: The derived column list contains a duplicate column name 'AA'.ij> -- test uniqueness of namesselect aa from (select * from s) ss (aa, bb, cc, dd, ee, ff), t;ERROR 42X03: Column name 'AA' is in more than one table in the FROM list.ij> -- test uniqueness of namesinsert into t select aa from (select * from s) aa (aa, bb, cc, dd, ee, ff), 	 (select * from s) bb (aa, bb, cc, dd, ee, ff);ERROR 42X03: Column name 'AA' is in more than one table in the FROM list.ij> -- verify using "exposed" namesselect a from (select * from s) ss (aa, bb, cc, dd, ee, ff);ERROR 42X04: Column 'A' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'A' is not a column in the target table.ij> -- ambiguous column referenceselect a from (select * from s a, s b) ss;ERROR 42Y34: Column name 'A' matches more than one result column in table 'SS'.ij> -- positive tests-- simple derived tableselect a from (select a from s) a;A          -----------0          10         ij> -- select * query'sselect * from (select * from s) a;A          |B          |C          |D          |E          |F          -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> select * from (select a, b, c, d, e, f from s) a;A          |B          |C          |D          |E          |F          -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> select * from (select a, b, c from s) a;A          |B          |C          -----------------------------------0          |1          |2          10         |11         |12         ij> select a, b, c, d, e, f from (select * from s) a;A          |B          |C          |D          |E          |F          -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> -- simple derived tableinsert into t (aa) select a from (select a from s) a;2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |NULL       |NULL       |NULL       |NULL       |NULL       10         |NULL       |NULL       |NULL       |NULL       |NULL       ij> delete from t;2 rows inserted/updated/deletedij> -- select * query'sinsert into t select * from (select * from s) a;2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> delete from t;2 rows inserted/updated/deletedij> insert into t select * from (select a, b, c, d, e, f from s) a;2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> delete from t;2 rows inserted/updated/deletedij> insert into t (aa, bb, cc) select * from (select a, b, c from s) a;2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |1          |2          |NULL       |NULL       |NULL       10         |11         |12         |NULL       |NULL       |NULL       ij> delete from t;2 rows inserted/updated/deletedij> insert into t select a, b, c, d, e, f from (select * from s) a;2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> delete from t;2 rows inserted/updated/deletedij> -- simple derived table with derived column listselect a from (select a from s) a (a);A          -----------0          10         ij> -- select * query's	with derived column listsselect * from (select * from s) a (f, e, d, c, b, a);F          |E          |D          |C          |B          |A          -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> select * from (select a, b, c, d, e, f from s) a (f, e, d, c, b, a);F          |E          |D          |C          |B          |A          -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> select * from (select a, b, c from s) a (c, f, e);C          |F          |E          -----------------------------------0          |1          |2          10         |11         |12         ij> select a, b, c, d, e, f from (select * from s) a (a, b, c, d, e, f);A          |B          |C          |D          |E          |F          -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> -- simple derived table with derived column listinsert into t (aa) select a from (select a from s) a (a);2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |NULL       |NULL       |NULL       |NULL       |NULL       10         |NULL       |NULL       |NULL       |NULL       |NULL       ij> delete from t;2 rows inserted/updated/deletedij> -- select * query's with derived column listsinsert into t select * from (select * from s) a (c, b, a, e, f, d);2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> delete from t;2 rows inserted/updated/deletedij> insert into t select * from (select a, b, c, d, e, f from s) a (f, a, c, b, e, d);2 rows inserted/updated/deletedij> select * from t;AA         |BB         |CC         |DD         |EE         |FF         -----------------------------------------------------------------------0          |1          |2          |3          |4          |5          10         |11         |12         |13         |14         |15         ij> delete from t;2 rows inserted/updated/deletedij> insert into t (aa, bb, cc) select * from (select a, b, c from s) a (f, e, a);2 rows inserted/updated/deletedij> select * from t;

⌨️ 快捷键说明

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