Professional Documents
Culture Documents
DBMS Exp 4
DBMS Exp 4
VIEW:
QUERIES:
1. Create view
SQL> create table particulars(sys_no int, gametype varchar(50),amount float(30));
Table created.
SQL> insert into particulars(sys_no, gametype, amount)values('01','Racing','30');
1 row created.
SYNTAX:
CREATE OR REPLACE VIEW view_name AS SELECT column1, column2, ... FROM table_name
WHERE condition;
EXAMPLE
2. Insert in view
SQL> insert into particulars_view(sys_no, gametype)values('08', 'Racing');
1 row created.
917722IT123_VANEESHWARI K
3. Delete in view
SQL> delete from particulars_view where sys_no=03;
1 row deleted.
4. Update view
SQL> update particulars_view set sys_no=03 where sys_no=02;
1 row updated.
5. Drop view
917722IT123_VANEESHWARI K
6. Order by command
SQL> select *from particulars_view order by sys_no;
917722IT123_VANEESHWARI K
8. Execute DML commands in view table and check whether it is reflected in main table.
SQL> insert into particulars_view(sys_no, gametype)values('08', 'Racing');
1 row created.
917722IT123_VANEESHWARI K
IT IS REFELECTED.
9. Execute DML commands in main table and check whether it is reflected in view table.
SQL> insert into particulars(sys_no, gametype, amount)values('12', 'Racing','30');
1 row created.
SQL> select *from particulars;
917722IT123_VANEESHWARI K
IT IS REFLECTED.
10. Do DML operations in view table with read only constraint and tell what happens.
SQL> insert into part_view(sys_no, gametype, amount)values('10', 'Cooking games', '25');
insert into part_view(sys_no, gametype, amount)values('10', 'Cooking games', '25')
ERROR at line 1:
ORA-42399: cannot perform a DML operation on a read-only view
RESULT:
Thus the commands on creation and updation of views were executed and verified
successfully.