- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create an empty VIEW in MySQL?
To create an empty view in MySQL, following is the syntax −
create or replace view yourViewName as select yourValue AS yourColumnName, yourValue AS yourColumnName2, . . N from dual where false;
Let us implement the above syntax in order to create an empty view in MySQL −
mysql> create or replace view empty_view as select "John Smith" AS ClientName, "US" AS ClientCountryName, false AS isMarried from dual where false; Query OK, 0 rows affected (0.20 sec)
Let us check the description of the view −
mysql> desc empty_view;
This will produce the following output -
+-------------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+-------------+------+-----+---------+-------+ | ClientName | varchar(10) | NO | | | | | ClientCountryName | varchar(2) | NO | | | | | isMarried | int(1) | NO | | 0 | | +-------------------+-------------+------+-----+---------+-------+ 3 rows in set (0.00 sec)
Let us check the view is empty or not −
mysql> select *from empty_view; Empty set (0.00 sec)
Advertisements