Sei sulla pagina 1di 11

1. What privilege should a user be given to log on to the Oracle server? Is this a system or an object privilege?

Ans)) when a user wants to log on to the oracle database server without any privilege then the following error occurs. ORA-01045:user 'XYZ' lacks CREATE SESSION privilege; logon denied. Inorder to give permission to user sysdba should grant create session privilege.

grant create session to user;

'create session' is one of the most important 'system privileges';

2. What privilege should a user be given to create tables? Ans)) create table - system privilege is granted to create tables.

3. If you create a table, who can pass along privileges to other users on your table? Ans)) owner of the table and any user who has been given the privilege using the WITH GRANT OPTION;

4. You are the DBA. You are creating many users who require the same system privileges. What should you use to make your job easier? Ans)) create users first and then create a ROLE having a group of related system privileges. THen assign the ROLE to all users.

ROLES can have both SYSTEM and OBJECT privileges.

CREATE USER <user1> IDENTIFIED BY <password>; CREATE ROLE <Rolename>; GRANT create session, create table, create view, create procedure TO <Rolename>; GRANT <Rolename> to <user1>, <user2>; 5. What command do you use to change your password? Ans)) ALTER USER <username> IDENTIFIED BY <new-password>; 6. Grant another user access to your DEPARTMENTS table. Have the user grant you query access to his or her DEPARTMENTS table. Ans)) GRANT select ON departments TO <username>; --This is the basic query and any user who executes this statement can grant access on their departments table to other users.

7. Query all the rows in your DEPARTMENTS table. Ans)) select * from <departments table>; Or if I am in my user1 account then I query as below: select * from user1_dept ; 8. Add a new row to your DEPARTMENTS table. Team 1 should add Education as department number 500. Team 2 should add Human Resources as department number 510. Query the other teams table. Ans)) ---user1

INSERT INTO user2.departments(department_id, department_name) values(500, 'Education');

select * from user2.departments;

---user2

INSERT INTO user1.departments(department_id, department_name) values(510, 'Human Resources');

select * from user1.departments;

9. Create a synonym for the other teams DEPARTMENTS table. Ans)) CREATE synonym <new-synonym> for <other user's name>.departments; ---------I am unable to create synonym due to insufficient privileges even thou I granted the connect privilage which by default has create synonym privilege too.-----10. Query all the rows in the other teams DEPARTMENTS table by using your synonym. Team 1 SELECT statement results:

Team 2 SELECT statement results: ans)) select * from <new-synonym>; 11. Query the USER_TABLES data dictionary to see information about the tables that you own. Ans)) select table_name from user_tables;

12. Query the ALL_TABLES data dictionary view to see information about all the tables that you can access. Exclude tables that you own. Note: Your list may not exactly match the list shown below. Ans)) select table_name from all_tables where owner != 'HR';

13. Revoke the SELECT privilege from the other team. Ans)) revoke select on departments from <other-team>;

14. Remove the row you inserted into the DEPARTMENTS table in step 8 and save the changes. Ans)) commit; /--to save change;

Potrebbero piacerti anche