Fix up typos.
Move "query result" tables to left side of page (remove leading spaces).
This commit is contained in:
parent
ff7b9f5541
commit
ee7f92b76b
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.9 2000/05/02 20:01:52 thomas Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.10 2000/06/14 13:10:48 thomas Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<chapter id="sql">
|
<chapter id="sql">
|
||||||
@ -155,20 +155,22 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.9 2000/05/02 20:01:52 thomas E
|
|||||||
<example>
|
<example>
|
||||||
<title id="supplier-fig">The Suppliers and Parts Database</title>
|
<title id="supplier-fig">The Suppliers and Parts Database</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SUPPLIER SNO | SNAME | CITY SELLS SNO | PNO
|
SUPPLIER: SELLS:
|
||||||
-----+---------+-------- -----+-----
|
SNO | SNAME | CITY SNO | PNO
|
||||||
1 | Smith | London 1 | 1
|
----+---------+-------- -----+-----
|
||||||
2 | Jones | Paris 1 | 2
|
1 | Smith | London 1 | 1
|
||||||
3 | Adams | Vienna 2 | 4
|
2 | Jones | Paris 1 | 2
|
||||||
4 | Blake | Rome 3 | 1
|
3 | Adams | Vienna 2 | 4
|
||||||
3 | 3
|
4 | Blake | Rome 3 | 1
|
||||||
4 | 2
|
3 | 3
|
||||||
PART PNO | PNAME | PRICE 4 | 3
|
4 | 2
|
||||||
-----+---------+--------- 4 | 4
|
PART: 4 | 3
|
||||||
1 | Screw | 10
|
PNO | PNAME | PRICE 4 | 4
|
||||||
2 | Nut | 8
|
----+---------+---------
|
||||||
3 | Bolt | 15
|
1 | Screw | 10
|
||||||
4 | Cam | 25
|
2 | Nut | 8
|
||||||
|
3 | Bolt | 15
|
||||||
|
4 | Cam | 25
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</para>
|
</para>
|
||||||
@ -474,7 +476,7 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
INTERSECT (∩): builds the set-theoretic intersection of two
|
INTERSECT (∩): builds the set-theoretic intersection of two
|
||||||
tables. Given the tables <classname>R</classname> and
|
tables. Given the tables <classname>R</classname> and
|
||||||
<classname>S</classname>,
|
<classname>S</classname>,
|
||||||
<classname>R</classname> ∪ <classname>S</classname> is the
|
<classname>R</classname> ∩ <classname>S</classname> is the
|
||||||
set of tuples
|
set of tuples
|
||||||
that are in <classname>R</classname> and in
|
that are in <classname>R</classname> and in
|
||||||
<classname>S</classname>.
|
<classname>S</classname>.
|
||||||
@ -532,11 +534,12 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
Let the following two tables be given:
|
Let the following two tables be given:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
R A | B | C S C | D | E
|
R: S:
|
||||||
---+---+--- ---+---+---
|
A | B | C C | D | E
|
||||||
1 | 2 | 3 3 | a | b
|
---+---+--- ---+---+---
|
||||||
4 | 5 | 6 6 | c | d
|
1 | 2 | 3 3 | a | b
|
||||||
7 | 8 | 9
|
4 | 5 | 6 6 | c | d
|
||||||
|
7 | 8 | 9
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
@ -547,14 +550,15 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
get:
|
get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
R x S A | B | R.C | S.C | D | E
|
R x S:
|
||||||
---+---+-----+-----+---+---
|
A | B | R.C | S.C | D | E
|
||||||
1 | 2 | 3 | 3 | a | b
|
---+---+-----+-----+---+---
|
||||||
1 | 2 | 3 | 6 | c | d
|
1 | 2 | 3 | 3 | a | b
|
||||||
4 | 5 | 6 | 3 | a | b
|
1 | 2 | 3 | 6 | c | d
|
||||||
4 | 5 | 6 | 6 | c | d
|
4 | 5 | 6 | 3 | a | b
|
||||||
7 | 8 | 9 | 3 | a | b
|
4 | 5 | 6 | 6 | c | d
|
||||||
7 | 8 | 9 | 6 | c | d
|
7 | 8 | 9 | 3 | a | b
|
||||||
|
7 | 8 | 9 | 6 | c | d
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -564,10 +568,10 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
we get:
|
we get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
A | B | R.C | S.C | D | E
|
A | B | R.C | S.C | D | E
|
||||||
---+---+-----+-----+---+---
|
---+---+-----+-----+---+---
|
||||||
1 | 2 | 3 | 3 | a | b
|
1 | 2 | 3 | 3 | a | b
|
||||||
4 | 5 | 6 | 6 | c | d
|
4 | 5 | 6 | 6 | c | d
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -579,10 +583,10 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
and get:
|
and get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
A | B | C | D | E
|
A | B | C | D | E
|
||||||
---+---+---+---+---
|
---+---+---+---+---
|
||||||
1 | 2 | 3 | a | b
|
1 | 2 | 3 | a | b
|
||||||
4 | 5 | 6 | c | d
|
4 | 5 | 6 | c | d
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -595,8 +599,9 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
C and D.
|
C and D.
|
||||||
Then we define the division as:
|
Then we define the division as:
|
||||||
|
|
||||||
R ÷ S = {t ∣ ∀ t<subscript>s</subscript> ∈ S
|
<programlisting>
|
||||||
∃ t<subscript>r</subscript> ∈ R
|
R ÷ S = {t ∣ ∀ t<subscript>s</subscript> ∈ S ∃ t<subscript>r</subscript> ∈ R
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
such that
|
such that
|
||||||
t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>s</subscript>}
|
t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>s</subscript>}
|
||||||
@ -614,24 +619,25 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
Given the following tables
|
Given the following tables
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
R A | B | C | D S C | D
|
R: S:
|
||||||
---+---+---+--- ---+---
|
A | B | C | D C | D
|
||||||
a | b | c | d c | d
|
---+---+---+--- ---+---
|
||||||
a | b | e | f e | f
|
a | b | c | d c | d
|
||||||
b | c | e | f
|
a | b | e | f e | f
|
||||||
e | d | c | d
|
b | c | e | f
|
||||||
e | d | e | f
|
e | d | c | d
|
||||||
a | b | d | e
|
e | d | e | f
|
||||||
|
a | b | d | e
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
R ÷ S
|
R ÷ S
|
||||||
is derived as
|
is derived as
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
A | B
|
A | B
|
||||||
---+---
|
---+---
|
||||||
a | b
|
a | b
|
||||||
e | d
|
e | d
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -668,10 +674,10 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
we will obtain the following result:
|
we will obtain the following result:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNAME
|
SNAME
|
||||||
-------
|
-------
|
||||||
Smith
|
Smith
|
||||||
Adams
|
Adams
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
@ -720,7 +726,10 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
<para>
|
<para>
|
||||||
The queries used in <acronym>TRC</acronym> are of the following
|
The queries used in <acronym>TRC</acronym> are of the following
|
||||||
form:
|
form:
|
||||||
x(A) ∣ F(x)
|
|
||||||
|
<programlisting>
|
||||||
|
x(A) ∣ F(x)
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
where <literal>x</literal> is a tuple variable
|
where <literal>x</literal> is a tuple variable
|
||||||
<classname>A</classname> is a set of attributes and <literal>F</literal> is a
|
<classname>A</classname> is a set of attributes and <literal>F</literal> is a
|
||||||
@ -733,11 +742,11 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
<xref linkend="suppl-rel-alg" endterm="suppl-rel-alg">
|
<xref linkend="suppl-rel-alg" endterm="suppl-rel-alg">
|
||||||
using <acronym>TRC</acronym> we formulate the following query:
|
using <acronym>TRC</acronym> we formulate the following query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{x(SNAME) ∣ x ∈ SUPPLIER ∧ \nonumber
|
{x(SNAME) ∣ x ∈ SUPPLIER ∧
|
||||||
∃ y ∈ SELLS ∃ z ∈ PART (y(SNO)=x(SNO) ∧ \nonumber
|
∃ y ∈ SELLS ∃ z ∈ PART (y(SNO)=x(SNO) ∧
|
||||||
z(PNO)=y(PNO) ∧ \nonumber
|
z(PNO)=y(PNO) ∧
|
||||||
z(PNAME)='Screw')} \nonumber
|
z(PNAME)='Screw')}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -806,7 +815,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
to involve
|
to involve
|
||||||
arithmetic operations as well as comparisons, e.g.
|
arithmetic operations as well as comparisons, e.g.
|
||||||
|
|
||||||
A < B + 3.
|
<programlisting>
|
||||||
|
A < B + 3.
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
Note
|
Note
|
||||||
that + or other arithmetic operators appear neither in relational
|
that + or other arithmetic operators appear neither in relational
|
||||||
@ -843,17 +854,17 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
used to retrieve data. The syntax is:
|
used to retrieve data. The syntax is:
|
||||||
|
|
||||||
<synopsis>
|
<synopsis>
|
||||||
SELECT [ALL|DISTINCT]
|
SELECT [ALL|DISTINCT]
|
||||||
{ * | <replaceable class="parameter">expr_1</replaceable> [AS <replaceable class="parameter">c_alias_1</replaceable>] [, ...
|
{ * | <replaceable class="parameter">expr_1</replaceable> [AS <replaceable class="parameter">c_alias_1</replaceable>] [, ...
|
||||||
[, <replaceable class="parameter">expr_k</replaceable> [AS <replaceable class="parameter">c_alias_k</replaceable>]]]}
|
[, <replaceable class="parameter">expr_k</replaceable> [AS <replaceable class="parameter">c_alias_k</replaceable>]]]}
|
||||||
FROM <replaceable class="parameter">table_name_1</replaceable> [<replaceable class="parameter">t_alias_1</replaceable>]
|
FROM <replaceable class="parameter">table_name_1</replaceable> [<replaceable class="parameter">t_alias_1</replaceable>]
|
||||||
[, ... [, <replaceable class="parameter">table_name_n</replaceable> [<replaceable class="parameter">t_alias_n</replaceable>]]]
|
[, ... [, <replaceable class="parameter">table_name_n</replaceable> [<replaceable class="parameter">t_alias_n</replaceable>]]]
|
||||||
[WHERE <replaceable class="parameter">condition</replaceable>]
|
[WHERE <replaceable class="parameter">condition</replaceable>]
|
||||||
[GROUP BY <replaceable class="parameter">name_of_attr_i</replaceable>
|
[GROUP BY <replaceable class="parameter">name_of_attr_i</replaceable>
|
||||||
[,... [, <replaceable class="parameter">name_of_attr_j</replaceable>]] [HAVING <replaceable class="parameter">condition</replaceable>]]
|
[,... [, <replaceable class="parameter">name_of_attr_j</replaceable>]] [HAVING <replaceable class="parameter">condition</replaceable>]]
|
||||||
[{UNION [ALL] | INTERSECT | EXCEPT} SELECT ...]
|
[{UNION [ALL] | INTERSECT | EXCEPT} SELECT ...]
|
||||||
[ORDER BY <replaceable class="parameter">name_of_attr_i</replaceable> [ASC|DESC]
|
[ORDER BY <replaceable class="parameter">name_of_attr_i</replaceable> [ASC|DESC]
|
||||||
[, ... [, <replaceable class="parameter">name_of_attr_j</replaceable> [ASC|DESC]]]];
|
[, ... [, <replaceable class="parameter">name_of_attr_j</replaceable> [ASC|DESC]]]];
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -876,17 +887,17 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
greater than 10 we formulate the following query:
|
greater than 10 we formulate the following query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT * FROM PART
|
SELECT * FROM PART
|
||||||
WHERE PRICE > 10;
|
WHERE PRICE > 10;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
and get the table:
|
and get the table:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
PNO | PNAME | PRICE
|
PNO | PNAME | PRICE
|
||||||
-----+---------+--------
|
-----+---------+--------
|
||||||
3 | Bolt | 15
|
3 | Bolt | 15
|
||||||
4 | Cam | 25
|
4 | Cam | 25
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -896,9 +907,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
from table PART we use the statement:
|
from table PART we use the statement:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT PNAME, PRICE
|
SELECT PNAME, PRICE
|
||||||
FROM PART
|
FROM PART
|
||||||
WHERE PRICE > 10;
|
WHERE PRICE > 10;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
In this case the result is:
|
In this case the result is:
|
||||||
@ -920,18 +931,18 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
using the keywords OR, AND, and NOT:
|
using the keywords OR, AND, and NOT:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT PNAME, PRICE
|
SELECT PNAME, PRICE
|
||||||
FROM PART
|
FROM PART
|
||||||
WHERE PNAME = 'Bolt' AND
|
WHERE PNAME = 'Bolt' AND
|
||||||
(PRICE = 0 OR PRICE < 15);
|
(PRICE = 0 OR PRICE < 15);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
will lead to the result:
|
will lead to the result:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
PNAME | PRICE
|
PNAME | PRICE
|
||||||
--------+--------
|
--------+--------
|
||||||
Bolt | 15
|
Bolt | 15
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -941,19 +952,19 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
take two pieces of a part we could use the following query:
|
take two pieces of a part we could use the following query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT PNAME, PRICE * 2 AS DOUBLE
|
SELECT PNAME, PRICE * 2 AS DOUBLE
|
||||||
FROM PART
|
FROM PART
|
||||||
WHERE PRICE * 2 < 50;
|
WHERE PRICE * 2 < 50;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
and we get:
|
and we get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
PNAME | DOUBLE
|
PNAME | DOUBLE
|
||||||
--------+---------
|
--------+---------
|
||||||
Screw | 20
|
Screw | 20
|
||||||
Nut | 16
|
Nut | 16
|
||||||
Bolt | 30
|
Bolt | 30
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
Note that the word DOUBLE after the keyword AS is the new title of the
|
Note that the word DOUBLE after the keyword AS is the new title of the
|
||||||
@ -980,25 +991,25 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
attributes we formulate the following statement:
|
attributes we formulate the following statement:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT S.SNAME, P.PNAME
|
SELECT S.SNAME, P.PNAME
|
||||||
FROM SUPPLIER S, PART P, SELLS SE
|
FROM SUPPLIER S, PART P, SELLS SE
|
||||||
WHERE S.SNO = SE.SNO AND
|
WHERE S.SNO = SE.SNO AND
|
||||||
P.PNO = SE.PNO;
|
P.PNO = SE.PNO;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
and get the following table as a result:
|
and get the following table as a result:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNAME | PNAME
|
SNAME | PNAME
|
||||||
-------+-------
|
-------+-------
|
||||||
Smith | Screw
|
Smith | Screw
|
||||||
Smith | Nut
|
Smith | Nut
|
||||||
Jones | Cam
|
Jones | Cam
|
||||||
Adams | Screw
|
Adams | Screw
|
||||||
Adams | Bolt
|
Adams | Bolt
|
||||||
Blake | Nut
|
Blake | Nut
|
||||||
Blake | Bolt
|
Blake | Bolt
|
||||||
Blake | Cam
|
Blake | Cam
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1040,8 +1051,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
the following query:
|
the following query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT AVG(PRICE) AS AVG_PRICE
|
SELECT AVG(PRICE) AS AVG_PRICE
|
||||||
FROM PART;
|
FROM PART;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1049,9 +1060,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
The result is:
|
The result is:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
AVG_PRICE
|
AVG_PRICE
|
||||||
-----------
|
-----------
|
||||||
14.5
|
14.5
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1060,16 +1071,16 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
the statement:
|
the statement:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT COUNT(PNO)
|
SELECT COUNT(PNO)
|
||||||
FROM PART;
|
FROM PART;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
and get:
|
and get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
COUNT
|
COUNT
|
||||||
-------
|
-------
|
||||||
4
|
4
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
@ -1108,21 +1119,21 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
formulate the query:
|
formulate the query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
|
SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
|
||||||
FROM SUPPLIER S, SELLS SE
|
FROM SUPPLIER S, SELLS SE
|
||||||
WHERE S.SNO = SE.SNO
|
WHERE S.SNO = SE.SNO
|
||||||
GROUP BY S.SNO, S.SNAME;
|
GROUP BY S.SNO, S.SNAME;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
and get:
|
and get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNO | SNAME | COUNT
|
SNO | SNAME | COUNT
|
||||||
-----+-------+-------
|
-----+-------+-------
|
||||||
1 | Smith | 2
|
1 | Smith | 2
|
||||||
2 | Jones | 1
|
2 | Jones | 1
|
||||||
3 | Adams | 2
|
3 | Adams | 2
|
||||||
4 | Blake | 3
|
4 | Blake | 3
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1132,16 +1143,16 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
tables SUPPLIER and SELLS is derived:
|
tables SUPPLIER and SELLS is derived:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
S.SNO | S.SNAME | SE.PNO
|
S.SNO | S.SNAME | SE.PNO
|
||||||
-------+---------+--------
|
-------+---------+--------
|
||||||
1 | Smith | 1
|
1 | Smith | 1
|
||||||
1 | Smith | 2
|
1 | Smith | 2
|
||||||
2 | Jones | 4
|
2 | Jones | 4
|
||||||
3 | Adams | 1
|
3 | Adams | 1
|
||||||
3 | Adams | 3
|
3 | Adams | 3
|
||||||
4 | Blake | 2
|
4 | Blake | 2
|
||||||
4 | Blake | 3
|
4 | Blake | 3
|
||||||
4 | Blake | 4
|
4 | Blake | 4
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1150,19 +1161,19 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
together that agree on both attributes S.SNO and S.SNAME:
|
together that agree on both attributes S.SNO and S.SNAME:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
S.SNO | S.SNAME | SE.PNO
|
S.SNO | S.SNAME | SE.PNO
|
||||||
-------+---------+--------
|
-------+---------+--------
|
||||||
1 | Smith | 1
|
1 | Smith | 1
|
||||||
| 2
|
| 2
|
||||||
--------------------------
|
--------------------------
|
||||||
2 | Jones | 4
|
2 | Jones | 4
|
||||||
--------------------------
|
--------------------------
|
||||||
3 | Adams | 1
|
3 | Adams | 1
|
||||||
| 3
|
| 3
|
||||||
--------------------------
|
--------------------------
|
||||||
4 | Blake | 2
|
4 | Blake | 2
|
||||||
| 3
|
| 3
|
||||||
| 4
|
| 4
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1204,21 +1215,21 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
query:
|
query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
|
SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
|
||||||
FROM SUPPLIER S, SELLS SE
|
FROM SUPPLIER S, SELLS SE
|
||||||
WHERE S.SNO = SE.SNO
|
WHERE S.SNO = SE.SNO
|
||||||
GROUP BY S.SNO, S.SNAME
|
GROUP BY S.SNO, S.SNAME
|
||||||
HAVING COUNT(SE.PNO) > 1;
|
HAVING COUNT(SE.PNO) > 1;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
and get:
|
and get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNO | SNAME | COUNT
|
SNO | SNAME | COUNT
|
||||||
-----+-------+-------
|
-----+-------+-------
|
||||||
1 | Smith | 2
|
1 | Smith | 2
|
||||||
3 | Adams | 2
|
3 | Adams | 2
|
||||||
4 | Blake | 3
|
4 | Blake | 3
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
@ -1243,10 +1254,10 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
named 'Screw' we use the query:
|
named 'Screw' we use the query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM PART
|
FROM PART
|
||||||
WHERE PRICE > (SELECT PRICE FROM PART
|
WHERE PRICE > (SELECT PRICE FROM PART
|
||||||
WHERE PNAME='Screw');
|
WHERE PNAME='Screw');
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1254,10 +1265,10 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
The result is:
|
The result is:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
PNO | PNAME | PRICE
|
PNO | PNAME | PRICE
|
||||||
-----+---------+--------
|
-----+---------+--------
|
||||||
3 | Bolt | 15
|
3 | Bolt | 15
|
||||||
4 | Cam | 25
|
4 | Cam | 25
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1272,16 +1283,16 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
greater.
|
greater.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
If we want to know all suppliers that do not sell any part
|
If we want to know all suppliers that do not sell any part
|
||||||
(e.g. to be able to remove these suppliers from the database) we use:
|
(e.g. to be able to remove these suppliers from the database) we use:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM SUPPLIER S
|
FROM SUPPLIER S
|
||||||
WHERE NOT EXISTS
|
WHERE NOT EXISTS
|
||||||
(SELECT * FROM SELLS SE
|
(SELECT * FROM SELLS SE
|
||||||
WHERE SE.SNO = S.SNO);
|
WHERE SE.SNO = S.SNO);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1310,22 +1321,22 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
The following query is an example for UNION:
|
The following query is an example for UNION:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT S.SNO, S.SNAME, S.CITY
|
SELECT S.SNO, S.SNAME, S.CITY
|
||||||
FROM SUPPLIER S
|
FROM SUPPLIER S
|
||||||
WHERE S.SNAME = 'Jones'
|
WHERE S.SNAME = 'Jones'
|
||||||
UNION
|
UNION
|
||||||
SELECT S.SNO, S.SNAME, S.CITY
|
SELECT S.SNO, S.SNAME, S.CITY
|
||||||
FROM SUPPLIER S
|
FROM SUPPLIER S
|
||||||
WHERE S.SNAME = 'Adams';
|
WHERE S.SNAME = 'Adams';
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
gives the result:
|
gives the result:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNO | SNAME | CITY
|
SNO | SNAME | CITY
|
||||||
-----+-------+--------
|
-----+-------+--------
|
||||||
2 | Jones | Paris
|
2 | Jones | Paris
|
||||||
3 | Adams | Vienna
|
3 | Adams | Vienna
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1333,45 +1344,46 @@ gives the result:
|
|||||||
Here an example for INTERSECT:
|
Here an example for INTERSECT:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT S.SNO, S.SNAME, S.CITY
|
SELECT S.SNO, S.SNAME, S.CITY
|
||||||
FROM SUPPLIER S
|
FROM SUPPLIER S
|
||||||
WHERE S.SNO > 1
|
WHERE S.SNO > 1
|
||||||
INTERSECT
|
INTERSECT
|
||||||
SELECT S.SNO, S.SNAME, S.CITY
|
SELECT S.SNO, S.SNAME, S.CITY
|
||||||
FROM SUPPLIER S
|
FROM SUPPLIER S
|
||||||
WHERE S.SNO > 2;
|
WHERE S.SNO > 2;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
gives the result:
|
gives the result:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNO | SNAME | CITY
|
SNO | SNAME | CITY
|
||||||
-----+-------+--------
|
-----+-------+--------
|
||||||
2 | Jones | Paris
|
2 | Jones | Paris
|
||||||
The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
|
The only tuple returned by both parts of the query is the one having $SNO=2$.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Finally an example for EXCEPT:
|
Finally an example for EXCEPT:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT S.SNO, S.SNAME, S.CITY
|
SELECT S.SNO, S.SNAME, S.CITY
|
||||||
FROM SUPPLIER S
|
FROM SUPPLIER S
|
||||||
WHERE S.SNO > 1
|
WHERE S.SNO > 1
|
||||||
EXCEPT
|
EXCEPT
|
||||||
SELECT S.SNO, S.SNAME, S.CITY
|
SELECT S.SNO, S.SNAME, S.CITY
|
||||||
FROM SUPPLIER S
|
FROM SUPPLIER S
|
||||||
WHERE S.SNO > 3;
|
WHERE S.SNO > 3;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
gives the result:
|
gives the result:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNO | SNAME | CITY
|
SNO | SNAME | CITY
|
||||||
-----+-------+--------
|
-----+-------+--------
|
||||||
2 | Jones | Paris
|
2 | Jones | Paris
|
||||||
3 | Adams | Vienna
|
3 | Adams | Vienna
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
@ -1395,11 +1407,11 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
one that creates a new relation (a new table). The syntax of the
|
one that creates a new relation (a new table). The syntax of the
|
||||||
CREATE TABLE command is:
|
CREATE TABLE command is:
|
||||||
|
|
||||||
<synopsis>
|
<synopsis>
|
||||||
CREATE TABLE <replaceable class="parameter">table_name</replaceable>
|
CREATE TABLE <replaceable class="parameter">table_name</replaceable>
|
||||||
(<replaceable class="parameter">name_of_attr_1</replaceable> <replaceable class="parameter">type_of_attr_1</replaceable>
|
(<replaceable class="parameter">name_of_attr_1</replaceable> <replaceable class="parameter">type_of_attr_1</replaceable>
|
||||||
[, <replaceable class="parameter">name_of_attr_2</replaceable> <replaceable class="parameter">type_of_attr_2</replaceable>
|
[, <replaceable class="parameter">name_of_attr_2</replaceable> <replaceable class="parameter">type_of_attr_2</replaceable>
|
||||||
[, ...]]);
|
[, ...]]);
|
||||||
</synopsis>
|
</synopsis>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
@ -1411,23 +1423,23 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
following <acronym>SQL</acronym> statements are used:
|
following <acronym>SQL</acronym> statements are used:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE TABLE SUPPLIER
|
CREATE TABLE SUPPLIER
|
||||||
(SNO INTEGER,
|
(SNO INTEGER,
|
||||||
SNAME VARCHAR(20),
|
SNAME VARCHAR(20),
|
||||||
CITY VARCHAR(20));
|
CITY VARCHAR(20));
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE TABLE PART
|
CREATE TABLE PART
|
||||||
(PNO INTEGER,
|
(PNO INTEGER,
|
||||||
PNAME VARCHAR(20),
|
PNAME VARCHAR(20),
|
||||||
PRICE DECIMAL(4 , 2));
|
PRICE DECIMAL(4 , 2));
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE TABLE SELLS
|
CREATE TABLE SELLS
|
||||||
(SNO INTEGER,
|
(SNO INTEGER,
|
||||||
PNO INTEGER);
|
PNO INTEGER);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
@ -1463,7 +1475,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
<replaceable class="parameter">q</replaceable>
|
<replaceable class="parameter">q</replaceable>
|
||||||
of them right to the decimal point.
|
of them right to the decimal point.
|
||||||
|
|
||||||
(15 ≥ <replaceable class="parameter">p</replaceable> ≥ <replaceable class="parameter">q</replaceable>q ≥ 0).
|
(15 ≥ <replaceable class="parameter">p</replaceable> ≥ <replaceable class="parameter">q</replaceable> ≥ 0).
|
||||||
|
|
||||||
If <replaceable class="parameter">q</replaceable>
|
If <replaceable class="parameter">q</replaceable>
|
||||||
is omitted it is assumed to be 0.
|
is omitted it is assumed to be 0.
|
||||||
@ -1514,8 +1526,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
the CREATE INDEX command is used. The syntax is:
|
the CREATE INDEX command is used. The syntax is:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE INDEX <replaceable class="parameter">index_name</replaceable>
|
CREATE INDEX <replaceable class="parameter">index_name</replaceable>
|
||||||
ON <replaceable class="parameter">table_name</replaceable> ( <replaceable class="parameter">name_of_attribute</replaceable> );
|
ON <replaceable class="parameter">table_name</replaceable> ( <replaceable class="parameter">name_of_attribute</replaceable> );
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1528,8 +1540,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
we use the following statement:
|
we use the following statement:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE INDEX I
|
CREATE INDEX I ON SUPPLIER (SNAME);
|
||||||
ON SUPPLIER (SNAME);
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1578,8 +1589,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
is:
|
is:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE VIEW <replaceable class="parameter">view_name</replaceable>
|
CREATE VIEW <replaceable class="parameter">view_name</replaceable>
|
||||||
AS <replaceable class="parameter">select_stmt</replaceable>
|
AS <replaceable class="parameter">select_stmt</replaceable>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
where <replaceable class="parameter">select_stmt</replaceable>
|
where <replaceable class="parameter">select_stmt</replaceable>
|
||||||
@ -1597,12 +1608,12 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
<xref linkend="supplier-fig" endterm="supplier-fig"> again):
|
<xref linkend="supplier-fig" endterm="supplier-fig"> again):
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE VIEW London_Suppliers
|
CREATE VIEW London_Suppliers
|
||||||
AS SELECT S.SNAME, P.PNAME
|
AS SELECT S.SNAME, P.PNAME
|
||||||
FROM SUPPLIER S, PART P, SELLS SE
|
FROM SUPPLIER S, PART P, SELLS SE
|
||||||
WHERE S.SNO = SE.SNO AND
|
WHERE S.SNO = SE.SNO AND
|
||||||
P.PNO = SE.PNO AND
|
P.PNO = SE.PNO AND
|
||||||
S.CITY = 'London';
|
S.CITY = 'London';
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1612,17 +1623,16 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
if it were another base table:
|
if it were another base table:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT *
|
SELECT * FROM London_Suppliers
|
||||||
FROM London_Suppliers
|
WHERE P.PNAME = 'Screw';
|
||||||
WHERE P.PNAME = 'Screw';
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
which will return the following table:
|
which will return the following table:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SNAME | PNAME
|
SNAME | PNAME
|
||||||
-------+-------
|
-------+-------
|
||||||
Smith | Screw
|
Smith | Screw
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1646,7 +1656,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
DROP TABLE command is used:
|
DROP TABLE command is used:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
DROP TABLE <replaceable class="parameter">table_name</replaceable>;
|
DROP TABLE <replaceable class="parameter">table_name</replaceable>;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1654,7 +1664,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
To destroy the SUPPLIER table use the following statement:
|
To destroy the SUPPLIER table use the following statement:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
DROP TABLE SUPPLIER;
|
DROP TABLE SUPPLIER;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1662,7 +1672,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
The DROP INDEX command is used to destroy an index:
|
The DROP INDEX command is used to destroy an index:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
DROP INDEX <replaceable class="parameter">index_name</replaceable>;
|
DROP INDEX <replaceable class="parameter">index_name</replaceable>;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1670,7 +1680,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
Finally to destroy a given view use the command DROP VIEW:
|
Finally to destroy a given view use the command DROP VIEW:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
DROP VIEW <replaceable class="parameter">view_name</replaceable>;
|
DROP VIEW <replaceable class="parameter">view_name</replaceable>;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</sect3>
|
</sect3>
|
||||||
@ -1689,10 +1699,9 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
The syntax is:
|
The syntax is:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceable class="parameter">name_of_attr_1</replaceable>
|
INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceable class="parameter">name_of_attr_1</replaceable>
|
||||||
[, <replaceable class="parameter">name_of_attr_2</replaceable> [,...]])
|
[, <replaceable class="parameter">name_of_attr_2</replaceable> [,...]])
|
||||||
VALUES (<replaceable class="parameter">val_attr_1</replaceable>
|
VALUES (<replaceable class="parameter">val_attr_1</replaceable> [, <replaceable class="parameter">val_attr_2</replaceable> [, ...]]);
|
||||||
[, <replaceable class="parameter">val_attr_2</replaceable> [, ...]]);
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1702,8 +1711,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
following statement:
|
following statement:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
INSERT INTO SUPPLIER (SNO, SNAME, CITY)
|
INSERT INTO SUPPLIER (SNO, SNAME, CITY)
|
||||||
VALUES (1, 'Smith', 'London');
|
VALUES (1, 'Smith', 'London');
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1711,8 +1720,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
To insert the first tuple into the relation SELLS we use:
|
To insert the first tuple into the relation SELLS we use:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
INSERT INTO SELLS (SNO, PNO)
|
INSERT INTO SELLS (SNO, PNO)
|
||||||
VALUES (1, 1);
|
VALUES (1, 1);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</sect3>
|
</sect3>
|
||||||
@ -1725,10 +1734,10 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
UPDATE command is used. The syntax is:
|
UPDATE command is used. The syntax is:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
UPDATE <replaceable class="parameter">table_name</replaceable>
|
UPDATE <replaceable class="parameter">table_name</replaceable>
|
||||||
SET <replaceable class="parameter">name_of_attr_1</replaceable> = <replaceable class="parameter">value_1</replaceable>
|
SET <replaceable class="parameter">name_of_attr_1</replaceable> = <replaceable class="parameter">value_1</replaceable>
|
||||||
[, ... [, <replaceable class="parameter">name_of_attr_k</replaceable> = <replaceable class="parameter">value_k</replaceable>]]
|
[, ... [, <replaceable class="parameter">name_of_attr_k</replaceable> = <replaceable class="parameter">value_k</replaceable>]]
|
||||||
WHERE <replaceable class="parameter">condition</replaceable>;
|
WHERE <replaceable class="parameter">condition</replaceable>;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1737,9 +1746,9 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
relation PART we use:
|
relation PART we use:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
UPDATE PART
|
UPDATE PART
|
||||||
SET PRICE = 15
|
SET PRICE = 15
|
||||||
WHERE PNAME = 'Screw';
|
WHERE PNAME = 'Screw';
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1757,8 +1766,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
FROM. The syntax is:
|
FROM. The syntax is:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
DELETE FROM <replaceable class="parameter">table_name</replaceable>
|
DELETE FROM <replaceable class="parameter">table_name</replaceable>
|
||||||
WHERE <replaceable class="parameter">condition</replaceable>;
|
WHERE <replaceable class="parameter">condition</replaceable>;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1767,8 +1776,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
following statement is used:
|
following statement is used:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
DELETE FROM SUPPLIER
|
DELETE FROM SUPPLIER
|
||||||
WHERE SNAME = 'Smith';
|
WHERE SNAME = 'Smith';
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</sect3>
|
</sect3>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user