SyedaKashafNaqvi-125-4C T1 DBL

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

THE SUPERIOR UNIVERSITY

SOFTWARE ENGINEERING
DEPARTMENT

TOPIC: “Creating tables in SQL”

Name: Syeda Kashaf Naqvi


Roll no. su92-bssem-f22-125
Submitted to: Asma AbuBakr
Date: October 28, 2024
Assignment #: 1
Section: 4C
Assignment#1

Database Systems
“SQL Queries”
Question#1:
Create an Employee Table:
create database EmployeeDB
use EmployeeDB

CREATE TABLE Employee (


EmployeeNo INT identity(1,1) PRIMARY KEY,
EmployeeName VARCHAR(255),
EmployeeSal DECIMAL(10, 2),
EmployeeCity VARCHAR(255),
EmployeeDob DATE
);

Insert Data:
INSERT INTO Employee (EmployeeName, EmployeeSal, EmployeeCity,
EmployeeDob)
VALUES
('Kashaf', 50000.00, 'Gujranwala', '2004-01-08'),
('Fatima', 90000.00, 'Lahore', '2000-08-28'),
('Rida', 40000.00, 'Gujrat', '2001-06-06')

SELECT * FROM Employee;

UPDATE Employee
SET EmployeeSal = 55000.00
WHERE EmployeeNo = 1 AND EmployeeName = 'Kashaf';

2|Page
Assignment#1

DELETE FROM Employee WHERE EmployeeNo = 1;

DROP TABLE Employee;

Question#2:
Create a Persons Table:
CREATE TABLE Persons (
P_Id INT PRIMARY KEY,
LastName VARCHAR(255),
FirstName VARCHAR(255),
Address VARCHAR(255),
City VARCHAR(255)
);

Insert Data:
INSERT INTO Persons (P_Id, LastName, FirstName, Address, City)
VALUES
(1, 'Hansen', 'Christ', 'Timoteivn 10', 'Sandnes'),
(2, 'Svendson', 'Tove', 'Borgvn 23', 'Sandnes'),
(3, 'Pettersen', 'Michael', 'Storgt 20', 'Stavanger');

3|Page
Assignment#1

INSERT INTO Persons (P_Id, LastName, FirstName, Address, City)


VALUES (4, 'Nilsen', 'Johan', 'Bakken 2', 'Stavanger');

INSERT INTO Persons (LastName, FirstName)


VALUES ('Tjessem', 'Jakob');

UPDATE Persons
SET Address = 'Nissestien 67', City = 'Sandnes'
WHERE P_Id = 5;

4|Page

You might also like