2、创建表
CREATE TABLE weather ( city varchar(80),temp_lo int,-- low temperature temp_hi int,-- high temperature prcp real,-- precipitation date date );Postgresql 的注释是:--
MysqL 的注释是:#
3、表的继承
CREATE TABLE cities ( name text,population real,altitude int -- (in ft) ); CREATE TABLE capitals ( state char(2) ) INHERITS (cities);指定“父表”——查询“父表”和“字表”:
SELECT name,altitude FROM cities WHERE altitude > 500; name | altitude -----------+---------- Las Vegas | 2174 Mariposa | 1953 Madison | 845 (3 rows)ONLY 加“父表”——只查询父表
SELECT name,altitude FROM ONLY cities WHERE altitude > 500; name | altitude -----------+---------- Las Vegas | 2174 Mariposa | 1953 (2 rows)