Permissions within databases

Whether or not you can create and drop databases and database objects depends on your permissions or privileges. Ordinarily, a system administrator or database owner sets up permissions for you, based on the kind of work you do and the functions you need. These permissions can be different for each user in an installation or database.

Determine what your permissions are by executing:

sp_helprotect user_name

where user_name is your Adaptive Server login name.

The pubs2 and pubs3 databases have a guest user name in their sysusers system tables. The scripts that create pubs2 and pubs3 grant a variety of permissions to “guest.”

The “guest” mechanism means that anyone who has a login on Adaptive Server, that is, anyone who is listed in master..syslogins, has access to pubs2 and pub3, and permission to create and drop such objects as tables, indexes, defaults, rules, procedures, and so on. The “guest” user name also allows you to use certain stored procedures, create user-defined datatypes, query the database, and modify the data in it.

To use the pubs2 or pubs3 database, issue the use command. Adaptive Server checks whether you are listed under your own name in pubs2.sysusers or pubs3..sysusers. If not, you are admitted as a guest without any action on your part. If you are listed in the sysusers table for pubs2 or pubs3, Adaptive Server admits you as yourself, but may give you different permissions from those of “guest.”

NoteAll the examples in this chapter assume you are being treated as “guest.”

Most users can look at the system tables in the master database by using the “guest” mechanism. Users who are not recognized by name in the master database are allowed in and treated as a user named “guest.” The “guest” user is added to the master database in the script that creates the master database when it is installed.

A database owner, “dbo,” can add a “guest” user to any user database using sp_adduser. System administrators automatically become the database owner in any database they use. See Chapter 13, “Getting Started with Security Administration in Adaptive Server,” in the System Administration Guide: Volume 1.