2010-04-06 38 views

Trả lời

1

Có một số cơ sở dữ liệu mẫu có sẵn như là một dự án pgFoundry tại http://pgfoundry.org/projects/dbsamples/

+0

Trang dbsamples được lấy ra. Ở đâu? – 42n4

+0

Vâng, trang không còn ở đó nữa – Fra

1

Nếu bạn thực sự muốn điều đó một cụ thể, bạn có thể lấy một cổng PostgreSQL của Northwind từ Bộ dữ liệu thử nghiệm đơn vị DbLinq. Xem http://groups.google.com/group/dblinq/web/unit-tests để biết các ghi chú hơi sơ sài về cách thực hiện điều đó.

8

tôi đã có thể tải về cơ sở dữ liệu Northwind (đối với PostgreSQL) từ

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

đặc biệt

[chấp nhận: http://northwindextended.googlecode.com/files/northwind.postgre.sql]

[Cập nhật: tháng 10 năm 2016:] https://code.google.com/archive/p/northwindextended/downloads

tải/truy cập vào cơ sở dữ liệu:

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 

cơ sở dữ liệu này được sử dụng (ví dụ) trong tuyệt vời, hướng dẫn trực tuyến này (tôi bỏ qua phía trước một vài trang, đến trang đầu tiên đề cập đến nó):

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

4

Hai câu trả lời khác dường như đã lỗi thời.

Bạn có thể nhận được kịch bản tạo db Northwind từ this link

Chạy truy vấn sử dụng PG admin hoặc lệnh psql

Các vấn đề liên quan