任何人都可以解釋什么是 partition_position in all_tab_partitions。
任何人都可以告訴我這是什么轉換
SELECT partition_position
FROM all_tab_partitions tp
WHERE tp.table_owner = ? AND
tp.table_name = ? AND
tp.partition_name = ?
到 Postgres。
uj5u.com熱心網友回復:
ALL_TAB_PARTITIONS
| 柱子 | 資料型別 | 描述 |
|---|---|---|
| PARTITION_POSITION | 數字 | 磁區在表中的位置 |
我不知道如何(如果無論如何)將它從 Oracle 翻譯成 PostgreSQL。
uj5u.com熱心網友回復:
您可以像下面這樣轉換 oracle 查詢(也許不是那樣,但我認為它可以幫助您):
Postgres 沒有partition_position列,應該根據表物件 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
uj5u.com熱心網友回復:
PostgreSQL 在表的磁區串列中沒有順序的概念,實際上它在所有情況下都沒有意義。如果磁區鍵是一種沒有總排序的資料型別,比如 ,polygon怎么辦?我承認這是一種不常見的磁區資料型別,但它可以與串列磁區一起使用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/417580.html
標籤:
