PostgreSQL 覆盖继承的列

Gau*_*nia 5 database postgresql

假设我有一个 xmldoc 关系,如下所示:

   Column     |            Type             | Modifiers                          
--------------+-----------------------------+-----------------
docid         | integer                     | not null  
create_date   | timestamp without time zone | not null 
type          | text                        | not null
xml           | xml                         | 
Run Code Online (Sandbox Code Playgroud)

现在,假设我创建了另一个表,该表仅从该表继承而没有任何其他列。例如,我如何将“xml”覆盖为“text”类型?

目前,我得到:

ERROR:  cannot alter inherited column "xml"
Run Code Online (Sandbox Code Playgroud)

那么,数据库继承中的覆盖是如何工作的呢?[具体来说,我使用的是 PostgreSQL 8.3]

mu *_*ort 5

来自精美手册

如果新表的列名列表包含一个也是继承的列名,则数据类型也必须与继承的列匹配,并且列定义合并为一个。

所以你不能重写xml为 type text。至于“数据库继承中的覆盖如何工作?” 是的,它没有,您不能通过这样的继承来更改接口(即列),您只能添加新内容或收紧约束。

你熟悉里氏代换原理吗?更改列类型会使表的公共属性(AKA 接口)不兼容。