O'Reilly logo

SQL in a Nutshell 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.

Vendor

Command

SQL Server

Supported, with limitations

MySQL

Not supported

Oracle

Supported

PostgreSQL

Not supported

SQL99 Syntax and Description

CONNECT [TO] DEFAULT
| {[server_specification] [AS connection_name] [USER user_name ] }

If the CONNECT statement is invoked without explicitly disconnecting, the old session becomes dormant and the new session becomes active. The period between issuing the CONNECT and DISCONNECT statements is commonly called a session . Typically, users complete all work on a DBMS during an explicitly invoked session.

Tip

The Oracle tool SQL*Plus uses the CONNECT command somewhat differently: to connect a user to a specific schema.

The CONNECT TO DEFAULT statement has somewhat variable results, since different vendors implement it differently. But according to the standard, this command should initiate a default session with the server where the user authorization is the default and the current database is the default.

In contrast to CONNECT TO DEFAULT, CONNECT TO server_name allows you to specify the server. Here, the connection is made to the server that is explicitly named. In addition, the connection may be declared using AS and a specific user with USER.

Oracle Syntax and Variations

CONN[ECT] [[username/password] [AS [SYSOPER | SYSDBA] ] ]

The CONNECT clause allows a database connection as a specific username. Alternately, ...

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