Chapter 9.  Using the PostgreSQL Database System

9.1. How do I connect to the database server?
9.2. What is Emacs SQL mode?
9.3. Where can I learn more about PostgreSQL?

9.1.

How do I connect to the database server?

  1. You will need a database account in addition to your Linux account. Your database instructor is normally the one who provides this.

  2. After logging into to mis.iue.edu, give the shell command $ psql dbname , where dbname is the name of your database. You can omit dbname if it is the same as your user name.

    For more information, run the command $ man psql in the shell, or \? or \h in psql.

  3. Alternatively, start Emacs on the mis.iue.edu. In Emacs, give the command M-x sql-postgres RET. Emacs will prompt you for the server and database names. Omit the server name. If the database name is the same as your user name, you can omit it too.

9.2.

What is Emacs SQL mode?

If you editing a file with a name ending in .sql, Emacs goes into SQL mode, which allows you to send SQL statements directly to the SQL process (assuming you're running SQL from within Emacs). See the Emacs SQL menu for details.

It's best to start the SQL process under Emacs before opening the SQL file. Otherwise, Emacs might be confused about which process to send your SQL commands to.

9.3.

Where can I learn more about PostgreSQL?

  • All Linux workstations in 102 Tom Raper Hall and the server mis.iue.edu should have PostgreSQL HTML documentation online. Its precise location in the file system changes as we upgrade to newer versions of PostgreSQL. One of the following links may work, if you are logged onto one of these systems:

    • $ evince /usr/share/doc/postgresql-docs-8.3.9/postgresql-8.3.9-US.pdf &

      at merlin.iue.edu, Linux lab, or other Fedora 11 systems (verified 2/9/2010). Don't print this; it is 2,091 pages! You may want to print small parts of it.

  • Otherwise, you can find the PostgreSQL documentation by using the shell command

    • $ ls /usr/share/doc/postgresql*

    or by inference from the version number

    • $ psql --version

    Then use your browser's "Open File" command, for HTML documentation, or a PDF reader such as evince or Adobe PDF reader, for PDF.

  • PostgreSQL.org Home Page (download, interactive and downloadable documentation)