20.453J / 2.771J / HST.958J Biomedical Information Technology MIT OpenCourseWare Fall 2008

advertisement
MIT OpenCourseWare
http://ocw.mit.edu
20.453J / 2.771J / HST.958J Biomedical Information Technology
Fall 2008
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
PostgreSQL Mini Installation User Guide
Downloading and installation of PostgreSQL
(Note: follow the PostgreSQL installation instruction from http://www.postgresql.org/download/. This
document provides a summary of the installation process on the Windows XP system.)
1) Download the installation package of PostgreSQL from http://www.postgresql.org/download/
2) Install PostgreSQL
You will see several screens like the ones below 1 :
(1) Service configuration
Enter a password of your choice
The “Account error” dialog box will pop out
the first time the service is configured.
Click “Yes” to continue the installation
1
See license statement at the end of this document.
© H.E. Chua, 2008
Page 1
PostgreSQL Mini Installation User Guide
(2) Initialize database cluster
Enter a password of your choice. This will be the
password for connecting to the local database
(3) Set up procedural languages
© H.E. Chua, 2008
Page 3
PostgreSQL Mini Installation User Guide
(4) Set up modules
© H.E. Chua, 2008
Page 4
PostgreSQL Mini Installation User Guide
(5) Complete the installation
© H.E. Chua, 2008
Page 5
PostgreSQL Mini Installation User Guide
Using PostgreSQL
Additional documentations can be found in http://www.postgresql.org/docs/ .
1) Start pgAdmin III and double-click on PostreSQL Database Server 8.3
Enter the password you set for
“Initialize database cluster”
2) Create PID database
Right-click on “Databases” and select “New
Database...” in the pop-up dialog
© H.E. Chua, 2008
BSD license statement has added to the document, per http://www.postgresql.org/about/licence
Page 6
PostgreSQL Mini Installation User Guide
Enter “PID” as the name of the database
3) Create tables
Right-click on “Tables” and select “New Table...”
in the pop-up dialog
BSD license statement has added to the document, per http://www.postgresql.org/about/licence
© H.E. Chua, 2008
Page 7
PostgreSQL Mini Installation User Guide
Enter the table name
3) Enter column name
4) Select data type
(e.g. integer, text,
Boolean, etc.) for this
column
1) Click on “Columns” tab to
start adding new column to the
table
2) Click on “Add” to add a new
column and edit the details for
the column
BSD license statement has added to the document, per http://www.postgresql.org/about/licence
© H.E. Chua, 2008
Page 8
PostgreSQL Mini Installation User Guide
Setting primary key, foreign key and unique constraints
Primary key column should be
set to non-null
1) Select “Constraints” tab
4) Click on “Columns” tab. Select the columns
to be included in the constraint.
More than 1 column can be selected if required
2) Select types of constraints
(primary key, foreign key, or
unique constraints)
3) Click on “Add” to set the
constraints. “New Primary
Key...” dialog will pop up
© H.E. Chua, 2008
BSD license statement has added to the document, per http://www.postgresql.org/about/licence
Page 9
PostgreSQL Mini Installation User Guide
4) Populate tables
2) Click on this button to edit data in the selected table
1) Select the table to populate
3) Populate or edit the values in the table
5) Save/restore the database information
1) Right-click on the database you want to save and select
“Backup…” in the pop-up dialog
For restoring a backup file, select “Restore…” instead
s
© H.E. Chua, 2008
BSD license statement has added to the document, per http://www.postgresql.org/about/licence
Page 10
PostgreSQL Mini Installation User Guide
1) Click on the browse button in “Backup Database”
dialog box to select where you want to backup the
file
2) Save the backup file in the following format
<FamilyName>_HW<AssignmentNumber>
E.g. Chua_HW1B
6) Construct SQL query
1) Click on SQL button
3) Run SQL query
2) Enter SQL query
© H.E. Chua, 2008
BSD license statement has added to the document, per http://www.postgresql.org/about/licence
Page 11
PostgreSQL Mini Installation User Guide
Copyright statement for PostgreSQL screenshots:
Permission to use, copy, modify, and distribute this software and its documentation for any
purpose, without fee, and without a written agreement is hereby granted, provided that the
above copyright notice and this paragraph and the following two paragraphs appear in all
copies.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE
UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
© H.E. Chua, 2008
Page 12
Download