> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-shdepend.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 52.48. pg\_shdepend \#

### 52.48. `pg_shdepend` [#](#catalog-pg-shdepend) <a href="#catalog-pg-shdepend" id="catalog-pg-shdepend"></a>

系統目錄 `pg_shdepend` 記錄資料庫物件與共享物件（例如角色）之間的相依關係。這些資訊讓 PostgreSQL 能在嘗試刪除這些物件之前，確保它們未被參照。

另請參閱 [`pg_depend`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-depend.md)，它對涉及單一資料庫內物件的相依關係執行類似的功能。

與大多數系統目錄不同，`pg_shdepend` 由叢集中的所有資料庫共享：每個叢集只有一份 `pg_shdepend`，而不是每個資料庫各一份。

#### 表 52.48. `pg_shdepend` 欄位 [#](#catalog-pg-shdepend-columns) <a href="#catalog-pg-shdepend-columns" id="catalog-pg-shdepend-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><code>dbid</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-database.md"><code>pg\_database</code></a>.<code>oid</code>）</p><p>相依物件所在資料庫的 OID；若為共享物件則為零</p>     |
| <p><code>classid</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>oid</code>）</p><p>相依物件所在之系統目錄的 OID</p>                |
| <p><code>objid</code> <code>oid</code> （參照任何 OID 欄位）</p><p>特定相依物件的 OID</p>                                                                                                                                         |
| <p><code>objsubid</code> <code>int4</code></p><p>對於資料表欄位，這是欄位編號（<code>objid</code> 與 <code>classid</code> 參照資料表本身）。對於所有其他物件類型，此欄位為零。</p>                                                                           |
| <p><code>refclassid</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>oid</code>）</p><p>被參照物件所在之系統目錄的 OID（必須是共享系統目錄）</p> |
| <p><code>refobjid</code> <code>oid</code> （參照任何 OID 欄位）</p><p>特定被參照物件的 OID</p>                                                                                                                                     |
| <p><code>deptype</code> <code>char</code></p><p>定義此相依關係特定語意的代碼；請參閱正文</p>                                                                                                                                           |

<br>

在所有情況下，`pg_shdepend` 項目都表示：若不同時刪除相依物件，就無法刪除被參照物件。不過，`deptype` 還區分出數種子類型：

`SHARED_DEPENDENCY_OWNER` (`o`) : 被參照物件（必須是角色）是相依物件的擁有者。

`SHARED_DEPENDENCY_ACL` (`a`) : 被參照物件（必須是角色）出現在相依物件的 ACL 中。（不會為物件的擁有者建立 `SHARED_DEPENDENCY_ACL` 項目，因為擁有者無論如何都會有一筆 `SHARED_DEPENDENCY_OWNER` 項目。）

`SHARED_DEPENDENCY_INITACL` (`i`) : 被參照物件（必須是角色）出現在相依物件的某筆 [`pg_init_privs`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-init-privs.md) 項目中。

`SHARED_DEPENDENCY_POLICY` (`r`) : 被參照物件（必須是角色）被列為某個相依政策物件的目標。

`SHARED_DEPENDENCY_TABLESPACE` (`t`) : 被參照物件（必須是資料表空間）被列為某個沒有實體儲存之關聯的資料表空間。

未來可能需要其他相依類型。特別要注意，目前的定義只支援以角色與資料表空間作為被參照物件。

與 `pg_depend` 系統目錄相同，大多數在 initdb 期間建立的物件都被視為「釘住」（pinned）的物件。`pg_shdepend` 中不會建立任何以釘住物件作為被參照物件或相依物件的項目。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/catalog-pg-shdepend.html)（原文版本：18.6；核對日期：2026-10-17）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-shdepend.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
