You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Informix数据库中查询指定表的索引列?

查询Informix指定表的索引及对应列

你需要关联sysindexcols和syscolumns系统表来获取索引对应的列信息,替换原有查询语句为以下SQL:

SELECT
    t.tabname AS table_name,
    i.idxname AS index_name,
    c.colname AS column_name,
    ic.colno AS column_position,
    ic.ascdesc AS sort_order -- 'A'代表升序,'D'代表降序
FROM
    systables t
JOIN sysindexes i ON t.tabid = i.tabid
JOIN sysindexcols ic ON i.idxname = ic.idxname AND i.tabid = ic.tabid
JOIN syscolumns c ON t.tabid = c.tabid AND ic.colno = c.colno
WHERE
    t.tabname = 'mytable'
ORDER BY
    i.idxname, ic.colno;

关键表说明:

  • sysindexcols:存储索引与列的映射关系,记录了每个索引对应的列序号和排序方向
  • syscolumns:通过表ID(tabid)和列序号(colno)关联,获取列的实际名称

如果需要区分唯一索引,可以在SELECT中添加i.uniqueflag字段,值为1表示唯一索引,0表示非唯一索引。

内容的提问来源于stack exchange,提问作者samurai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 15:57:18