GRANT CONNECT Statement

Grants CONNECT privilege to a user.

Quick Links:

Go to Parameters

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

GRANT CONNECT 
   TO userID [,...]
   IDENTIFIED BY password [,...]

Parameters

(back to top)

Examples

(back to top)

Usage

(back to top)

GRANT CONNECT can be used to create a new user or also be used by any user to change their own password.

Tip: Use the CREATE USER statement rather than the GRANT CONNECT statement to create users.

If you inadvertently enter the user ID of an existing user when you are trying to add a new user, you are actually changing the password of the existing user. You do not receive a warning because this behavior is considered normal.

The stored procedures sp_addlogin and sp_adduser can also be used to add users. These procedures display an error if you try to add an existing user ID.

Note: Use system procedures, not GRANT and REVOKE statements to add and remove user IDs.

A user without a password cannot connect to the database. This is useful when you are creating groups and you do not want anyone to connect to the role user ID. To create a user without a password, do not include the IDENTIFIED BY clause.

When specifying a password, it must be a valid identifier Passwords have a maximum length of 255 bytes. If the VERIFY_PASSWORD_FUNCTION database option is set to a value other than the empty string, the GRANT CONNECT TO statement calls the function identified by the option value. The function returns NULL to indicate that the password conforms to rules. If the VERIFY_PASSWORD_FUNCTION option is set, you can specify only one userid and password with the GRANT CONNECT statement.

Invalid names for database user IDs and passwords include those that:

Standards

(back to top)

  • SQL–Other syntaxes are vendor extensions to ISO/ANSI SQL grammar.
  • SAP Sybase Database product–The security model is different in Adaptive Server and SAP Sybase IQ, so other syntaxes differ.

Permissions

(back to top)

Note: If you are changing another user’s password, the other user cannot be connected to the database.
Related reference
CREATE USER Statement
REVOKE CONNECT Statement