
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Modify MySQL View with CREATE OR REPLACE VIEW Statement
As we know that we can modify a view by using ALTER VIEW statement but other than that we can also use CREATE OR REPLACE VIEW to modify an existing view. The concept is simple as MySQL simply modifies the view if it already exists otherwise a new view would be created. Following is the syntax of it −
Syntax
CREATE OR REPLACE VIEW view_name AS Select_statements FROM table;
Example
mysql> Create OR Replace VIEW Info AS Select Id, Name, Address, Subject from student_info WHERE Subject = 'Computers'; Query OK, 0 rows affected (0.46 sec)
The above query will create or replace a view ‘Info’. It will be created if not existed already otherwise it would get replaced by a new definition given in the above query.
Advertisements