lab3
lab3
Oracle DBMS
OBJECTIVES:
• User and Privilege Management: Learn how to create and manage users, grant and revoke access rights, and control session
privileges in Oracle databases.
• Role and Profile Creation: Set up roles and profiles to manage user privileges and system resource usage, optimizing database
performance and security.
• Table and Object Access: Understand and apply permissions for reading, updating, and indexing database objects, ensuring
proper user access control.
Oracle allows multiple users to securely work on the same database. Two commands are particularly important: GRANT and
REVOKE, which allow defining the rights of each user on the objects in the database. Every user accesses the database with his
username and password. It is the username that determines the access rights to the objects in the database. In the previous
tutorials, you worked alone in a schema with a name equal to your username. We are going to check that the DBMS manages
the competition of access to objects in the database between several different users. Any user who creates objects is the owner
of these objects. The creator of an object can decide to grant or revoke certain access rights to any user.
Questions:
1. Create another user: Admin.
2. Log in with this user. What do you notice?
3. Give the right to create a session for this user (Create Session).
4. Give the following privileges to Admin: create tables, users. Log in with Admin and check.
5. Run the query Q1: Select * from DBAShool.Teacher. What do you notice?
6. Give this user read permission for the Teacher table. Run query Q1 now.
7. The school increases the salaries of Teachers by 3000 DA if their total number of courses taught is greater than or equal to 3. What should
be done? What do you notice?
8. Try again after giving this user update rights for the Teacher table and read rights for the COURSE_ASSIGNMENT table.
9. Create a LastName_IX index on the LastName attribute of the Teacher table. What do you notice?
10. Give the index creation rights to Admin for the Teacher table and try to create the index again. What happens?
11. Revoke the previously granted privileges.
12. Verify that the privileges have been revoked.
13. Create a profile "School_Profile" which is characterized by: 3 simultaneous sessions allowed, a system call cannot consume more than
35 seconds of CPU, each session cannot exceed 90 minutes, a system call cannot read more than 1200 blocks of data in memory and on the
disk. Each session cannot allocate more than 25 KB of memory in SGA. For each session, a maximum of 30 minutes of inactivity is allowed. 5
login attempts before the account is blocked. The password is valid for 50 days, and it will take 40 days before it can be used again. Only one
day of access ban after the 5 login attempts have been reached. The grace period that extends the use of the password before changing it is 5
days.
14. Assign this profile to the Admin user.
15. Create the role: " School _MANAGER" who can see the tables EXAM, STUDENT, COURSE and can modify the tables TEACHER,
ENROLLMENT, COURSE_ASSIGNMENT and EXAM_RESULT,
16. Assign this role to Admin. Check that the authorizations assigned to the role School_MANAGER have been transferred to the Admin user.
The SQL syntax for creating a user:
CREATE USER username
IDENTIFIED {BY password | EXTERNALLY | GLOBALLY AS 'externalname’}
[DEFAULT TABLESPACE tablespaceName [QUOTA {integer [K | M] | UNLIMITED} ON tablespaceName]]
[TEMPORARY TABLESPACE tablespaceName [QUOTA {integer [K | M] | UNLIMITED} ON tablespaceName]] [PROFILE
profileName] [PASSWORD EXPIRE] [ ACCOUNT {LOCK |UNLOCK}];
• IDENTIFIED BY password allows assigning a password to a local user (most common and simplest case).
• IDENTIFIED BY EXTERNALLY allows using the authenticity of the operating system to identify Oracle (case of OPS$accounts for Unix).
• IDENTIFIED BY GLOBALLY allows using the authenticity of a directory system.
• DEFAULT TABLESPACE nameTablespace assigns a working disk space (called tablespace) to the user.
• TEMPORARY TABLESPACE nameTablespace assigns a temporary disk space to the user.
• QUOTA allows limiting or not each allocated space.
• PROFILE nameProfile assigns a profile (system characteristics related to CPU and connections) to the user.
• PASSWORD EXPIRE to force the user to change his password at the first connection (by default, he is free not to do so). The DBA can also change
this password.
• ACCOUNT to lock or release access to the database (by default UNLOCK).