Hello * community,
你好*社区,
Could you please tell me can I get information about column names of a table in 1 row using Firebird
? [*]
您能否告诉我,我可以使用Firebird获取有关一行表格列名的信息吗? [*]
What I'd like to achieve is the following using Postgres
:
我想要实现的是使用Postgres的以下内容:
SELECT * FROM table_name LIMIT 0;
Above statement would return 0 rows, but will contain the header
上面的语句将返回0行,但将包含标题
id | data
---+-------
(0 rows)
[*] I need a similar way (taken from example above) in Firebird to obtain information about columns, since I'm using it external tool, so I need to provide a dynamically built schema for dynamic queries. This implies, that I'm not looking for a solution using system tables like rdb$relation_fields
.
[*]我需要在Firebird中使用类似的方法(取自上面的示例)来获取有关列的信息,因为我使用它是外部工具,所以我需要为动态查询提供动态构建的模式。这意味着,我不是在寻找使用rdb $ relation_fields等系统表的解决方案。
Adding WHERE
condition with dummy value does not apply in my case. I'm looking for something like SELECT FIRST 0 ...
. Does it even exist?
在我的情况下,添加具有虚拟值的WHERE条件不适用。我正在寻找像SELECT FIRST 0这样的东西....它甚至存在吗?
edited: Yes, it does. Interactive Firebird Client doesn't show up anything, but it does indeed return the "header". This may be confusing for some of us that use psql console which yields 0 rows, but does contain the "header" itself.
编辑:是的,确实如此。交互式Firebird客户端不会显示任何内容,但确实会返回“标题”。对于我们这些使用psql控制台产生0行但我们确实包含“标题”本身的人来说,这可能会令人困惑。
2 个解决方案
#1
1
Firebird supports limiting the result set - but the syntax is a bit different:
Firebird支持限制结果集 - 但语法有点不同:
SELECT FIRST 0 *
FROM table_name;
This is part of the Firebird FAQ: http://www.firebirdfaq.org/faq111/
这是Firebird常见问题解答的一部分:http://www.firebirdfaq.org/faq111/
#2
0
What about this?
那这个呢?
select * from (
[any query here]
) where 1=0
#1
1
Firebird supports limiting the result set - but the syntax is a bit different:
Firebird支持限制结果集 - 但语法有点不同:
SELECT FIRST 0 *
FROM table_name;
This is part of the Firebird FAQ: http://www.firebirdfaq.org/faq111/
这是Firebird常见问题解答的一部分:http://www.firebirdfaq.org/faq111/
#2
0
What about this?
那这个呢?
select * from (
[any query here]
) where 1=0