Chapter 9 SQL Statements
617
SETUSER statement
Use this statement to allow a database administrator to impersonate another
user, and to enable connection pooling.
{ SET SESSION AUTHORIZATION | SETUSER }
[ [ WITH OPTIONS ]
userid
]
Must have DBA authority.
"EXECUTE IMMEDIATE statement" on page 518
"GRANT statement" on page 540
"REVOKE statement" on page 595
"SET OPTION statement" on page 612
The SETUSER statement is provided to make database administration easier.
It enables a user with DBA authority to impersonate another user of the
database.
SETUSER can also be used from an application server to take advantage of
connection pooling. Connection pooling cuts down the number of distinct
connections that need to be made, which can improve performance.
SETUSER with no user ID undoes all earlier SETUSER statements.
There are several uses for the SETUSER statement, including the following:
♦
Creating objects You can use SETUSER to create a database object
that is to be owned by another user.
♦
Permissions checking By acting as another user, with their
permissions and group memberships, a DBA can test the permissions
and name resolution of queries, procedures, views, and so on.
♦
Providing a safer environment for administrators The DBA has
permission to carry out any action in the database. If you wish to ensure
that you do not accidentally carry out an unintended action, you can use
SETUSER to switch to a different user ID with fewer permissions.
WITH OPTIONS By default, only permissions (including group
membership) are altered. If WITH OPTIONS is specified, the database
options in effect are changed to the current database options of userid.
♦
SQL/92 SET SESSION AUTHORIZATION is SQL 92 compliant.
SETUSER is a vendor extension.
♦
Sybase Adaptive Server Enterprise supports SETUSER, but not the
WITH OPTIONS keywords.
Function
Syntax
Permissions
See also
Description
Parameters
Standards and
compatibility