Set Operators:
Procedural Language:(Pl/sql)
The user instructs the system to do a sequence of operations on a database to compute the desired result .
Non-Procedural Language:(sql)
The user describes the desire information without giving any specific procedure for obtaining the information in a database .
Relational algebra:
Relational algebra is a procedural query language which consist of set of operations that take one or two relations as input and produces a new relation as an output .
Table 1:
SQL>create table course(cid number(2) primary key,cname varchar(5));
CID CNAME
---------- -----
11 mca
22 bca
33 mpcs
44 mecs
55 mscs
SQL>create table std(sno number(3),sname varchar(11),city varchar(10),cid number(2),foreign key(cid) references course(cid));
SNO SNAME CITY CID
---------- ----------- ---------- ----------
111 raju vsp 11
222 rani hyd 11
333 vani vzm 22
444 kani rjm 33
555 poni anp 33
1.Union :This operator combines all rows of one table with all the rows of another table except for duplicate tuples .
Syntax : Select<statement1> Union Select <statement2>;
Example :
CID
----------
11
22
33
44
55
2.Union all : It accepts all the duplicate values
Syntax : Select<statement1> Union all Select <statement2>;
Example :
CID
----------
11
22
33
44
55
11
11
22
33
33
Syntax : select <statement 1> intersect select <statement 2>;
Example :
CID
----------
11
22
33
4.Difference : This operator gets all rows in one table that are not found in another table
Syntax : select <statement 1> minus select <statement 2>;
SQL> select cid from course minus select cid from std;
CID
----------
44
55
No comments:
Post a Comment