You are on page 1of 3

create a table Employee with the following specifications

ID integer
First_name char/varchar
Last_name "/"
DOB date
salary decimal/integer

create table Employee


(ID integer not null primary Key,
First_name char(50),
Last_name char(50),
DOB date,
salary integer(7));

create table Job


(Job_ID integer not null primary Key,
Job_description varchar(25),
Hire_date date,
ID integer references Employee(ID));

create table Emp


(Ecode integer not null primary key,
Ename char(50),
Grade char(1) DEFAULT 'B',
Gross salary decimal);
_____________________________________________________________________________
Tuples are rows
Attributes are columns
Degree is the no. of attributes
Cardinality ios the no. of tuples
_____________________________________________________________________________

create table Item


(Code integer not null primary key,
Iname varchar(50),
Qty integer,
Price integer,
Company varchar(50),
Tcode varchar(4) references Traders(Tcode));
create table Traders
(Tcode varchar(4),
Tname char(50),
City char(50));
______________________________________________________________________________

INSERT INTO Item(Code,Iname,Qty,Price,Company,Tcode)


Values(1001,'DIGITAL PAD 12I',120,11000,'XENITA','T01');
INSERT INTO Item(Code,Iname,Qty,Price,Company,Tcode)
Values(1004,'LED SCREEN 40',70,38500,'SANTORA','T02');
INSERT INTO Item(Code,Iname,Qty,Price,Company,Tcode)
Values(1006,'CAR GPS SYSTEM',50,21500,'GEOKNOW','T01');
INSERT INTO Item(Code,Iname,Qty,Price,Company,Tcode)
Values(1003,'DIGITAL CAMERS 4X',180,8000,'DIGICHECK','T02');
____________________________________________________________________________

Select *From Items where Code=1006;


____________________________________________________________________________
Display all inforamtion T02
Select *From Items where Tcode='T02';
____________________________________________________________________________
To display date
Select curdate();
____________________________________________________________________________
Select 45*75 From dual;
____________________________________________________________________________

Projection operation-only few attributes are selected


Select Adno,Name From Students where Class=12;
_____________________________________________________________________________

Select Name,Class,Section From Student where section='A';


Select *From Students where Fees>=3000;
Select *From Students where Name='Rsohan Saini';

Select Adno,Name,Average*5 As Total_Marks From Student;

<>-not equal to

write a query to display employee number name and salary and


salary into 12 as annual salry

write a query to display all details of employees whose salary is bw 2500-4000

Select epmno,ename,sal,sal*12asAnnual_Salary From Empl;


Select ename From Empl where comm>sal;

display all detials of salesmen who have not been assigned dept

Select *From Empl where job='SALESMAN' and deptno IS NULL;


Select ename,sal From Empl where sal>=2200;
Select ename,sal From Empl where sal NOT BETWEEN 2500 and 4000;
Select ename,job,sal From Empl where mgr IS NULL;
Select *From Empl where job<>'MANAGER';

Select Name From STUDENT where GAME='C' or SUPW='C';


Select DISTINCT GAME From STUDENT;
Select SUPW From STUDENT where NAME LIKE 'A%';

Select NAME From SPORTS where Game1=Game2;


Select Games From SPORTS where NAME LIKE 'A%';

Select Title From Library where type='PROG' and Pub='BPB';


Select Title From Library order by Price;
Select *From Library where order by Price DESC;
Select ename from Empl where year(hiredate) BETWEEEN 1991 and 1992;
Select ename,min(hiredate) from Empl;
Update Empl set sal=sal+500 where job=MANAGER;
Delete from item where iname='powder';
Update ITEM set PRICE=PRICE+PRICE/10;
Select *From CLUB where SPORTS='SWIMMING'
Select COACHNAME,DATEOFAPP order by DATEOFAPP DESC;

You might also like