# PgAccess Tutorial - Editing a table

## Adding records

Once you have a table, you can begin to add entries to it. In the main PgAccess window, when you click the Tables button, you should see the new table appear in the list of tables. Highlighting the table name by clicking on it and clicking on the Open button will open that table in another window, as shown below.

The most straighforward way to add records to a table is to type the information directly into the fields. Two records have been entered in the table shown. As is common with this user interface, clicking the mouse while the pointer is in a field will allow keyboard entry to that field. This type of entry is adequate when the information arrives infrequently in small parcels, for instance in keeping a table of contact information about other researchers. However, what do you do when someone emails you the entire reference list for their doctoral dissertation?

This is best handled using the SQL COPY command. First, the information will have to be massaged into shape in what is called a 'flat' ASCII file. This is simply a text file in which each line is a record, and each field in each record is separated by a delimiter such as a tilde (~). The fields will have to be in the same order as those in your table, and there will have to be the same number of fields in each record as are in the table, otherwise you may get unexpected data or no data at all. Say you produce a text file named `newref.txt` that starts like this:

`Cassileth, BR~Unorthodox Cancer Medicine~Cancer Investigation~~1986~4~6~591-598
...`

Notice that there are two consecutive tildes to allow for the fact that this particular entry doesn't have anything in the Editor field. You can then perform a Query as follows:

`COPY psyref FROM '/home/jim/newref.txt' USING DELIMITERS '~';`

This will read the records from `newref.txt` and insert them into the table `psyref`. See the PostgreSQL documentation under the headings
Tutorial|The Query Language|Populating a Class with Instances

Back to index