![](/img/trans.png)
[英]Error while getting list of column names from a Firebird database table
[英]Get list of column names from a Firebird database table
如何獲取特定表中的列名列表?
IE。
火鳥表:
| name | id | phone_number |
得到這樣的列表:
columnList = ['name', 'id', 'phone_number']
如果您想獲取特定表中的列名列表,這是您需要的 sql 查詢:
select rdb$field_name from rdb$relation_fields
where rdb$relation_name='YOUR-TABLE_NAME';
我在firebird 2.5中試過這個並且它有效。
順便說一句,您的表名周圍的單引號是必要的
獲取所有表的列列表(逗號分隔,按位置排序):
SELECT RDB$RELATION_NAME AS TABLE_NAME, list(trim(RDB$FIELD_NAME),',') AS COLUMNS
FROM RDB$RELATIONS
LEFT JOIN (SELECT * FROM RDB$RELATION_FIELDS ORDER BY RDB$FIELD_POSITION) USING (rdb$relation_name)
WHERE
(RDB$RELATIONS.RDB$SYSTEM_FLAG IS null OR RDB$RELATIONS.RDB$SYSTEM_FLAG = 0)
AND RDB$RELATIONS.rdb$view_blr IS null
GROUP BY RDB$RELATION_NAME
ORDER BY 1
很好地檢查數據庫表中的 YOUR-COLUMN_NAME_fragment ,在 FB 3.0.7 上的 DBeaver 中使用
select
RDB$FIELD_NAME AS "COLUMN",
RDB$RELATION_NAME AS "TABLE"
from
rdb$relation_fields
where
RDB$FIELD_NAME like '%YOUR-COLUMN_NAME_fragment%';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.