AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 289296
Accepted
wha7ever
wha7ever
Asked: 2021-04-06 06:33:49 +0800 CST2021-04-06 06:33:49 +0800 CST 2021-04-06 06:33:49 +0800 CST

Informix 列数据类型有哪些?

  • 772

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

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

datatypes informix
  • 2 2 个回答
  • 723 Views

2 个回答

  • Voted
  1. Best Answer
    Jonathan Leffler
    2021-04-06T09:52:12+08:002021-04-06T09:52:12+08:00

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

    列中的值coltype是低位中的 8 位(无符号)整数和高位中的各种标志值的混合。特别是,当使用NOT NULL限定符定义列时,0x100会设置该位 — 对应于“添加 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
    );
    

    sqltype列中的值为syscolumns:

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

    这些对应于SQLUDTFIXED(类型 41)。该类型SQLBOOL被标记为“由 FE [前端]使用,......不是 BE [后端,表示数据库服务器]中真正的主要类型”。两者collength都是1。

    标题的相关部分包括:

    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
    

    标志:

    #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 */
    

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

    类型BLOB NOT NULL和CLOB NOT NULL都被编码coltype为 297(41 + 256 - 相同的 a BOOLEAN NOT NULL),或72 (与SQLUDTFIXEDfor相对)。固定长度数据是一个描述符,它提供有关or值实际存储位置的所有详细信息。collength1BOOLEAN NOT NULLBLOBCLOB

    • 8
  2. wha7ever
    2021-04-06T06:33:49+08:002021-04-06T06:33:49+08:00

    下面是 Informix 数据类型的列表:

    0 = CHAR 
    1 = SMALLINT 
    2 = INTEGER 
    3 = FLOAT 
    4 = SMALLFLOAT 
    5 = DECIMAL 
    6 = SERIAL 
    7 = DATE 
    8 = MONEY 
    9 = NULL 
    10 = DATETIME 
    11 = BYTE 
    12 = TEXT 
    13 = VARCHAR 
    14 = INTERVAL 
    15 = NCHAR 
    16 = NVARCHAR
    17 = INT8 
    18 = SERIAL8 
    19 = SET 
    20 = MULTISET 
    21 = LIST 
    22 = Unnamed ROW 
    40 = LVARCHAR 
    41 = CLOB 
    43 = BLOB 
    44 = BOOLEAN 
    256 = CHAR 
    257 = SMALLINT 
    258 = INTEGER 
    259 = FLOAT 
    260 = REAL 
    261 = DECIMAL 
    262 = SERIAL 
    263 = DATE 
    264 = MONEY 
    266 = DATETIME 
    267 = BYTE 
    268 = TEXT 
    269 = VARCHAR 
    270 = INTERVAL 
    271 = NCHAR 
    272 = NVARCHAR
    273 = INT8 
    274 = SERIAL8 
    275 = SET 
    276 = MULTISET 
    277 = LIST 
    278 = Unnamed ROW 
    296 = LVARCHAR 
    297 = CLOB 
    298 = BLOB 
    299 = BOOLEAN
    4118 = Named ROW 
    

    此信息可在此非官方网页上找到。

    来自 Jonathan Leffler 以下评论的其他相关信息:

    请注意,基本值在所示列表中的 0..44 范围内;范围 256..299 中的值应与类型减 256 相同。0x100 位表示该列被限定为“NOT NULL”

    阅读下面的完整评论,其中还包含一些更有用的信息。

    • 2

相关问题

  • 如何在 PostgreSQL 中将货币列的类型更改为十进制?

  • Oracle 的 VARCHAR 和 VARCHAR2 数据类型有什么区别?

  • 从 NTEXT 迁移到 NVARCHAR(MAX)

  • 获取时间跨度之间的记录

  • INT(5) vs SMALLINT(5):数字类型后面括号中的数字

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve