Where can I download Northwind database for Postgresql?

放肆的年华 提交于 2019-12-04 06:41:47

There are a number of sample databases available as a pgFoundry project at http://pgfoundry.org/projects/dbsamples/

I was able to download the Northwind Database (for PostgreSQL) from

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

specifically

[ deprecated: http://northwindextended.googlecode.com/files/northwind.postgre.sql ]

[ updated: Oct 2016: ] https://code.google.com/archive/p/northwindextended/downloads

Loading/accessing the database:

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

This database is used (e.g.) in this excellent, online tutorial (I skipped ahead a few pages, to the first page that mentions it):

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

The other two answers seems to be outdated.

You can get northwind db creation script from this link

Run query using PG admin or psql command

If you really want that specific one, you can grab a PostgreSQL port of Northwind from the DbLinq unit test data set. See http://groups.google.com/group/dblinq/web/unit-tests for somewhat sketchy notes on how to do that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!