connect

Description

Establishes a connection to a database.

Syntax

connect
	[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}

Parameters

engine_name

is the name of the engine to which you are connecting.

database_name

is the name of the database to which you are connecting. It must conform to the rules for identifiers and cannot be a variable.

as

you can optionally name a connection by specifying the as clause. This allows multiple connections to the same database, or multiple connections to the same or different database servers, all simultaneously. Each connection has its own associated transaction. You may get locking conflicts between your transactions if, for example, you modify the same record in the same database from two different connections.

connection_name

is the login name you are using to make the connection.

user

indicates that you are connecting to Adaptive Server as a user.

user_id

is the ID of the user who is connecting.

identified by password

indicates that the user will need to include a password when they connect.

password

is the password of the user connecting to Adaptive Server.

identifier

is the identifier you are using for the connection information.

string

is the string you are using for the connection information.

hostvar

is the variable information for the host name and port.

connect_string

is a list of parameter settings of the form keyword = value, separated by semicolons, and must be enclosed in single quotes.

Examples

Example 1

Connects to a database from Interactive SQL. Interactive SQL prompts for a user ID and a password:

connect

Example 2

Connects to the default database as DBA from Interactive SQL. Interactive SQL prompts for a password:

connect user "DBA"

Example 3

As user dba, with password sql, connects to the pubs2 database of an Adaptive Server running on host “tribble” at port number 5000:

connect to "tribble:5000"
database pubs2
user dba
identified by sql

Example 4

As user dba, with password sql, connects to an Adaptive Server named “tribble” (defined in interfaces file):

connect to tribble
user dba
identified by sql

Usage

Permissions

Any user can execute this command.

See also

disconnect, set connection