Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

sql

What is SQL DROP VIEW?

Sarvech Qadir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

What is SQL VIEW?

SQL VIEW is a type of table that only exists virtually, i.e., it has no physical existence. In simpler words, it is a virtual table that is created by applying a query to another table. Such tables are created using the SQL CREATE VIEW command shown below:

CREATE VIEW myview AS   
SELECT columns  
FROM tables  
WHERE conditions; 

Deleting a VIEW

If a user wants to delete a SQL VIEW, they can do so with the SQL DROP VIEW command:

DROP VIEW myview  

The VIEW can be permanently deleted using the DROP VIEW command.

Code

CREATE TABLE Chocolates (
Choc_Name varchar(255),
Price int
);
/* Created a table, now let's insert values */
INSERT INTO Chocolates (Choc_Name, Price)
VALUES ('twix', 20);
INSERT INTO Chocolates (Choc_Name, Price)
VALUES ('Mars', 30);
INSERT INTO Chocolates (Choc_Name, Price)
VALUES ('Snickers', 35);
INSERT INTO Chocolates (Choc_Name, Price)
VALUES ('Hersheys', 25);
INSERT INTO Chocolates (Choc_Name, Price)
VALUES ('Nutella', 15);
/* Create a view */
CREATE VIEW Price_greater AS
SELECT Choc_Name, Price
FROM Chocolates
WHERE Price >= 25;
SELECT * FROM Price_greater;
/* Drop view */
DROP VIEW Price_greater;

RELATED TAGS

sql

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring