我正在尝试使用我定义的列在 mySQL 中创建一个空的 VIEW。
即我想要一个包含以下列的 View :年龄、身份证、性别,但有 0 行。
提前致谢。
最佳答案
给你举个例子:
mysql> create or replace view v_test as
-> select 99 as age,
-> 2147483647 as id,
-> 'F' as gender
-> from dual
-> where false;
Query OK, 0 rows affected (0.04 sec)
mysql> desc v_test;
+--------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------+------+-----+---------+-------+
| age | int(2) | NO | | 0 | |
| id | bigint(10) | NO | | 0 | |
| gender | varchar(1) | NO | | | |
+--------+------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> select * from v_test;
Empty set (0.00 sec)
关于mysql - 如何在 mySQL 中创建一个空的 VIEW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13461028/