This page in other versions: 9.0 / 9.1 / 9.2 / 9.3  |  Development versions: devel / 9.4  |  Unsupported versions: 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3 / 8.4

4.2. Connecting to the Database Server

One connects to a database using the following statement:

EXEC SQL CONNECT TO target [AS connection-name] [USER user-name];

The target can be specified in the following ways:

  • dbname[@hostname][:port]

  • tcp:postgresql://hostname[:port][/dbname][?options]

  • unix:postgresql://hostname[:port][/dbname][?options]

  • character variable

  • character string

  • DEFAULT

There are also different ways to specify the user name:

  • userid

  • userid/password

  • userid IDENTIFIED BY password

  • userid USING password

The userid and password may be a constant text, a character variable, or a character string.

The connection-name is used to handle multiple connections in one program. It can be omitted if a program uses only one connection.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group