哪里可以为Postgresql下载Northwind数据库?

时间:2010-04-06 14:37:03

标签: postgresql northwind

是否有可下载的Postgres数据库包含虚拟数据?最好是罗斯文,我可以练习我的查询想法

4 个答案:

答案 0 :(得分:8)

我可以从

下载Northwind数据库(用于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

这个数据库用于(例如)这个优秀的在线教程(我跳过几页,到第一页提到它):

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

答案 1 :(得分:4)

其他两个答案似乎已经过时了。

您可以从this link

获取northwind数据库创建脚本

使用PG admin或psql命令运行查询

答案 2 :(得分:1)

http://pgfoundry.org/projects/dbsamples/

有许多样本数据库可用作pgFoundry项目

答案 3 :(得分:1)

如果你真的想要那个特定的,你可以从DbLinq单元测试数据集中获取Northwind的PostgreSQL端口。有关如何做到这一点的粗略说明,请参阅http://groups.google.com/group/dblinq/web/unit-tests