Once you have constructed a database, you can access it by:
Running the PostgreSQL terminal monitor program (psql) which allows you to interactively enter, edit, and execute SQL commands.
Writing a C program using the libpq subroutine library. This allows you to submit SQL commands from C and get answers and status messages back about the program.
psql dbname |
Welcome to psql, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit dbname=> |
This prompt indicates that the terminal monitor is listening to you and that you can type SQL queries into a workspace maintained by the terminal monitor. The psql program responds to escape codes that begin with the backslash character, "\". For example, you can get help on the syntax of various PostgreSQL SQL commands by typing:
dbname=> \h |
dbname=> \g |
dbname=> \i filename |
dbname=> \q |
Other things to note:
For more escape codes, type \h (backslash-h) at the monitor prompt.
You can include white space in SQL queries.
Single-line comments are denoted by two dashes (--). Everything after the dashes up to the end of the line is ignored.
Multiple-line comments, and comments within a line, are denoted by the /* ... */ convention.