Oracle, like many other databases, uses the combination of specific user definitions, privileges, and roles to control access to the data in the database. In turn, it provides various layers of security. When the database is first created, there are several users created for the purpose of not only installing various components of the database, but also to manage and administer the database functionality. You have already used the SYS and SYSTEM users in previous labs. In this lab you will be creating a series of different users, administering various privileges to those users, as well as exploring how Roles help provide additional functionality to the user picture.
VERY IMPORTANT:
Be sure that you start a spool session before you start executing your SQL code when working on the lab. Your SPOOL file name should be DATABASE_lab6. This will be the only way to capture the results of your work and will be required for grading. Remember that anytime you see the ### in the instructions (not the expected results), it indicates that you are supposed to replace the number signs with your instance number. Last, if you do the lab in several sessions, be sure that you use a different file name, so as not to overwrite the existing file (for example DATABASE_lab6, DATABASE_lab6a, DATABASE_lab6b etc.)
Environment Set Up:
Before starting this lab you will need to download two files from Doc Sharing and run them to make some changes to the environment. To make these change do the following:
- Download the pupbld.sql file from Doc Sharing to a directory on your computer.
- Open the file and edit the login information at the top for the SYSTEM user (change the DB### to your instance name).
- Now at the bottom of the file make the same change to the login string to go back to the SYS user.
- Now run the file in your Oracle enstance.
- Download the Lab6_support.SQL file from Doc Sharing to a directory on your computer.
- Open the file and edit the login information for the connection to SCOTT to reflect your instance number in the host string. This is the only change you should have to make to the script.
- When finished, save the file and then run the script file logged onto your instance as the SYS AS SYSDBA.
L A B S T E P S |
Step 1: Creating a new user |
Your response will look similar to this:
User CreatedNow that the user is created, make sure that Bob can create a session, by granting the needed privilege.
Your answer will look similar to this:
Grant succeeded.
Step 2: Finding information on users |
Hint: This information can be obtained by querying the DBA_USERS.Your response will look similar to this:
USERNAMEDEFAULT_TABLESPACE TEMPORARY_TABLESPACE
------------------------------ ------------------------------ -----------------------
BOBUSERS01 TEMP01
Step 3: Finding information about user storage |
Hint:This information can be obtained from DBA_TS_QUOTAS.Your answer will look similar to this:
TABLESPACE_NAME USERNAME BYTES MAX_BYTES BLOCKSMAX_BLOCKS
--------------------- -------------------- ---------- ------------ ---------- ------------
USERS01 BOB 0 524288 0 64
Step 4: Finding user privileges |
Hint: At the command line prompt enter CONNECT bob/along@host_string_goes_Your answer will look similar to this:here
Connected.While connected as Bob, query the USER_SYS_PRIVS data dictionary view to see what privileges Bob currently has. This view is accessible by any user and can be very helpful.
User altered.
Your answer will look similar to this:
USERNAME PRIVILEGE
---------------------- ------------------------
BOB CREATE SESSION
Step 5: Changing user specifications |
Your answer will look similar to this:
Connected.Bob has forgotten his password. Assign him a password of OLINK and require that Bob change his password the next time he logs on.
User altered.
Your answer will look similar to this:
User altered.
Step 6: Listing privileges associated with a Role |
Hint: The information is available from DBA_SYS_PRIVS.Your answer will look similar to this:
GRANTEEPRIVILEGE ADM
------------------------------ ---------------------------------------- ----
RESOURCECREATE CLUSTER NO
RESOURCECREATE INDEXTYPE NO
RESOURCECREATE OPERATOR NO
RESOURCECREATE PROCEDURE NO
RESOURCECREATE SEQUENCE NO
RESOURCECREATE TABLE NO
RESOURCECREATE TRIGGER NO
RESOURCECREATE TYPE NO
8 rows selected.
Step 7: Creating a Role |
Create a role called DEV and assign privileges to the Role that will allow a user to:
- Create a session
- Create a table
- Create a view
- Enable a user select from Scott's EMP table.
Hint: Remember that a member assigned to this roll must be able to create the table in any tablespace. Also, you cannot assign System privileges and Object privileges in the same GRANT statement.You should get responses that look similar to this:
Role created.
Grant succeeded.
Step 8: Verifying Role content |
Your response will look similar to this:
GRANTEEPRIVILEGE ADM
------------------------------ ---------------------------------------- ---
DEVCREATE VIEW NO
DEVCREATE SESSION NO
DEVCREATE ANY TABLE NO
GRANTEE OWNERTABLE_NAME GRANTOR
---------------- ---------------------- ------------------- -------------------
DEV SCOTT EMP SCOTT
Step 9: Assigning a user to a Role |
Your response will look similar to this:
User created.
Grant succeeded.
Step 10: Using privileges in a Role |
Your answer will look similar to this:
Connected.
Table created.
Step 11: Assigning multiple Roles to a user |
Hint: there is a system-level role that will accomplish this but you have to be connected as the correct user to assign it.Your answer will look similar to this:
Connected.
Grant succeeded.
Step 12: Assigning a Default Role |
Hint: You will need to use the USER_ROLE_PRIVS view to find your information.Your answer will look similar to this:
Grant succeeded.
User altered.
Connected.
USERNAMEGRANTED_ROLE DEF
------------------------------ ------------------------------ ---
JACKDEV YES
JACKRESOURCE NO
JACKSELECT_CATALOG_ROLE NO
No comments:
Post a Comment