Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c9ff1a5a
Commit
c9ff1a5a
authored
Aug 08, 1999
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update references to char2 type by using char(2).
Thanks to Garr Updegraff <garru@uci.edu> for the tip.
parent
f11bdb9d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
301 additions
and
251 deletions
+301
-251
doc/src/sgml/advanced.sgml
doc/src/sgml/advanced.sgml
+222
-192
doc/src/sgml/inherit.sgml
doc/src/sgml/inherit.sgml
+71
-51
doc/src/sgml/libpq++.sgml
doc/src/sgml/libpq++.sgml
+8
-8
No files found.
doc/src/sgml/advanced.sgml
View file @
c9ff1a5a
This diff is collapsed.
Click to expand it.
doc/src/sgml/inherit.sgml
View file @
c9ff1a5a
<Chapter I
d="inherit">
<Title>Inheritance</T
itle>
<chapter i
d="inherit">
<title>Inheritance</t
itle>
<P
ara>
Let's create two classes. The capitals class contains
state capitals which are also cities. Naturally, the
capitals class should inherit from cities.
<ProgramL
isting>
<p
ara>
Let's create two classes. The capitals class contains
state capitals which are also cities. Naturally, the
capitals class should inherit from cities.
<programl
isting>
CREATE TABLE cities (
name text,
population float,
altitude int
-- (in ft)
altitude int -- (in ft)
);
CREATE TABLE capitals (
state char
2
state char
(2)
) INHERITS (cities);
</ProgramListing>
</programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all
attributes (name, population, and altitude) from its
parent, cities. The type of the attribute name is
<type>text</type>, a native <productname>Postgres</productname> type for variable length
ASCII strings. The type of the attribute population is
<type>float</type>, a native <productname>Postgres</productname> type for double precision
floating point numbers. State capitals have an extra
attribute, state, that shows their state. In <productname>Postgres</productname>,
a class can inherit from zero or more other classes,
and a query can reference either all instances of a
class or all instances of a class plus all of its
descendants.
<note>
<para>
The inheritance hierarchy is a actually a directed acyclic graph.
</para>
</note>
In this case, an instance of capitals <FirstTerm>inherits</FirstTerm> all
attributes (name, population, and altitude) from its
parent, cities. The type of the attribute name is
<Type>text</Type>, a native <ProductName>Postgres</ProductName> type for variable length
ASCII strings. The type of the attribute population is
<Type>float</Type>, a native <ProductName>Postgres</ProductName> type for double precision
floating point numbers. State capitals have an extra
attribute, state, that shows their state. In <ProductName>Postgres</ProductName>,
a class can inherit from zero or more other classes,
and a query can reference either all instances of a
class or all instances of a class plus all of its
descendants.
<Note>
<Para>
The inheritance hierarchy is a actually a directed acyclic graph.
</Para>
</Note>
For example, the following query finds
all the cities that are situated at an attitude of 500ft or higher:
<ProgramListing>
For example, the following query finds
all the cities that are situated at an attitude of 500ft or higher:
<programlisting>
SELECT name, altitude
FROM cities
WHERE altitude > 500;
...
...
@@ -50,23 +52,23 @@ SELECT name, altitude
+----------+----------+
|Mariposa | 1953 |
+----------+----------+
</ProgramL
isting>
</para>
</programl
isting>
</para>
<P
ara>
On the other hand, to find the names of all cities,
including state capitals, that are located at an altitude
over 500ft, the query is:
<p
ara>
On the other hand, to find the names of all cities,
including state capitals, that are located at an altitude
over 500ft, the query is:
<ProgramL
isting>
<programl
isting>
SELECT c.name, c.altitude
FROM cities* c
WHERE c.altitude > 500;
</ProgramListing>
</programlisting>
which returns:
which returns:
<ProgramListing>
<programlisting>
+----------+----------+
|name | altitude |
+----------+----------+
...
...
@@ -76,13 +78,31 @@ SELECT c.name, c.altitude
+----------+----------+
|Madison | 845 |
+----------+----------+
</ProgramL
isting>
</programl
isting>
Here the <Quote>*</Quote> after cities indicates that the query should
be run over cities and all classes below cities in the
inheritance hierarchy. Many of the commands that we
have already discussed -- <Command>select</Command>, <Command>update</Command> and <Command>delete</Command> --
support this <Quote>*</Quote> notation, as do others, like <Command>alter</Command>.
</Para>
Here the <quote>*</quote> after cities indicates that the query should
be run over cities and all classes below cities in the
inheritance hierarchy. Many of the commands that we
have already discussed -- <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command> --
support this <quote>*</quote> notation, as do others, like
<command>ALTER TABLE</command>.
</para>
</chapter>
</Chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
doc/src/sgml/libpq++.sgml
View file @
c9ff1a5a
...
...
@@ -737,14 +737,14 @@
As an example:
<programlisting>
PgDatabase data;
data.Exec("create table foo (a int4, b char16
, d float8)");
data.Exec("copy foo from stdin");
data.putline("3\etHello World\et4.5\en");
data.putline("4\etGoodbye World\et7.11\en");
&...
data.putline(".\en");
data.endcopy();
PgDatabase data;
data.Exec("create table foo (a int4, b char(16)
, d float8)");
data.Exec("copy foo from stdin");
data.putline("3\etHello World\et4.5\en");
data.putline("4\etGoodbye World\et7.11\en");
&...
data.putline(".\en");
data.endcopy();
</programlisting>
</para>
</sect1>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment