Name
CONNECT
Synopsis
The CONNECT statement establishes a connection to the DBMS and to a specific database within the DBMS.
Platform |
Command |
DB2 |
Supported, with variations |
MySQL |
Not supported |
Oracle |
Supported |
PostgreSQL |
Not supported |
SQL Server |
Supported, with variations |
SQL2003 Syntax
CONNECT TO {DEFAULT | {[server_name
] [ASconnection_name
] [USERuser_name
] }
Keywords
- DEFAULT
Initiates a default session with the server where the user authorization is the default and the current database is the default. The standard specifies that CONNECT TO DEFAULT is issued implicitly if you start a SQL session without first issuing a CONNECT statement.
-
server_name
Establishes a connection to a named server. The
server_name
may be a string literal enclosed in single-quotes or a host variable.- AS
connection_name
Establishes a connection with the name
connection_name
shown in single-quotes. The optionalconnection_name
may be a string literal enclosed in single quotes or a host variable. It is optional only for the first connection attached to a server. All subsequent sessions must include the AS clause. This is useful for telling user connections apart when many users, perhaps even a single user, have many open sessions on a givenserver_name
.- USER
user_name
Establishes a connection to the named server under the
user_name
specified.
Rules at a Glance
Issue the CONNECT statement to open an interactive SQL session with a DBMS. The period between issuing the CONNECT and DISCONNECT statements ...
Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.