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

不同RHEL版本下Informix SQLCMD输出格式差异技术问询

Fixing info columns Output Format Change in RHEL7 Informix dbaccess

I’ve run into this exact format shift between RHEL6 and RHEL7 Informix environments before—dbaccess updated its info columns output to be more human-readable, which breaks scripts relying on the old machine-friendly pipe-separated format. Here are the most reliable fixes:

The info columns command is an interactive helper tool, and its output isn’t guaranteed to stay consistent across versions. Instead, query Informix’s system tables directly—this is the supported, stable way to get column metadata.

Example Command

Replace your original echo "info columns for <table>" | dbaccess ... with this command, which generates output identical to your old RHEL6 format:

echo "SELECT colno || '|' || colname || '|' || coltype || '|' || collength || '|' || nullable 
      FROM syscolumns 
      WHERE tabid = (SELECT tabid FROM systables WHERE tabname = '<YOUR_TABLE_NAME>') 
      ORDER BY colno;" | dbaccess <YOUR_DATABASE> 2>&1 | grep -v -E "^$|Database selected\.|Row\(s\) retrieved\."

Key Notes:

  • Informix stores table names in uppercase in systables by default. If your table was created with lowercase letters, adjust the WHERE clause to LOWER(tabname) = '<your_table_name>'.
  • Add AND owner = '<TABLE_OWNER>' to the systables subquery if you have duplicate table names across different owners.

2. Force Compact Output (If You Must Use info columns)

Some newer dbaccess versions support a -raw flag to disable formatted, human-readable output. Try modifying your command like this:

echo "info columns for <table>" | dbaccess -raw <YOUR_DATABASE> 2>&1 | head

If -raw doesn’t work for your version, check the dbaccess man page (man dbaccess) for other output-formatting flags—though this approach is less reliable long-term than using system tables.

Why This Works

By querying syscolumns and systables, you’re using Informix’s official metadata API, which won’t change unexpectedly between OS upgrades. The string concatenation ensures you get the exact pipe-separated format your existing scripts expect.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:10:14