PostgreSQL 常见操作
发布时间:2020-12-13 17:50:56 所属栏目:百科 来源:网络整理
导读:1、在命令行登录指定数据库 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
1、在命令行登录指定数据库
2、创建表 CREATE TABLE weather ( city varchar(80),temp_lo int,-- low temperature temp_hi int,-- high temperature prcp real,-- precipitation date date );PostgreSQL 的注释是:-- MySQL 的注释是:# 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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |