有哪些不同的 Informix 列数据类型?

wha*_*ver 2 datatypes informix

我正在编写一个查询,我需要知道一列是否属于“BLOB”类型的列。根据本文档, 41 是“BLOB”类型的列的数量,一般来说。但是,当我查询syscolumns表时,我看到存储 BLOB 数据的列实际上具有 297 的值,就我而言。上面链接的那个页面甚至在其页面上的任何地方都没有数字“297”。我找到了另一页,标题为“数据类型常量”,但在这里,数字“297”甚至没有出现在页面上的任何地方。

文档的数据类型列表似乎不完整。Informix 中是否有(更多)完整的列类型列表?

Jon*_*ler 6

系统目录表coltype列中的值syscolumns主要在 Informix ESQL/C 标头中定义sqltypes.h。这个头在整个 Informix 服务器代码中使用。

coltype列中的值是低位中的 8 位(无符号)整数和高位中的各种标志值的混合。特别是,当使用NOT NULL限定符定义列时,该0x100位被设置 — 对应于“add 256”。还有其他一些您不太可能看到的标志位。

另一个答案中显示的值 4118(十进制)对应于 hex 0x1016;的16(又名22十进制)对应于SQLROW,和0x1000(4096十进制)位对应于#define SQLNAMED 0x1000 /* Named row type vs row type */。该类型是(如另一个答案中所述)“命名行类型”。

考虑一个表:

CREATE TABLE bool_check
(
    b1      BOOLEAN NOT NULL,
    b2      BOOLEAN
);
Run Code Online (Sandbox Code Playgroud)

sqltype列中的值syscolumns是:

  • b1 = 297 = 256 + 41
  • b2 = 41

这些对应于SQLUDTFIXED(类型 41)。该类型SQLBOOL被标记为“由 FE [前端] 使用,......在 BE [后端,意味着数据库服务器] 中不是真正的主要类型”。该collength1两个。

标题的相关部分包括:

SQL 类型:

#define SQLCHAR         0
#define SQLSMINT        1
#define SQLINT          2
#define SQLFLOAT        3
#define SQLSMFLOAT      4
#define SQLDECIMAL      5
#define SQLSERIAL       6
#define SQLDATE         7
#define SQLMONEY        8
#define SQLNULL         9
#define SQLDTIME        10
#define SQLBYTES        11
#define SQLTEXT         12
#define SQLVCHAR        13
#define SQLINTERVAL     14
#define SQLNCHAR        15
#define SQLNVCHAR       16
#define SQLINT8         17
#define SQLSERIAL8      18
#define SQLSET          19
#define SQLMULTISET     20
#define SQLLIST         21
#define SQLROW          22
#define SQLCOLLECTION   23
#define SQLROWREF       24
/*
 * Note: SQLXXX values from 25 through 39 are reserved to avoid collision
 *       with reserved PTXXX values in that same range. See p_types_t.h
 *
 * REFSER8: create tab with ref: referenced serial 8 rsam counter
 *      this is essentially a SERIAL8, but is an additional rsam counter
 *      this type only lives in the system catalogs and when read from
 *      disk is converted to SQLSERIAL8 with CD_REFSER8 set in ddcol_t 
 *      ddc_flags we must distinguish from SERIAL8 to allow both 
 *      counters in one tab
 *
 * SQLSTREAM: Is a synonym for SQLUDTFIXED used by CDR (Enterprise
 *      Replication) code
 */
#define SQLUDTVAR       40
#define SQLUDTFIXED     41
#define SQLSTREAM       SQLUDTFIXED
#define SQLREFSER8      42

/* These types are used by FE, they are not real major types in BE */
#define SQLLVARCHAR     43
#define SQLSENDRECV     44
#define SQLBOOL         45
#define SQLIMPEXP       46
#define SQLIMPEXPBIN    47

/* This type is used by the UDR code to track default parameters,
   it is not a real major type in BE */
#define SQLUDRDEFAULT   48
#define SQLUNKNOWN      51     
#define SQLBIGINT       52
#define SQLBIGSERIAL    53
#define SQLMAXTYPES     54

#define SQLLABEL        SQLINT
Run Code Online (Sandbox Code Playgroud)

标志:

#define SQLNONULL       0x0100  /* disallow nulls       */
/* a bit to show that the value is from a host variable */
#define SQLHOST         0x0200  /* Value is from host var. */
#define SQLNETFLT       0x0400  /* float-to-decimal for networked backend */
#define SQLDISTINCT     0x0800  /* distinct bit         */
#define SQLNAMED        0x1000  /* Named row type vs row type */
#define SQLDLVARCHAR    0x2000  /* Distinct of lvarchar */
#define SQLDBOOLEAN     0x4000  /* Distinct of boolean */
#define SQLCLIENTCOLL   0x8000  /* Collection is processed on client */

/* we are overloading SQLDBOOLEAN for use with row types */
#define SQLVARROWTYPE   0x4000  /* varlen row type */
Run Code Online (Sandbox Code Playgroud)

还有“C-ISAM 类型”,编号为 100 到 125,名称为 aCCHARTYPECDECIMALTYPE。他们在这里不是直接关注的问题。头文件中有 524 行(至少在我查看的版本中)。其中,74 行是空白,315 行包含代码,其余行是纯注释行。AFAIK,这种SQLREFSER8类型是死产的;它不存在于该文件之外。

类型BLOB NOT NULLCLOB NOT NULL在两个编码coltype为297(41 + 256 -同一个BOOLEAN NOT NULL),或SQLUDTFIXEDcollength72(而不是1BOOLEAN NOT NULL)。固定长度数据是一个描述符,提供有关BLOBorCLOB值实际存储位置的所有详细信息。