0% found this document useful (0 votes)
49 views4 pages

SQL 23

Object privileges allow users to perform specific operations on database objects and are granted by administrators. Common object privileges in Oracle include insert, update, delete, select, execute, read, and write. Privileges can be granted on tables, views, and other database objects using the GRANT statement. The REVOKE statement removes privileges that were previously granted. Forced views allow creating a view even when the underlying table does not exist.

Uploaded by

Yugandhara rao k
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)
49 views4 pages

SQL 23

Object privileges allow users to perform specific operations on database objects and are granted by administrators. Common object privileges in Oracle include insert, update, delete, select, execute, read, and write. Privileges can be granted on tables, views, and other database objects using the GRANT statement. The REVOKE statement removes privileges that were previously granted. Forced views allow creating a view even when the underlying table does not exist.

Uploaded by

Yugandhara rao k
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/ 4

object privileges:

object privileges are given by either database


developer or database adminstrator

whenever we are using object privilges then only


users allow to perform same operation of the objects

oracle having insert,update,delete,select execute


,read,write object privileges

note:
in oracle we can also use all keyword in place
of insert,delete,select object privileges

syntax:
grant object privileges on objectname to username/
rolename;

SQL> conn scott/tiger;


Connected.
SQL> grant all on emp to andb;

SQL> conn scott/tiger;


Connected.
SQL> grant update(ename) on emp to andb1;

Grant succeeded.

SQL> grant select on emp to andb1;

Grant succeeded.

SQL> conn andb1/andb1;


Connected.
SQL> select * from scott.emp;

SQL> desc user_tab_privs;


Name Null? Type
----------------------------------------- -------- ----------------------------
GRANTEE NOT NULL VARCHAR2(30)
OWNER NOT NULL VARCHAR2(30)
TABLE_NAME NOT NULL VARCHAR2(30)
GRANTOR NOT NULL VARCHAR2(30)
PRIVILEGE NOT NULL VARCHAR2(40)
GRANTABLE VARCHAR2(3)
HIERARCHY VARCHAR2(3)

revoke:
it is used to cancel system or object privilges
permission
syntax:
revoke systemprivilges from username1,username2..
revoke objectprivilges on objectname from user1,user2

same like views:


grant objectprivileges on viewname to username1,
username2....
SQL> create or replace view v20
2 as
3 select empno,ename,sal,deptno from emp;

View created.

SQL> grant all on v20 to andb1;

SQL> conn andb1/andb1;


Connected.
SQL> select * from scott.v20;

SQL> conn sys as sysdba


Enter password:
Connected.
SQL> revoke connect from andb1;

Revoke succeeded.

SQL> conn andb1/andb1;


ERROR:
ORA-01045: user ANDB1 lacks CREATE SESSION privilege; logon denied

Warning: You are no longer connected to ORACLE.

with check option:


if you want to provide conatriant type mechanosam
on views then we are using check option clause

syntax:
create or replace view viewname
as
select * from tablename where condition with check option;

SQL> conn scott/tiger;


Connected.
SQL> create or replace view v22
2 as
3 select * from emp where deptno=10 with check option;

View created.

SQL> insert into v22(empno,ename,deptno) values(1012,'abcd',20);


insert into v22(empno,ename,deptno) values(1012,'abcd',20)
*
ERROR at line 1:
ORA-01402: view WITH CHECK OPTION where-clause violation

SQL> insert into v22(empno,ename,deptno) values(1012,'abcd',10);

1 row created.

with read only view:


when a view having read only clause then those
type of views are called read only views

we cannot perform dml opeartions on read only views

syntax:
create or replace view viewname
as
select statement where clause
with read only;

SQL> create or replace view v30


2 as
3 select * from emp where deptno=10 with read only;

View created.

SQL> insert into v30(empno,ename,deptno) values(1012,'abcd',10);


insert into v30(empno,ename,deptno) values(1012,'abcd',10)
*
ERROR at line 1:
ORA-42399: cannot perform a DML operation on a read-only view

forced view or force view:


in oracle we can also create view without having
table also these type of views are called as
forced views

syntax:
create or replace force view viewname
as
select * from anyname;

SQL> create or replace view v16


2 as
3 select * from sun;
select * from sun
*
ERROR at line 3:
ORA-00942: table or view does not exist

SQL> create or replace force view v16a


2 as
3 select * from sun;

Warning: View created with compilation errors.

SQL> create table sun(empno number(10),ename varchar2(10));

Table created.

SQL> alter view v16a compile;

View altered.

SQL> desc v16a;


Name Null? Type
----------------------------------------- -------- ----------------------------
EMPNO NUMBER(10)
ENAME VARCHAR2(10)

You might also like