0% found this document useful (0 votes)
17 views5 pages

Week11 Priviledges

Uploaded by

MahNoor Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Week11 Priviledges

Uploaded by

MahNoor Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Practice 16: Managing Privileges

1 As user SYSTEM, create user Emi and give her the capability to log on
to the database and
create objects in her schema. Assign her to the default tablespace
DATA01, and the
temporary tablespace TEMP. Make her quota on DATA01 1M.

2 a Run the script lab16_02a.sql to connect as Emi and create the


tables CUSTOMERS1 and ORDERS1.
b Connect as SYSTEM and copy the data from SYSTEM.CUSTOMERS to
Emi�s
CUSTOMERS1 table. Verify that the records have been inserted.
c As user SYSTEM give Bob the ability to select from Emi's
CUSTOMERS1 table. What
happens?
3 Reconnect as Emi and give Bob the ability to select from Emi�s
CUSTOMERS1 table.
Also, enable Bob to give the select capability to other users. As user
SYSTEM, examine
the data dictionary views that record these actions.
Hint: Use DBA_TAB_PRIVS to examine.

4 Create user Trevor identified by diamond1$ with the capability to log


on to the
database.

5 a As Bob, enable Trevor to access Emi�s CUSTOMERS1 table.


Note: A password has expired message will be received due to actions in
Practice
15, step 8. Give Bob the new password aaron$1.
5 b As Emi, remove Bob�s privilege to read Emi�s CUSTOMERS1 table.
c As Trevor, query Emi�s CUSTOMERS1 table. What happens?
6 Enable Emi to start up and shut down the database without the ability
to create a
new database.

check the default tablespace:

select username,default_tablespace
from dba_users;

create tablespace:

SQL> Create tablespace data01


2 datafile 'F:\Oracle\product\10.2.0\oradata\orcl\data01.dbf' size 100M
3 autoextend on next 5M maxsize 200m;

create user emi and assign data01


SQL> create user shan
identified by shan
default tablespace data01
temporary tablespace temp
quota 1M on data01;
User created.

SQL> grant create session,create table to emi;

Grant succeeded.
-----------------------------------------------------------------------------------
---------------

2 a Run the script lab16_02a.sql to connect as Emi and create the


tables CUSTOMERS1 and ORDERS1.
b Connect as SYSTEM and copy the data from SYSTEM.CUSTOMERS to
Emi�s
CUSTOMERS1 table. Verify that the records have been inserted.
c As user SYSTEM give Bob the ability to select from Emi's
CUSTOMERS1 table. What
ha

2 (a) SQL> connect emi/emi;


Connected.

SQL> create table customers1(


2 cust_code VARCHAR2(3),
3 name VARCHAR2(50),
4 region VARCHAR2(5) )
5 TABLESPACE data01;

Table created.

SQL> CREATE TABLE orders1 (ord_id NUMBER(3),


ord_date DATE,
cust_code VARCHAR2(3) )
TABLESPACE data01;

Table created.
-----------------------------------------------------------------

b Connect as SYSTEM and copy the data from SYSTEM.CUSTOMERS to Emi�s


CUSTOMERS1 table. Verify that the records have been inserted.

2 (b) SQL> connect sys as sysdba/oracle


Connected.

create table:

SQL> create table customers(


2 cust_code VARCHAR2(3),
3 name VARCHAR2(50),
4 region VARCHAR2(5) );
create table customers(
c_id varchar2(3),
name varchar2(10));

Table created.

insert into customers values ( 1, 'shanali');


SQL> INSERT INTO shan.customer1
select * from system.customers;

SQL> select * from emi.customer1;

CUS NAME REGIO


--- -------------------------------------------------- -----
1 ru lhr
2 ni guj

---------------------------------------------------------------

2 (c) As user SYSTEM give Bob the ability to select from Emi's CUSTOMERS1 table.
What
happens?

create user bob identified by bob


default tablespace users
temporary tablespace temp
quota 1M on users;

SQL> CONNECT system/password


Connected.
SQL> GRANT select ON shan.customer1 TO bob;
GRANT select ON emi.customers1 TO bob
*
ERROR at line 1:
ORA-01031: insufficient privileges
-----------------------------------------------------------------------------------
-----------------------------

3 Reconnect as Emi and give Bob the ability to select from Emi�s CUSTOMERS1
table.
Also, enable Bob to give the select capability to other users. As user
SYSTEM, examine
the data dictionary views that record these actions.
Hint: Use DBA_TAB_PRIVS to examine.

3.
SQL> CONNECT emi/abcd12
Connected.
SQL> GRANT select ON customer1
TO bob WITH GRANT OPTION;
Grant succeeded.
SQL> CONNECT system/manager
Connected.

SQL> SELECT *
FROM dba_tab_privs
WHERE grantee='bob';
GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRANT HIERARCH
BOB EMI CUSTOMERS1 EMI SELECT YES NO
-----------------------------------------------------------------------------------
--------------------------
4 Create user Trevor identified by diamond1$ with the capability to log
on to the
database.

4.
SQL> create user trevor
identified by trevor;

User created.

SQL> grant create session to trevor;

Grant succeeded.
-----------------------------------------------------------------------------------
--------------------------------------

5 a As Bob, enable Trevor to access Emi�s CUSTOMERS1 table.


Note: A password has expired message will be received due to actions in
Practice
15, step 8. Give Bob the new password aaron$1.
5 b As Emi, remove Bob�s privilege to read Emi�s CUSTOMERS1 table.
c As Trevor, query Emi�s CUSTOMERS1 table. What happens?

5 (a)
SQL> connect bob/bob;
Connected.
SQL> grant select on emi.customers1 to trevor;

Grant succeeded.

5(b)
SQL> connect emi/emi;
Connected.
SQL> revoke select on customers1 from bob;

Revoke succeeded.

5(c)
SQL> connect trevor/trevor;
Connected.
SQL> select * from emi.customers1;
select * from emi.customers1
*
ERROR at line 1:
ORA-00942: table or view does not exist
-----------------------------------------------------------------------------------
----------------------------------------------

6 Enable Emi to start up and shut down the database without the ability to
create a
new database.

SQL> connect sys as sysdba


Enter password: ******
Connected.
SQL> grant sysoper to emi;

Grant succeeded.

You might also like