阅读了今天的主题
“ SQL。 “有趣的任务,”我回忆道,我一直想向我们优秀的Oracle专家Alex Reprintsev推荐一本关于Oracle SQL高级水平的优秀书籍-“ Oracle SQL的力量”。 它本身对于想要高层次了解Oracle SQL的人来说非常有用,它也是
免费的 ! 此外,还有俄语和英语版本。
通常,
链接到本书本身 。
并
与作者讨论这本书本身 。
并从中列举几个任务示例:
- 连接的组件
有一个由边列表定义的无向图
需要获得连接的组件。
对于下表中的数据:
create table edge(x1, x2) as select 10,20 from dual union all select 50,40 from dual union all select 20,30 from dual union all select 20,40 from dual union all select 60,70 from dual union all select 80,60 from dual union all select 20,90 from dual;
预期会得到以下结果(组件的编号顺序并不重要):
X GRP
- 排序依存关系
现在在有向(有向)图上考虑该问题。
有一个表,其中对象之间具有依赖关系,不包含循环
依赖性。 但是,在成对的顶点之间可能存在多个路径,因此
这样的结构不能称为树。
create table d(name, referenced_name) as (select null, 'a' from dual union all select null, 'd' from dual union all select 'a', 'b' from dual union all select 'd', 'b' from dual union all select 'b', 'e' from dual union all select 'b', 'c' from dual union all select 'e', 'c' from dual);
有必要以最少的步骤走动所有对象,而每一步
您只能绕过所有相关对象都绕过的对象。 也就是说,在
第一步绕过没有依赖性的对象;第二步绕过那些依赖的对象
从第一步的对象开始,依此类推。 换句话说,深度依赖性被编号。
- 覆盖范围
假设有一个以下形式的表:
create table t_range(a, b) as (select 1, 15 from dual union all select 3, 17 from dual union all select 6, 19 from dual union all select 10, 21 from dual union all select 17, 26 from dual union all select 18, 29 from dual union all select 20, 32 from dual union all select 24, 35 from dual union all select 28, 45 from dual union all select 30, 49 from dual);
b>每对a,b; 一个独特的
有必要获取段(1:15),(17:26),(28:45),即我们从
最小a ,然后选择下一行,因此a大于当前行的b ,所以
进一步。
- 热门路径
对于具有文件系统中目录列表的表,仅输出不具有目录列表的表
子目录。
create table t_path(path) as select '/tmp/cat/' from dual union all select '/tmp/cata/' from dual union all select '/tmp/catb/' from dual union all select '/tmp/catb/catx/' from dual union all select '/usr/local/' from dual union all select '/usr/local/lib/liba/' from dual union all select '/usr/local/lib/libx/' from dual union all select '/var/cache/' from dual union all select '/var/cache/'||'xyz'||rownum||'/' from dual connect by level <= 1e6;
对于指示的数据,结果将是:
PATH