Get list of column names from a Firebird database table

后端 未结 2 1574
一整个雨季
一整个雨季 2021-02-08 04:49

How do you get a list of the column names in an specific table?

ie.

Firebird table:

| name | id | phone_number |

get list like this:

相关标签:
2条回答
  • 2021-02-08 05:18

    if you want to get a list of column names in an specific table, this is the sql query you need:

    select rdb$field_name from rdb$relation_fields
    where rdb$relation_name='YOUR-TABLE_NAME';
    

    I tried this in firebird 2.5 and it works.

    the single quotes around YOUR-TABLE-NAME are necessary btw

    0 讨论(0)
  • 2021-02-08 05:35

    Get list of columns (comma-separated, order by position) for all table:

    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
    
    0 讨论(0)
提交回复
热议问题