如何在MySQL中创建一个空的VIEW?
要在MySQL中创建一个空视图,以下是语法-
create or replace view yourViewName as select yourValue AS yourColumnName, yourValue AS yourColumnName2, . . N from dual where false;
让我们实现上述语法,以便在MySQL中创建一个空视图-
mysql> create or replace view empty_view as select "John Smith" AS ClientName, "US" AS ClientCountryName, false AS isMarried from dual where false;
让我们检查视图的描述-
mysql> desc empty_view;
这将产生以下输出-
+-------------------+-------------+------+-----+---------+-------+ | 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)
让我们检查视图是否为空-
mysql> select *from empty_view; Empty set (0.00 sec)