Nwn
Nwn

Reputation: 571

How to create a table with a BLOB datatype column in informix?

I am going to create a table in a informix database whcih is with a BLOB data typed column.It is going to save a image data. Here is my syntax as follows.

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

According to my above syntax I want to store my img_bin data in blob_dbspace dbspace. I want to know is it possible? However above syntax is wrong. Please tell me the correct syntax for adding blob type column to the informix table.

Upvotes: 2

Views: 6156

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 754410

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.

Upvotes: 2

Related Questions