首页 > 解决方案 > 如何在informix 中创建具有BLOB 数据类型列的表?

问题描述

我将在一个带有 BLOB 数据类型列的 informix 数据库中创建一个表。它将保存一个图像数据。这是我的语法如下。

create table blob_test_db
  (
    col1 varchar(10),
    img_bin BLOB in blob_dbspace
  ) extent size 32 next size 32 lock mode page;

根据我上面的语法,我想将我的img_bin数据存储在blob_dbspacedbspace 中。我想知道这可能吗?但是上面的语法是错误的。请告诉我将 blob 类型列添加到 informix 表的正确语法。

标签: informix

解决方案


Informix is tricky — it has two distinct families of 'large objects':

  • BYTE and TEXT — classic blobs
  • BLOB and CLOB — smart blobs

It can store BYTE or TEXT blobs IN TABLE or in a blob space (as opposed to a smart blob space or sbspace). Except that you wrote BLOB instead of BYTE, the notation you used is correct for BYTE or TEXT blobs.

The notation for BLOB or CLOB blobs is different. You're allowed to list multiple sbspaces for a BLOB or CLOB column:

CREATE TABLE blob_test_db
(
    col1    VARCHAR(10),
    img_bin BLOB
) PUT img_bin IN blob_dbspace EXTENT SIZE 32 NEXT SIZE 32 LOCK MODE PAGE;

See the CREATE TABLE statement generally, and the PUT clause in particular.


推荐阅读