

Once you have a View in your database, it will be listed on the left-column (you might have to click the refresh button above for it to appear) along with your tables. If you are wanting to edit a view, check the “OR REPLACE” box at top and fill in the ‘VIEW name’ field with the exact name of the View you are wanting to update. Hit ‘Go’ and your View will be updated. (I would advise getting it right when just doing queries for simplicity sake.) If you want their original names, leave the field blank. The query you ran will be copied into the ‘AS’ field and you can modify it if you wish. If you are creating a new view, you should fill out the ‘VIEW name’ field and you can use the ‘Column names’ field if you would like the column names to be different from their original names in the View.
#MYSQL CREATE VIEW EXAMPLES CODE#
Offices USING (officeCode) Code language: SQL (Structured Query Language) ( sql ) This statement creates a view named employeeOffices based on the employees and offices tables: CREATE VIEW employeeOffices AS SELECT

This example uses the DROP VIEW statement to drop the customerPayments view: DROP VIEW IF EXISTS customerPayments Ĭode language: SQL (Structured Query Language) ( sql ) 2) MySQL DROP VIEW – drop multiple views example This statement creates a view named customerPayments based on the customers and payments tables: CREATE VIEW customerPaymentsĬustomerName Code language: SQL (Structured Query Language) ( sql ) Let’s take some examples of using the DROP VIEW statement. Note that in MySQL 5.7 or earlier, the DROP VIEW returns an error if there is any non-existing view.

However, if you use the IF EXISTS option, the DROP VIEW statement will generate a NOTE for each non-existing view. If the list contains a view that doesn’t exist, the DROP VIEW statement will fail and won’t delete any view. In this syntax, you specify a list of comma-separated views after the DROP VIEW keywords. To remove multiple views in a single statement, you use the following syntax: DROP VIEW view_name1. The optional IF EXISTS option conditionally removes the view only if it exists. In this syntax, you specify the name of the view that you want to drop after the DROP VIEW keywords. Here’s the basic syntax of the DROP VIEW statement: DROP VIEW view_name Ĭode language: SQL (Structured Query Language) ( sql ) The DROP VIEW statement deletes a view completely from the database.

Introduction to the MySQL DROP VIEW statement
#MYSQL CREATE VIEW EXAMPLES HOW TO#
Summary: in this tutorial, you will learn how to use the MySQL DROP VIEW statement to delete a view from the database.
