有一个包含虚拟数据下载的Postgres数据库?优选罗斯文,这是我可以练习我的查询的想法

其他提示

我能够从下载罗斯文数据库(PostgreSQL的)

http://www.antepedia.com/detail/p/48023267.html

具体地

[弃用: http://northwindextended.googlecode.com/files/northwind.postgre.sql

[更新:2016年10月:] https://code.google.com/archive/p/northwindextended/downloads

装载/访问数据库:

sudo -u postgres psql     ## or: sudo su postgres

postgres=# \i northwind.postgre.sql;

postgres=# \d
                List of relations
 Schema |         Name         | Type  |  Owner   
--------+----------------------+-------+----------
 public | categories           | table | postgres
 public | customercustomerdemo | table | postgres
 public | customerdemographics | table | postgres
 public | customers            | table | postgres
 public | employees            | table | postgres
 public | employeeterritories  | table | postgres
 public | order_details        | table | postgres
 public | orders               | table | postgres
 public | products             | table | postgres
 public | region               | table | postgres
 public | shippers             | table | postgres
 public | shippers_tmp         | table | postgres
 public | suppliers            | table | postgres
 public | territories          | table | postgres
 public | usstates             | table | postgres
(15 rows)

postgres=# \d customers;
             Table "public.customers"
    Column    |         Type          | Modifiers 
--------------+-----------------------+-----------
 CustomerID   | bpchar                | not null
 CompanyName  | character varying(40) | not null
 ContactName  | character varying(30) | 
 ContactTitle | character varying(30) | 
 Address      | character varying(60) | 
 City         | character varying(15) | 
 Region       | character varying(15) | 
 PostalCode   | character varying(10) | 
 Country      | character varying(15) | 
 Phone        | character varying(24) | 
 Fax          | character varying(24) | 
Indexes:
    "pk_customers" PRIMARY KEY, btree ("CustomerID")

# Note the following query error:

postgres=# SELECT DISTINCT City FROM customers ORDER BY City;
ERROR:  column "city" does not exist
LINE 1: SELECT DISTINCT City FROM customers ORDER BY City;
                        ^

# ... use use double-quotes if your column name
# (etc.) contains some uppercase characters:

postgres=# SELECT DISTINCT "City" FROM customers ORDER BY "City";
      City       
-----------------
 Aachen
 Albuquerque
 Anchorage
 Århus
 Barcelona
 [ ... snip! ... ]
 Tsawassen
 Vancouver
 Versailles
 Walla Walla
 Warszawa

此数据库以这种优良使用(例如),在线教程(I跳过前面几页到第一页提到它):

http://www.w3schools.com/sql/sql_syntax.asp

在其它两个答案似乎是过时的。

您可以从这个链接得到的Northwind数据库创建脚本

使用PG的管理员或psql的指令Run查询

如果你真的想要那个特定一个,你可以抓住罗斯文从单位的DBLinq测试数据集的PostgreSQL的端口。请参见 http://groups.google.com/group/dblinq/web/unit -tests 关于如何做到这一点比较粗略的笔记。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top