Once you have created a database, you can access it by:
Running psql, the PostgreSQL interactive terminal program, allows you to interactively enter, edit, and execute SQL commands.
Using a graphical frontend tool such as RHDB Administrator to create and manipulate a database. Accessing a database with a graphical tool is not covered in this tutorial.
Writing a custom application using one of the several available language bindings. Refer to the Red Hat Database Programmer's Guide for more information on this.
$ psql mydb |
In psql, you will be greeted with the following message:
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 mydb=> |
mydb=# |
If you have encountered problems starting psql then go back to the previous section. The diagnostics of psql and createdb are similar, and if the latter worked the former should work as well.
The last line printed out by psql is the prompt. It indicates that psql is listening to you and that you can type SQL queries into a work space maintained by psql. Try out these commands:
mydb=> SELECT version(); version ---------------------------------------------------------------- PostgreSQL 7.2.2-RH on i686-pc-linux-gnu, compiled by GCC 2.96 (1 row) mydb=> SELECT current_date; date ------------ 2002-09-04 (1 row) mydb=> SELECT 2 + 2; ?column? ---------- 4 (1 row) |
The psql program has a number of internal commands that are not SQL commands. They begin with the backslash character, "\". Some of these commands were listed in the welcome message. For example, you can get help on the syntax of various SQL commands by typing:
mydb=> \h |
To quit psql, type
mydb=> \q |