Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Databases - Practical PostgreSQL
Previous Page Home Next Page

Creating Tables

It is relatively easy to create and modify the tables of a database with PgAccess through its graphical interface. Figure 6-3 shows this dialog window.

Figure 6-3. The PgAccess Create new table dialog box

To create a table, first click on the Tables tab, then click the New button to open the "Create new table" window. This window contains various fields and buttons that allow you to modify the attributes of the table you are creating. Basically, these commands are visual representations of the options found in the SQL CREATE TABLE command.

The following list names available inputs within the PgAccess Create Table Dialog:

Table name

The name of the table you wish to create within PostgreSQL.


You can set what table(s) from which this table will inherit attributes. A list of available tables is located in the drop-down box. Note that the list is not restricted to holding just one value; you can click the downward arrow button and choose another table to add that table to the inheritance list.


Enter any expressions you wish to have checked on INSERT and UPDATE commands.


Enter any constraints you wish to place upon the table.

The following subsections talk about how to add fields to a table and about how to insert and delete rows.

To add a field to the table, set its attributes with the field name, type, size, and Default value fields, and set its options with the "field cannot be null" and "primary key" check box options. Once you have chosen the options, click the "Add field" button to add the field to the field list. You are able to move fields up and down through the list with the "Move up" and "Move down" buttons, delete a field with the "Delete field" button, and delete all fields with the "Delete all" button.

Once you are ready to add the table into your database, click the Create button. The following subsections discuss how to insert and delete of rows.

Inserting and updating values

It is possible to insert values into a table using PgAccess; in fact, the process is fairly simple. Click on the Table tab to view the list of tables, then click on the table you wish to modify and click Open.

After clicking Open, you should see a window of rows and columns that contain the various fields of your table. You can tab through these columns and rows to reach a target field, or just use your mouse to click on it. The row chosen will become highlighted and a cursor will appear showing you the location of the new data. The database will not be updated with your changes until you tab out of the field you were editing; or, alternatively, click into another field with your mouse. PgAccess displays the message: "Updating database..." after you complete one of these actions.

It may be useful to note that it is possible to both sort and filter the table data by making use of two fields at the top of the table window, named logically "Sort field" and "Filter conditions." It is possible to sort the table by a field or multiple fields by typing the name of the field into the "Sort field" box, optionally including "ASC" or "DESC" if you wish for the sort to be ascending or descending, respectively. You can choose to sort by multiple fields. To do this, include the names of other fields in a comma-delimited list. As an example, you could use the following to sort a list of names by the lastname field, ascending:

lastname ASC

To use the "Filter conditions" box, enter filter conditions such as the following:

(age < 45) and (avgsalary > 40000)

The process for updating table data is the same as for inserting, but you change existing rows rather than adding new ones.

Deleting values

To delete values from a table, open it in the same manner you would when attempting to insert values: click on the Tables tab, then click on the table you wish to modify and click Open. Within this window are the columns and rows of the table, filled with whatever data has been entered. You can either delete rows, or specific fields within a row. To delete a row, click on the desired row, then hit the Delete key on your keyboard. PgAccess will display a dialog box asking for confirmation of the delete, in case your choice to delete was accidental. To delete the contents of a field, or the partial contents of a field, click or tab into that field and use the Backspace key to delete characters.

Databases - Practical PostgreSQL
Previous Page Home Next Page

  Published under the terms of the Open Publication License Design by Interspire