0% found this document useful (0 votes)
7 views1 page

Emp View, Add Email

The document outlines the creation of a database named 'Vinayy' and a table 'Employee' with employee details. It includes inserting employee records, creating a view to display employee information, adding an email column, updating the email addresses, and recreating the view to include the email information. Finally, it retrieves data from the updated view.

Uploaded by

vinaydongre2603
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)
7 views1 page

Emp View, Add Email

The document outlines the creation of a database named 'Vinayy' and a table 'Employee' with employee details. It includes inserting employee records, creating a view to display employee information, adding an email column, updating the email addresses, and recreating the view to include the email information. Finally, it retrieves data from the updated view.

Uploaded by

vinaydongre2603
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/ 1

//emp-View,Add-Email

CREATE DATABASE Vinayy;


USE Vinayy;

CREATE TABLE Employee (


e_id INT PRIMARY KEY,
e_name VARCHAR(50),
e_city VARCHAR(50),
salary DECIMAL(10,2)
);
INSERT INTO Employee (e_id, e_name, e_city, salary) VALUES
(101, 'Vinay', 'Pune', 45000),
(102, 'Vedant', 'Mumbai', 52000),
(103, 'Krushna', 'Nagpur', 30000),
(104, 'Shreyash', 'Nashik', 20000),
(105, 'Aakash', 'Aurangabad', 50000);

CREATE VIEW EmpView AS


SELECT e_id, e_name, e_city
FROM Employee
ORDER BY e_name DESC;

SELECT * FROM EmpView;

ALTER TABLE Employee ADD email VARCHAR(100);

UPDATE Employee
SET email = CASE
WHEN e_name = 'Vinay' THEN '[email protected]'
WHEN e_name = 'Vedant' THEN '[email protected]'
WHEN e_name = 'Krushna' THEN '[email protected]'
WHEN e_name = 'Shreyash' THEN '[email protected]'
WHEN e_name = 'Aakash' THEN '[email protected]'
ELSE NULL
END;

DROP VIEW IF EXISTS EmpView;

CREATE VIEW EmpView AS


SELECT e_id, e_name, e_city, email
FROM Employee
ORDER BY e_name DESC;

SELECT * FROM EmpView;

You might also like