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

Scripts GovtOffice

The document creates a GovtOffice database with Employee, Department, and OfficeBuilding tables. It inserts sample data into the tables and performs queries and data manipulation operations like SELECT, INSERT, UPDATE, DELETE, and ALTER. Records about employees, departments, and office buildings are added, retrieved, modified, and removed from the tables.

Uploaded by

cs22b1020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Scripts GovtOffice

The document creates a GovtOffice database with Employee, Department, and OfficeBuilding tables. It inserts sample data into the tables and performs queries and data manipulation operations like SELECT, INSERT, UPDATE, DELETE, and ALTER. Records about employees, departments, and office buildings are added, retrieved, modified, and removed from the tables.

Uploaded by

cs22b1020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATE DATABASE GovtOffice;

USE GovtOffice;

CREATE TABLE Employee


( employee_id INT PRIMARY KEY,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(20) NOT NULL,
age INT NOT NULL,
designation VARCHAR(50) NOT NULL);

CREATE TABLE Department


( department_id INT PRIMARY KEY,
department_name VARCHAR(20) NOT NULL,
head_of_department VARCHAR(20) NOT NULL);

CREATE TABLE OfficeBuilding


( building_name VARCHAR(20) NOT NULL,
building_id INT PRIMARY KEY,
capacity_of_employees INT,
no_of_floors INT );

INSERT INTO Employee VALUES


(1001, 'Edward', 'Cullen', 17, 'Intern'),
(1002, 'Isabella', 'Swan', 18, 'Human Relations'),
(1003, 'Taylor', 'Swift', 35, 'Singer'),
(1004, 'Penny', 'Porter', 16, 'Writer'),
(1005, 'Lorelai', 'Gilmore', 40, 'Manager');

INSERT IGNORE INTO Department VALUES


(101, 'IT', 'Taylor Swift'),
(102, 'Administration', 'Lana Del Rey'),
(103, 'Finance', 'Edward Cullen'),
(104, 'Sports', 'Noah Flynn'),
(105, 'Education', 'Bella');

INSERT INTO OfficeBuilding VALUES


('Bloom', 01, 1000, 31),
('Stella', 02, 200, 6),
('Musa', 03, 600, 14),
('Aisha', 04, 120, 9),
('Techna', 05, 150, 13);

SELECT * FROM Employee;


SELECT * FROM Department;
SELECT * FROM OfficeBuilding;

INSERT INTO Employee VALUES


(1006, 'Lana', 'Del Rey', 38, 'Finance'),
(1007, 'Tate', 'Mcrae', 20, 'Finance'),
(1008, 'Kanye', 'West', 51, 'Artist'),
(1009, 'Matt', 'Rife', 67, 'Legal');
INSERT INTO OfficeBuilding VALUES
('Daphne', 06, 170, 76),
('Roxy', 07, 700, 69),
('Sky', 08, 890, 41);

INSERT INTO Employee VALUES


(1010, 'Alex', 'Nilsen', 29, 'IT'),
(1011, 'Sarah', 'Lawrence', 22, 'HR'),
(1012, 'Gracie', 'Abrams', 34, 'IT'),
(1013, 'Sabrina', 'Carpenter', 28, 'HR'),
(1014, 'Jess', 'Danes', 17, 'HR');

SELECT * FROM Employee;

UPDATE Employee SET designation = 'Finance' WHERE employee_id IN (1011,1013,1014);

SELECT * FROM Employee;

INSERT INTO Employee VALUES


(1015, 'Blue', 'Berry', 5, 'HR'),
(1016, 'Christian', 'Grey', 20, 'HR'),
(1017, 'Dakota', 'Johnson', 32, 'HR'),
(1018, 'Travis', 'Kelce', 70, 'HR'),
(1019, 'Meredith', 'James', 11, 'HR');

SELECT * FROM Employee;

DELETE FROM Employee WHERE first_name='Lana' AND last_name='Del Rey';


DELETE FROM Employee WHERE first_name='Tate' AND last_name='Mcrae';
DELETE FROM Employee WHERE first_name='Matt' AND last_name='Rife';

SELECT * FROM Employee;

SELECT * FROM OfficeBuilding;

DELETE FROM OfficeBuilding WHERE building_name = 'Roxy';

SELECT * FROM OfficeBuilding;

ALTER TABLE OfficeBuilding DROP COLUMN no_of_floors;

You might also like