_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › PostgreSQL

Contents



CREATE TABLE capitals (
	name text,
	population real,
	altitude int, -- (in ft)
	state char(2)
);

CREATE TABLE non_capitals (
	name text,
	population real,
	altitude int -- (in ft)
);

企 襷れ れ螻 螳 觀磯ゼ 襷る 覈 蟆郁骸襯 覲 .

CREATE VIEW cities AS
	SELECT name, population, altitude FROM capitals
	UNION
	SELECT name, population, altitude FROM non_capitals;

PostgreSQL 螳ロ. 蠏碁覩襦 れ螻 螳 螳ロ.

讒...
!!
覃伎殊 危願 螳讌 轟 襭襯 谿場覲企 豢 危願 螳.

SELECT name, altitude
FROM cities
WHERE altitude > 500;

which returns: 

   name    | altitude
-----------+----------
 Las Vegas |     2174
 Mariposa  |     1953
 Madison   |      845

(3 rows)

貎朱Μ altitude螳 500覲企 蟆 螳語殊企. 願 capitals 企 蟆 蟾讌 覈 螳語. 讀, WHERE altitude > 500 譟郁唄 cities 企襷 牛る 蟆企. 蠏碁覩襦 capitals 企 譟郁唄 蟆企 襷谿螳讌 企襦 螳 る 蟆企. 襷 cities 企 蟆襷 螳語り 矩る FROM Only れ襯 覃 .

SELECT name, altitude
FROM ONLY cities
WHERE altitude > 500;

   name    | altitude
-----------+----------
 Las Vegas |     2174
 Mariposa  |     1953

(2 rows)

CREATE TABLE city (
	name text,
	population real,
	altitude int -- (in ft)
);

CREATE TABLE capitals (
	state char(2)
) INHERITS (city);


insert into capitals(name, population, altitude, state) values('Las Vegas', 1234, 2174, 'LA');
insert into capitals(name, population, altitude, state) values('Las Vegas', 1234, 1953, 'SA');
insert into capitals(name, population, altitude, state) values('Las Vegas', 1234, 845, 'SA');

Pervasive Demo DB=>  SELECT name, altitude
Pervasive Demo DB->    FROM city
Pervasive Demo DB->    WHERE altitude > 500;
   name    | altitude
-----------+----------
 Las Vegas |     2174
 Las Vegas |     1953
 Las Vegas |      845
(3 rows)

Pervasive Demo DB=> select name, altitude
Pervasive Demo DB-> from only city
Pervasive Demo DB-> where altitude > 500;
 name | altitude
------+----------
(0 rows)

Pervasive Demo DB=> select * from only city;
 name | population | altitude
------+------------+----------
(0 rows)

Pervasive Demo DB=> select * from city;
   name    | population | altitude
-----------+------------+----------
 Las Vegas |       1234 |     2174
 Las Vegas |       1234 |     1953
 Las Vegas |       1234 |      845
(3 rows)

Pervasive Demo DB=> select * from altitude;
ERROR:  relation "altitude" does not exist
Pervasive Demo DB=> select * from capitals;
   name    | population | altitude | state
-----------+------------+----------+-------
 Las Vegas |       1234 |     2174 | LA
 Las Vegas |       1234 |     1953 | SA
 Las Vegas |       1234 |      845 | SA
(3 rows)

Pervasive Demo DB=>
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

螳 蟆 蠍 螻 豺伎 蟆企.