历史版本。 PostgreSQL 7.3 已结束支持。 请参阅 当前版本手册.
4.2. 连接到数据库服务器 #
使用下面的语句连接到数据库:
EXEC SQL CONNECT TOtarget[ASconnection-name] [USERuser-name];
target 可以用下列方式指定:
-
dbname[@hostname][:port] -
tcp:postgresql://hostname[:port][/dbname][?options] unix:postgresql://hostname[:port][/dbname][?options]-
character variable -
character string -
DEFAULT
还有几种指定用户名的方式:
-
userid -
userid/password -
useridIDENTIFIED BYpassword -
useridUSINGpassword
userid 和
password 可以是常量文本、字符变量或字符串。
connection-name 用于在一个程序中处理多个连接。如果程序只使用一个连接,它可以省略。