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

Assignment Lab 1

The document outlines the creation and manipulation of two databases: 'employee_database' and 'STUDENT_database'. It includes SQL commands for creating tables, inserting records, querying data, deleting entries, and altering table structures. The document demonstrates various SQL operations on employee and student records, including filtering based on age and salary or fees.

Uploaded by

sai713194
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

Assignment Lab 1

The document outlines the creation and manipulation of two databases: 'employee_database' and 'STUDENT_database'. It includes SQL commands for creating tables, inserting records, querying data, deleting entries, and altering table structures. The document demonstrates various SQL operations on employee and student records, including filtering based on age and salary or fees.

Uploaded by

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

ASSIGNMENT LAB 1:

122CS0079

LEK NATH GHALLEY

1.

#CREATE DATABASE employee_database


#USE employee_database
CREATE TABLE EMPLOYEE(employee_id varchar(20) primary key, name
varchar(30),age int CHECK(age>0),salary int , department varchar(20))

INSERT INTO EMPLOYEE VALUES('EXE1001', 'Adiya', 25,30000, 'Executive')


INSERT INTO EMPLOYEE VALUES('ACC1002', 'Aditya', 28 ,31000, 'Accountant')
INSERT INTO EMPLOYEE VALUES('SAL1003', 'Priyanka', 30 ,32000,' Salesman')
INSERT INTO EMPLOYEE VALUES('EXE1004', 'Anmol', 35, 31000, 'Executive')
INSERT INTO EMPLOYEE VALUES('ACC1005' ,'Rahul' ,31 ,29000 ,'Accountant')
INSERT INTO EMPLOYEE VALUES('SAL1006 ','Shubham', 29 ,27000 ,'Salesman')
INSERT INTO EMPLOYEE VALUES('SAL1007','Sam ',33, 32000 ,'Salesman ')
INSERT INTO EMPLOYEE VALUES('SAL1008', 'Rohan', 33, 28000, 'Salesman')
INSERT INTO EMPLOYEE VALUES('ACC1009',' Priya', 23, 35000, 'Accountant')
INSERT INTO EMPLOYEE VALUES('EXE1010', 'Kabir', 29, 26000 ,'Executive')
SELECT *FROM EMPLOYEE

SELECT *FROM EMPLOYEE WHERE age<30


SELECT employee_id,name FROM EMPLOYEE WHERE age <= 30 AND salary < 32000

SELECT *FROM EMPLOYEE WHERE age >30 or salary > 35000

DELETE FROM EMPLOYEE WHERE name =' Priya'


INSERT INTO EMPLOYEE VALUES('EXE 1011' , 'Raj ', 24, 30000,' Executive')

DELETE FROM EMPLOYEE WHERE age >=35 AND salary <= 50000

ALTER TABLE EMPLOYEE DROP COLUMN salary;


DROP TABLE EMPLOYEE

2.

#CREATE DATABASE STUDENT_database


#USE STUDENT_database
CREATE TABLE STUDENT(student_id varchar(20) primary key, name varchar(30),age
int CHECK(age>0),fees int , department varchar(20))
INSERT INTO STUDENT VALUES('CSE1001','Avinash', 26 ,930000 ,'CSE')
INSERT INTO STUDENT VALUES('ACC1002', 'Tejas',23 ,50000 ,'Accountant')
INSERT INTO STUDENT VALUES('ECE1003',' Vivek', 30, 900000,' ECE')
INSERT INTO STUDENT VALUES('CSE1004', 'Jitendra', 25, 930000,'CSE')
INSERT INTO STUDENT VALUES('ACC1005',' Sweta ',31, 50000,' Accountant')
INSERT INTO STUDENT VALUES('ECE1006', 'Sweety', 26 ,900000 ,'ECE')
INSERT INTO STUDENT VALUES('ECE1007', 'Ravi', 24, 900000,'ECE ')
INSERT INTO STUDENT VALUES('ECE1008',' Rahul', 25, 900000 ,'ECE')
INSERT INTO STUDENT VALUES('ACC1009', 'Kartik', 29 ,50000 ,'Accountant')
INSERT INTO STUDENT VALUES('CSE1010',' Pooja', 28, 930000 ,'CSE')

SELECT *FROM STUDENT

SELECT *FROM STUDENT WHERE age < 30


SELECT *FROM STUDENT WHERE name='Avinash'

SELECT *FROM STUDENT WHERE age >24 AND age<28

SELECT student_id,name FROM STUDENT WHERE age <= 25 and fees < 900000
SELECT *FROM STUDENT WHERE department='CSE'

DELETE FROM STUDENT WHERE name =' Pooja'

DELETE FROM STUDENT WHERE age >=35 and fees <= 50000

SELECT*FROM STUDENT WHERE name=' Vivek'


SELECT*FROM STUDENT WHERE name=' Rahul'
ALTER TABLE STUDENT DROP COLUMN department
SELECT *FROM STUDENT
DROP TABLE STUDENT

You might also like