Create synonym and sequence

1)       Create synonyms s1 for table student.
Ø  create synonym s1 for stu;

2)       Insert the value into the table using synonym.
Ø  insert into s1 values(1206,'hemangi','89','EC-12','chikhali'); 

3)       Retrieve the data using Synonym.
Ø  select * from s1;

4)       Modify the record where students reg_no is 1218 and city is navasari.
Ø  update s1 set name='renuka' where reg_no=1218 and city='navasari';

5)      Drop the Synonym.

Ø  drop synonym s1;

6)       Create sequence that start from 0 to 10 in ascending value.
Ø  create sequence seq  minvalue 0  maxvalue 10  start with 0  increment by 1;

7)       Using the sequence insert the value of registration no into the student table.
Ø  insert into stu values(seq.nextval,'jenny','88','EC-12','vadodara');

8)       Display current value of sequence.
Ø  select seq.currval from dual;



9)       Display next value of sequence.
Ø  select seq.nextval from dual;

10)       Alter the sequence and increment value by 10.
Ø  alter sequence seq increment by 10;

11)       Drop the Sequence.
Ø  drop sequence seq;

Post a Comment

0 Comments