0% found this document useful (0 votes)
3 views

assignment-1 dbms

The document outlines SQL commands for creating and managing two tables: 'dept' and 'employee'. It includes commands for creating tables, inserting data, altering tables, updating records, and various select queries to retrieve information. The document serves as an assignment for practicing SQL operations related to department and employee management.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

assignment-1 dbms

The document outlines SQL commands for creating and managing two tables: 'dept' and 'employee'. It includes commands for creating tables, inserting data, altering tables, updating records, and various select queries to retrieve information. The document serves as an assignment for practicing SQL operations related to department and employee management.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT-1

1 a) create table dept( deptname varchar(14), deptcode int(4) primary key, no_of_student int(10));

1 b) insert into dept ( deptname, deptcode, no_of_student) values( 'cse', 1, 200);

insert into dept ( deptname, deptcode, no_of_student) values( 'ece', 2, 100);

insert into dept ( deptname, deptcode, no_of_student) values( 'ee', 3, 188);

insert into dept ( deptname, deptcode, no_of_student) values( 'it', 4, 88);

insert into dept ( deptname, deptcode, no_of_student) values( 'me', 5, 240);

insert into dept ( deptname, deptcode, no_of_student) values( 'ce', 6, 74);

insert into dept ( deptname, deptcode, no_of_student) values( 'mca', 7, 94);

insert into dept ( deptname, deptcode, no_of_student) values( 'bca', 8, 104);

insert into dept ( deptname, deptcode, no_of_student) values( 'bt', 9, 70);

insert into dept ( deptname, deptcode, no_of_student) values( 'ci', 10, 60);

1 c) desc dept;

1 d) select deptname, deptcode from dept;

1 e) select deptname from dept where no_of_student>=50;

1 f) select*from dept;

1 g) alter table dept add no_of_labs int;

1 h) select*from dept;

1 i) UPDATE DEPT SET NoOfLabs=3 WHERE Deptcode=01;

UPDATE DEPT SET NoOfLabs=3 WHERE Deptcode=02;

UPDATE DEPT SET NoOfLabs=2 WHERE Deptcode=03;

UPDATE DEPT SET NoOfLabs=2 WHERE Deptcode=04;

UPDATE DEPT SET NoOfLabs=1 WHERE Deptcode=05;

UPDATE DEPT SET NoOfLabs=4 WHERE Deptcode=06;

UPDATE DEPT SET NoOfLabs=3 WHERE Deptcode=07;

UPDATE DEPT SET NoOfLabs=2 WHERE Deptcode=08;

UPDATE DEPT SET NoOfLabs=2 WHERE Deptcode=09;

UPDATE DEPT SET NoOfLabs=2 WHERE Deptcode=10;

1 j) select*from dept;
ASSIGNMENT-1
2 a) create table employee( empid int(4) primary key, empname varchar(10), dob date, address
varchar(20), joindate date, mobileno int(10), deptno int(3), salary int(7), job char(10) );

b) insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job)
values ( 1, 'sonal', '2000-12-20', 'gujrat', '2022-09-14', 527891432, 1, 30000, 'analyst');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 2, 'monica', '2000-12-29', 'gujrat', '2022-09-17', 827891432, 2, 30000, 'analyst');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 3, 'manas', '2001-09-29', 'delhi', '2022-07-17', 827891832, 3, 80000, 'analyst')

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 4, 'adrit', '2000-09-02', 'delhi', '2020-07-17', 827891838, 4, 90000, 'developer');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 5, 'manasa', '2002-09-02', 'delhi', '2020-08-10', 827891898, 1, 90000, 'developer');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 6, 'soham', '1998-09-02', 'harayana', '2016-08-11', 827891876, 2, 100000, 'developer');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 7, 'manavendra','1997-09-02', 'bangalore', '2016-08-10', 827890676, 5, 100000,'developer');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 8, 'sayantani', '1997-09-08', 'bangalore', '2015-08-10', 827890096, 5, 80000, 'consultant');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 9, 'urmi', '1998-09-08', 'bangalore', '2015-08-11', 827090096, 6, 80000, 'consultant');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 10, 'bipasa', '1998-09-07', 'bangalore', '2015-08-12', 827090076, 6, 90000, 'consultant');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 11, 'trip ', '1998-10-06', 'hyderabad', '2014-08-14', 877090076, 2, 60000, 'consultant');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 12, 'monisha', '1998-08-06', 'hyderabad', '2014-09-15', 877090176, 7, 60000, 'consultant');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 13, 'manali', '1998-08-12', 'hyderabad', '2014-09-17', 876090176, 8, 70000, 'consultant');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 14, 'alia', '1998-09-12', 'hyderabad', '2014-09-19', 876090106, 9, 90000, 'consultant');

insert into employee( empid, empname, dob, address, joindate, mobileno, deptno, salary, job) values
( 15, 'ayush', '1998-09-11', 'hyderabad', '2015-09-19', 876090104, 10, 70000, 'consultant');

c) select * from employee;

d) select salary from employee where salary = (salary +0.1*salary) and deptno=3;

e) update employee set salary = salary*1.10 where deptno=3;


ASSIGNMENT-1
f) update employee set empname = 'joe', mobileno= '89763004

53' where empid = 105;

g) select mestampdiff(year, dob, curdate()) as age from employee;

h) select empname from employee where salary>=20000;

i) select empname, salary from employee where salary betwee

n 15000 and 35000;

j) select * from employee where empname= "a%";

k) select * from employee where empname= "%m";

l) select * from employee where empname like '%h%';

m) select * from employee where salary> min(salary) and job like 'a%';

n) select job,sum(salary) as total_salary from employee group by job;

o) select count(empid) as no_of_employees, deptno from empl

oyee group by deptno;

p) select salary from employee where deptno!=2 and salary<all(

select salary from employee where deptno=2);

q) select empid,empname, salary from employee where salary>(se

lect avg(salary) from employee);

You might also like