Name

DISCONNECT

Synopsis

The DISCONNECT statement terminates a connection to the DBMS.

Vendor

Command

SQL Server

Supported, with limitations

MySQL

Not supported

Oracle

Supported, with variations

PostgreSQL

Not supported

SQL99 Syntax and Description

DISCONNECT {CURRENT | ALL | connection_name}

This command ends one or more connections created between the current SQL process and the database server. The CURRENT clause closes the currently active user connection. The ALL clause closes all open connections for the current user. Alternately, it’s possible to close only a specific connection.

Microsoft SQL Server Syntax and Variations

Microsoft SQL Server supports DISCONNECT in Embedded-SQL (ESQL) only, not within its ad hoc querying tool, SQL Query Analyzer. It supports the full SQL99 syntax. When disconnecting from Microsoft SQL Server in an ESQL program, the DISCONNECT ALL command should be used to disconnect cleanly from the database server.

Oracle Syntax and Variations

DISC[ONNECT]

In contrast to SQL Server, Oracle allows DISCONNECT only in its ad hoc query tool, SQL*Plus. In this usage, the command ends the current session with the database server but otherwise allows work in SQL*Plus to continue. For example, a programmer can continue to edit the buffer, save run files, and so on. However, a reconnection must be established to issue any SQL commands. Exiting SQL*Plus and returning to the filesystem requires the EXIT or QUIT commands.

Oracle also supports this functionality with ...

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