mysql - 如何在 mySQL 中创建一个空的 VIEW

标签 mysql sql view

我正在尝试使用我定义的列在 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/

相关文章:

mysql - 使用子查询更新多行的多个字段

mysql - 如何结合两个更新

sql - 如何使用游标更新记录

mysql - 我可以使用 MySQL 变量来命名表吗?

mysql - 将数据从一个 prestashop 版本移动到另一个版本

mysql正则表达式获取匹配的第一个字母字符的位置

mysql - 从两个表中选择并总是从一个表中返回

sql - 将 sql View 查询更改为关系代数?

MySQL 存储过程或动态 View

android - 使用动态文本更新 UI