Postgresql中的“后代表”是什么?

Postgresql中的“后代表”是什么?,第1张

概述Postgresql的数据库转储使用ALTER TABLE ONLY tablename而不是我熟悉的ALTER TABLE tablename.我很好奇ONLY关键字的作用,所以我在 Postgresql documentation中查找了它,它说如下: name The name (optionally schema-qualified) of an existing table to alt Postgresql的数据库转储使用ALTER table ONLY tablename而不是我熟悉的ALTER table tablename.我很好奇ONLY关键字的作用,所以我在 Postgresql documentation中查找了它,它说如下:

name

The name (optionally schema-qualifIEd) of an existing table to alter. If ONLY is specifIEd before the table name,only that table is altered. If ONLY is not specifIEd,the table and all its descendant tables (if any) are altered. Optionally,* can be specifIEd after the table name to explicitly indicate that descendant tables are included.

什么是后代表

解决方法

Postgresql implements table inheritance,which can be a useful tool
for database designers. (sql:1999 and later define a type inheritance
feature,which differs in many respects from the features described
here.)

Let’s start with an example: suppose we are trying to build a data
model for citIEs. Each state has many citIEs,but only one cAPItal. We
want to be able to quickly retrIEve the cAPItal city for any
particular state. This can be done by creating two tables,one for
state cAPItals and one for citIEs that are not cAPItals. However,what
happens when we want to ask for data about a city,regardless of
whether it is a cAPItal or not? The inheritance feature can help to
resolve this problem. We define the cAPItals table so that it inherits
from citIEs:

CREATE table citIEs (    name            text,population      float,altitude        int     -- in feet);CREATE table cAPItals (    state           char(2)) inheritS (citIEs);@H_502_43@  

In this case,the cAPItals table inherits all the columns of its
parent table,citIEs. State cAPItals also have an extra column,state,
that shows their state.

In Postgresql,a table can inherit from zero or more other tables,and
a query can reference either all rows of a table or all rows of a
table plus all of its descendant tables. The latter behavior is the
default.

资料来源:https://www.postgresql.org/docs/8.4/static/ddl-inherit.html

总结

以上是内存溢出为你收集整理的Postgresql中的“后代表”是什么?全部内容,希望文章能够帮你解决Postgresql中的“后代表”是什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1161761.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存