O'Reilly logo

SQL in a Nutshell, 2nd Edition by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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] [AS connection_name]
   [USER user_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 optional connection_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 given server_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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required