SQL CONNECTION (formally SET CONNECTION in the SQL standard) is a session-level statement that makes an existing, previously declared connection the active one. It lets a script or interactive session hop between multiple databases without opening new network sockets each time. When a new connection becomes active, any uncommitted work on the old connection is implicitly committed or rolled back depending on the DBMS, session variables reset to the new context, and subsequent commands execute against the newly selected database. The command does not create a connection; it merely activates one that has already been established with a CONNECT or DECLARE CONNECTION statement. Because not every database engine exposes multiple session connections natively, support is limited and syntax varies.
connection_name
(identifier or string) - The symbolic name of an existing declared connection to activate.user
(string) - Username to authenticate (Oracle, SQL Server, PostgreSQL client variants).password
(string) - Password for the user (Oracle, SQL Server, PostgreSQL client variants).server_name
(string) - Target server or instance (SQL Server sqlcmd).SQL-92 (SET CONNECTION)
It refers to the SET CONNECTION statement defined in the SQL standard that changes which predefined connection is active in the current session.
Use DECLARE CONNECTION or a vendor-specific CONNECT command to establish each connection, then reference its symbolic name in SET CONNECTION.
Yes. Once you switch, variables such as current schema, role, and isolation level reflect the settings of the target connection.
You must open separate client sessions or rely on the vendor's alternative, such as USE database (SQL Server) or CONNECT (Oracle).