sql - Oracle 到 PostgreSQL - 什么是 PostgreSQL 中的“选项卡”?
问题描述
我正在将一些东西从 Oracle 转换为 PostgreSQL。
我有这样的声明:
select * from tab;
我指的是tab
这里。
例如,select * from tab
在 Oracle 中,我提供了我假设的所有对象、表和视图的列表;一切。
这在 Postgres 中不起作用,我似乎找不到合适的替代品。
解决方案
这个 Oracle 视图定义为
select o.name,
decode(o.type#, 2, 'TABLE', 3, 'CLUSTER', 150, 'HIERARCHY', 152, 'ANALYTIC VIEW',
4, 'VIEW', 5, 'SYNONYM'), t.tab#
from sys.tab$ t, sys."_CURRENT_EDITION_OBJ" o
where o.owner# = userenv('SCHEMAID')
and o.type# >=2
and o.type# <=5
and o.linkname is null
and o.obj# = t.obj# (+)
因此它列出了架构中与用户同名的表等。
你可以从符合标准的数据库中得到类似的东西
SELECT table_name, table_type
FROM information_schema.tables
WHERE table_schema = current_user;