Hands-On Lab: Create Tables and Load Data in Postgresql Using Pgadmin
Hands-On Lab: Create Tables and Load Data in Postgresql Using Pgadmin
In this lab, you will learn how to create tables and load data in the PostgreSQL database service using the pgAdmin graphical user interface (GUI) tool. The pgAdmin
GUI provides an alternative to the command line for interacting with a PostgreSQL database using a graphical interface. This GUI provides a number of key features
for interacting with a PostgreSQL database in an easy to use format.
To complete this lab you will utilize the PostgreSQL relational database service available as part of IBM Skills Network Labs (SN Labs) Cloud IDE. SN Labs is a
virtual lab environment used in this course.
The following diagram shows the structure of the "myauthors" table from the Books database:
Objectives
After completing this lab, you will be able to use pgAdmin with PostgreSQL to:
Lab Structure
In this lab, you will complete several tasks in which you will learn how to create tables and load data in the PostgreSQL database service using the pgAdmin
graphical user interface (GUI) tool.
7. Click the Copy icon on the left of your password to copy the session password onto your clipboard.
8. Navigate back to the pgAdmin tab and paste in your password, then click OK.
1. In the tree-view, expand Books > Schemas > public. Right-click on Tables and go to Create > Table.
2. On the General tab, in the Name box, type myauthors as name of the table. Don't click Save, proceed to the next step.
3. Switch to the tab Columns and click the Add new row button four times to add 4 column placeholders. Don't click Save, proceed to the next step.
4. Enter the myauthors table definition structure information as shown in the image below in the highlighted boxes. Then click Save. Proceed to Task C.
Task C: Load data into tables manually using the pgAdmin GUI
You now have a database and have created tables within it. With the pgAdmin GUI, you can insert values into the tables manually. This is useful if you have a few
new entries you wish to add to the database. Let's see how to do it.
1. In the tree-view, expand Tables. Right-click myauthors and go to View/Edit Data > All Rows.
2. You will insert 2 rows of data into the myauthors table. In the lower Data Output pane, enter myauthors table data information for 2 rows as shown in the
highlighted boxes in the image below. Then click the Save Data Changes icon. Proceed to Task D.
myauthors.csv
Make sure Import/Export is set to Import, Format = csv and Header = Yes. Then click Select file icon by the Filename box.
Conclusion
Congratulations! You have completed this lab, and you have learned how to create databases and tables in a PostgreSQL instance, load data into tables manually
using the pgAdmin GUI, and load data into tables from a text/script file.
Author
Sandip Saha Joy
Other Contributors
David Pasternak