Establishes a connection to a database.


	[to engine_name]
	[database database_name]
	[as connection_name]
	[user] user_id identified by password
	engine_name, database_name, connection_name, user_id,
		password : {identifier | string | hostvar}
connect using connect_string : {identifier | string | hostvar}




  • connect establishes a connection to the database identified by database_name running on the server identified by engine_name.

  • No statements are allowed until a successful connect statement has been executed.

  • Interactive SQL behavior – if you do not specify a database or server in the connect statement, Interactive SQL remains connected to the current database, rather than to the default server and database. If you do specify a database name without a server name, Interactive SQL attempts to connect to the specified database on the current server. If you specify a server name without a database name, Interactive SQL connects to the default database on the specified server.

  • In the user interface, if the password or the user ID and password are not specified, the user is prompted to type the missing information.

  • When Interactive SQL is running in command-prompt mode (-nogui is specified when you start Interactive SQL from a command prompt) or batch mode, or if you execute connect without an as clause, an unnamed connection is opened. If there is another unnamed connection already opened, the old one is automatically closed. Otherwise, existing connections are not closed when you run connect.

  • Multiple connections are managed through the concept of a current connection. After a successful connect statement, the new connection becomes the current one. To switch to a different connection, use the set connection statement. Use the disconnect statement to drop connections.

  • In Interactive SQL, the connection information (including the database name, your user ID, and the database server) appears in the title bar above the SQL Statements pane. If you are not connected to a database, Not Connected appears in the title bar.


Any user can execute this command.

Related reference
set connection