This chapter describes how client applications connect to databases. It contains information about connecting to databases from ODBC, OLE DB, and Embedded SQL applications. It also describes connecting from Sybase Central and Interactive SQL.
For more information on connecting to a database from Sybase Open Client applications, see Chapter 15, “Sybase IQ as a Data Server.”
For more information on connecting via JDBC (if you are not working in Sybase Central or Interactive SQL), see Appendix B, “Data Access Using JDBC.”
Any client application that uses a database must establish a connection to that database before any work can be done. The connection forms a channel through which all activity from the client application takes place. For example, your user ID determines permissions to carry out actions on the database—and the database server has your user ID because it is part of the request to establish a connection.
This sounds simple, but some client tools may not clearly
indicate connection status, and a failed command is your first indication
that the connection does not exist. For a novice user, a quick way
to confirm the connection is by a simple select
db_name()
.
To display the current database, use this syntax:
select db_name()
To specify a different database, use this syntax:
select db_name([ database_id ])