all_tab_partitions 中的 partition_position 是什么
what is partition_position in all_tab_partitions
任何人都可以解释 all_tab_partitions
中的 partition_position 是什么。
谁能告诉我这是什么转换
SELECT partition_position
FROM all_tab_partitions tp
WHERE tp.table_owner = ? AND
tp.table_name = ? AND
tp.partition_name = ?
到 Postgres。
Column
Datatype
Description
PARTITION_POSITION
NUMBER
Position of the partition within the table
我不知道如何(如果 无论如何)它可以从 Oracle 转换为 PostgreSQL。
PostgreSQL 在 table 的分区列表中没有顺序的概念,事实上它在所有情况下都没有意义。如果分区键是一种没有总排序的数据类型,比如 polygon
怎么办?我承认这是一种不常见的分区依据数据类型,但它可以与列表分区一起使用。
您可以像下面这样转换 oracle 查询(也许不是这样,但我认为它对您有帮助):
Postgres 没有 partition_position
列,应根据 table 对象 ID
手动创建
WITH partition_info as (
SELECT nmsp_parent.nspname AS parent_schema,
parent.relname AS parent,
owner_parent.rolname AS parent_owner,
nmsp_child.nspname AS child_schema,
child.relname AS child,
owner_child.rolname AS child_owner,
row_number() OVER (PARTITION BY parent.relname ORDER BY child.oid) AS partition_position
FROM pg_inherits
JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
JOIN pg_class child ON pg_inherits.inhrelid = child.oid
JOIN pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
JOIN pg_namespace nmsp_child ON nmsp_child.oid = child.relnamespace
JOIN pg_authid owner_parent ON owner_parent.oid = parent.relowner
JOIN pg_authid owner_child ON owner_child.oid = child.relowner
)
SELECT partition_position
FROM partition_info
WHERE child_owner = ? -- table_owner
AND parent = ? -- partition_name
AND child = ? -- table_name
任何人都可以解释 all_tab_partitions
中的 partition_position 是什么。
谁能告诉我这是什么转换
SELECT partition_position
FROM all_tab_partitions tp
WHERE tp.table_owner = ? AND
tp.table_name = ? AND
tp.partition_name = ?
到 Postgres。
Column | Datatype | Description |
---|---|---|
PARTITION_POSITION | NUMBER | Position of the partition within the table |
我不知道如何(如果 无论如何)它可以从 Oracle 转换为 PostgreSQL。
PostgreSQL 在 table 的分区列表中没有顺序的概念,事实上它在所有情况下都没有意义。如果分区键是一种没有总排序的数据类型,比如 polygon
怎么办?我承认这是一种不常见的分区依据数据类型,但它可以与列表分区一起使用。
您可以像下面这样转换 oracle 查询(也许不是这样,但我认为它对您有帮助):
Postgres 没有 partition_position
列,应根据 table 对象 ID
WITH partition_info as (
SELECT nmsp_parent.nspname AS parent_schema,
parent.relname AS parent,
owner_parent.rolname AS parent_owner,
nmsp_child.nspname AS child_schema,
child.relname AS child,
owner_child.rolname AS child_owner,
row_number() OVER (PARTITION BY parent.relname ORDER BY child.oid) AS partition_position
FROM pg_inherits
JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
JOIN pg_class child ON pg_inherits.inhrelid = child.oid
JOIN pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
JOIN pg_namespace nmsp_child ON nmsp_child.oid = child.relnamespace
JOIN pg_authid owner_parent ON owner_parent.oid = parent.relowner
JOIN pg_authid owner_child ON owner_child.oid = child.relowner
)
SELECT partition_position
FROM partition_info
WHERE child_owner = ? -- table_owner
AND parent = ? -- partition_name
AND child = ? -- table_name