As a database administrator, you might need to control the type of access people have to data, or restrict their view of the data.
This section briefly describes two methods for controlling access to the data:
Database authorities involve actions on a database as a whole. When a database is created, some authorities are automatically granted to anyone who accesses the database. For example, CONNECT, CREATETAB, BINDADD and IMPLICIT_SCHEMA authorities are granted to all users. Database privileges involve actions on specific objects within the database. When a database is created, some privileges are automatically granted to anyone who accesses the database. For example, SELECT privilege is granted on catalog views and EXECUTE and BIND privilege on each successfully bound utility is granted to all users.
In "Welcome", we recommend that you use the user ID that was created following the instructions in the Quick Beginnings for your platform. That user ID has SYSADM authority. The Administration Guide describes all the system authority levels. In short they are:
Together, privileges and authorities act to control access to an instance and its database objects. Users can access only those objects for which they have the appropriate authorization, that is, the required privilege or authority.
See the section on authorities, privileges, and authorizations, and the section on controlling database access in the Administration Guide for a more detailed discussion of authorities and privileges.
You can use the DB2 administration tools to grant and revoke privileges for users and groups for databases, table spaces, tables, views, and schemas. You do this as follows:
See the Administration Guide for the details of managing database authorities, privileges for database objects, and system authorities.
A view is defined in "Views". You can define a view so that it includes some or all of the rows in a table. You can create a view, for example, for each individual department manager that allows each manager to look at the salary information for their employees. This is done by specifying the department number for each manager when you define each view.
To create a view:
AS SELECT ID, NAME, DEPT, JOB, YEARS FROM STAFF WHERE JOB <> 'MGR'
Note that the <> operator in the WHERE clause means not equal.
See the SQL Reference for information on the CREATE VIEW statement.
A Check option specifies the constraint that conforms to the definition of the view. A row that does not conform to the definition of the view is a row that does not satisfy the search conditions of the view. The online help describes each of the options.