gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 01:07:23 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com