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

DBMS

The document contains SQL commands for creating and manipulating three tables: STUDENT208, DEPARTMENTS, and EMPL208. It includes commands for inserting data, selecting specific records, updating values, and altering table structures. Additionally, it provides queries for retrieving student and employee information based on various conditions.

Uploaded by

Barnali Das
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

DBMS

The document contains SQL commands for creating and manipulating three tables: STUDENT208, DEPARTMENTS, and EMPL208. It includes commands for inserting data, selecting specific records, updating values, and altering table structures. Additionally, it provides queries for retrieving student and employee information based on various conditions.

Uploaded by

Barnali Das
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

CREATE TABLE STUDENT208(NAME VARCHAR(25),


ROLL NUMBER(3),
ADDRESS VARCHAR(30),
PHNO NUMBER(10));
2. DESC STUDENT208;
3. INSERT INTO STUDENT208 VALUES('BARNALI',208,'KANKINARA',6289196805);
INSERT INTO STUDENT208 VALUES('PREETI',96,'KANKINARA',9007264474);
INSERT INTO STUDENT208 VALUES('ANJANA',001,'KOLKATA',9330191515);
INSERT INTO STUDENT208 VALUES('GOURAB',065,'JAGADDAL',8777054878);
4. SELECT * FROM STUDENT208;
5. SELECT NAME,ROLL FROM STUDENT208;
6. SELECT NAME,ROLL FROM STUDENT208 WHERE ADDRESS='KANKINARA';

ASSIGNMENT-1
1. Create a table inSQL.Table name is Departments and attributes are deptno, name,
location
CREATE TABLE DEPARTMENTS(DEPTNO NUMBER,
NAME VARCHAR2(20),
LOCATION VARCHAR(30));
2. Write a SQL statement to display the schema of Departments table.
DESC DEPARTMENTS;
3. Write a SQL statement to insert these rows into Departments Table.
INSERT INTO DEPARTMENTS VALUES(1,'CSE','KANKINARA');
INSERT INTO DEPARTMENTS VALUES(2,'ECE,'JAGADDAL');
INSERT INTO DEPARTMENTS VALUES(3,'CST,'KOLKATA');
4. Write a SQL statement to display all the records in the Departments Table.
SELECT * FROM DEPARTMENTS;
5. Write a SQL statement to display only deptno from Departments.
SELECT DISTINCT DEPTNO FROM DEPARTMENTS;
6. Write a SQL statement to display only deptno from Departments table.
SELECT NAME,LOCATION FROM DEPARTMENTS;
7. Write a SQL statement to add new column ‘no_of_emp’ in existing Departments table.
ALTER TABLE DEPARTMENTS ADD NO_OF_EMP NUMBER;
8. Write a SQL statement to update Departments table to add value in
mo_of_emp=11,column where deptno=1
UPDATE DEPARTMENTS SET NO_OF_EMP=11 WHERE DEPTNO=1;
9. Write a SQL statement to display Departments table.
SELECT * FROM DEPARTMENTS;
ASSIGNMENT-2
1. Create a empl208 table with column (eid,ename,eaddress,esal).
CREATE TABLE EMPL208( EID NUMBER(3),
ENAME VARCHAR(30),
EADDRESS VARCHAR(50),
ESAL NUMBER(10));
2. Insert values.
INSERT INTO EMPL208 VALUES(209,'A K GHOSH','MUMBAI',30000);
INSERT INTO EMPL208 VALUES(249,'B DAS','KOLKATA',50000);
INSERT INTO EMPL208 VALUES(219,'P SHAW','KOLKATA',30000);
INSERT INTO EMPL208 VALUES(239,'P DAS','KALYANI',10000);
INSERT INTO EMPL208 VALUES(229,'G DEBNATH','KALYANI',50000);
INSERT INTO EMPL208 VALUES(259,'a DAS','KOLKATA',10001);
3. Select the name of the employee whose salary is 10001 and address in Kolkata.
SELECT ENAME FROM EMPL208 WHERE ESAL=10001 AND
EADDRESS='KOLKATA';

4. Select the name of the employee whose salary is greater than 10000 and address
in Kolkata.
SELECT ENAME FROM EMPL208 WHERE ESAL>10000 AND
EADDRESS='KOLKATA';

5. Select the name of the employee whose salary is greater than 10000.
SELECT ENAME FROM EMPL208 WHERE ESAL>10000;

6. Find the salary of the employee id is 209.


SELECT ESAL FROM EMPL208 WHERE EID=209;

7. . Find the address and name of the employee whose salary is greater than 30000.
SELECT ENAME FROM EMPL208 WHERE ESAL>30000;
8. Find the employee id and salary whose belongs to Mumbai.
SELECT EID,ESAL FROM EMPL208 WHERE EADDRESS='MUMBAI';

9. Update the address of Mr. AK Ghosh. New address will be Kolkata.


UPDATE EMPL208 SET EADDRESS='KOLKATA' WHERE ENAME='A K GHOSH';
SELECT * FROM EMPL208;

10. Find all the employee names.


SELECT ENAME FROM EMPL208;

11. Find the employee id and name salary is greater than 30000 and less than 50000.
SELECT EID,ENAME FROM EMPL208 WHERE 30000<ESAL AND ESAL<50000;

12. Find the address and salary of employee id 249.


SELECT EADDRESS,ESAL FROM EMPL208 WHERE EID=249;
ASSIGNMENT-3
1. Create a table student103 with attributes first name, middle name, lastname, subject,
age, game and insert some values.
CREATE TABLE STUDENT2008(FNAME VARCHAR(20),
MNAME VARCHAR(10),
LNAME VARCHAR(20),
SUBJECT VARCHAR(10),
AGE NUMBER(3),
GAME VARCHAR(20));

2. Insert into student103.


INSERT INTO STUDENT2008 VALUES('RIMI','KUMARI','DUTTA','MATH',15,'NULL');
INSERT INTO STUDENT2008 VALUES('ANIK','KUMAR','DAS','PHYSICS',16,'FOOTBALL');
INSERT INTO STUDENT2008 VALUES('POM','KUMARI','DAS','CS',10,'FOOTBALL');
INSERT INTO STUDENT2008 VALUES('GOURAB','KUMAR','DEBNATH','CS',14,'CRICKET');

3. Find the first name and last name of the student whose subject is maths or physics.
SELECT FNAME,LNAME FROM STUDENT2008 WHERE SUBJECT='MATH' OR
SUBJECT='PHYSICS';

4. Find the first name last name and age of the student whose age is between 10 to 15.
SELECT FNAME,LNAME,AGE FROM STUDENT2008 WHERE AGE>10 AND AGE<15;

5. Find first name,lastname and game of the student whose game is not football.
SELECT FNAME,LNAME,GAME FROM STUDENT2008 WHERE GAME='FOOTBALL';

6. Find the first name,last name and game of the student whose age is between 10 to 15 or
game is not football.
SELECT FNAME,LNAME,GAME FROM STUDENT2008 WHERE AGE>10 AND AGE<15;
7. Find the first name and the last name of the student whose first name starts with r.
SELECT FNAME,LNAME FROM STUDENT2008 WHERE FNAME LIKE 'R%';

8. Find the first name and the last name of the student whose first name's second letter is
-n.
SELECT FNAME,LNAME FROM STUDENT2008 WHERE FNAME LIKE '_N%';

9. Find the first name,last name and age of the student whose age is between 10 to 15
using BETWEEN and AND keywords.
SELECT FNAME,LNAME,AGE FROM STUDENT2008 WHERE AGE BETWEEN 10 AND 15;

10. Find first name,last name of the student whose subject is maths or cs using IN
keywords.
SELECT FNAME,LNAME FROM STUDENT2008 WHERE SUBJECT IN('MATH','CS');

11. Find the first name, last name of the student whose game is null.
SELECT FNAME,LNAME FROM STUDENT2008 WHERE GAME='NULL';

12. Find first, last name and subject of the student whose subject is neither maths nor
physics using NOT IN keywords.
SELECT FNAME,LNAME FROM STUDENT2008 WHERE SUBJECT NOT
IN('MATH','PHYSICS');

You might also like