Skip to main content

Binary types

Binary types

Section

Description

BINARY

BINARY is a FairCom database field type containing a fixed-length binary value up to 65,500 bytes. It is useful for small binary values that vary little in length.

BIT

BIT is a FairCom database field type containing a fixed-length Boolean value of 0 or 1.

VARBINARY

VARBINARY is a FairCom database field type containing a variable-length binary value up to 65,500 bytes. It is useful for medium-sized binary values that vary in length.

LVARBINARY

LVARBINARY is a FairCom database field type containing a variable-length binary value up to 2 gigabytes. It is useful for very large binary values that vary greatly in length.

Binary data types for the JSON DB API

Binary typesFairCom DBbinarybitvarbinarylvarbinaryJSON DB API

BINARY is a FairCom database field type containing a binary value. It is useful for small binary values that vary little in length.

It is stored in a record as a series of bytes . It has a fixed length from 1 to 65,500 bytes, which is stored once in the table's header. If a value is smaller than its fixed length, the server uses padding to fill in missing bytes at the end. You must specify the fixed length of the field when you create it.

BINARY's behavior in different APIs:
  • In FairCom's JSON DB API, a BINARY value is represented in JSON as an array of bytes or a string containing Base64 or HEX characters.

  • In FairCom's SQL API, a BINARY value is submitted and returned in one of three ways:

    • As a binary constant represented as b'11010001100101110110011011001101111'.

    • As a HEX constant represented as x'68656c6c6f'.

    • As an ASCII string (such as 'hello') , where its ASCII characters are stored directly as a sequence of ASCII codes — for example, 104 101 108 108 111.

  • In FairCom's ISAM and CTDB APIs, a BINARY value is submitted and returned as a sequence of bytes.

BIT is a FairCom database field type containing a Boolean value of 0 or 1. It is stored in a record as an 8-bit integer.

BIT's behavior in different APIs:
  • In FairCom's JSON DB API, a BIT value is represented as a JSON Boolean with a value of false or true.

    A field value of 0 maps to false. A field value of 1 maps to true.

  • In FairCom's SQL API, a BIT value is submitted and returned as a 0 or 1 ASCII characters.

  • In FairCom's ISAM and CTDB APIs, a BIT value is submitted and returned as an unsigned byte with a value of 0 or 1.

VARBINARY is a FairCom database field type containing a variable-length binary value. It is useful for medium-sized binary values that vary in length.

It is stored in a record as a variable-length sequence of bytes with a user-defined maximum length of up to 65,500. You must specify the maximum length of the field when you create it.

Each VARBINARY field in each record contains a 2-byte header that defines the stored length of its value.

VARBINARY's behavior in different APIs:
  • In FairCom's JSON DB API, a VARBINARY value is represented in JSON as an array of bytes or a string containing Base64 or HEX characters.

  • In FairCom's SQL API, a VARBINARY value is submitted and returned in one of three ways:

    • As a binary constant represented as b'11010001100101110110011011001101111'.

    • As a HEX constant represented as x'68656c6c6f'.

    • As an ASCII string (such as 'hello'), where its ASCII characters are stored directly as a sequence of ASCII codes — for example, 104 101 108 108 111.

  • In FairCom's ISAM and CTDB APIs, a VARBINARY value is submitted and returned as a sequence of bytes.

LVARBINARY is a FairCom database field type containing a variable-length binary value. It is useful for very large binary values that vary greatly in length.

It is stored as a variable-length sequence of bytes up to 2 Gigabytes in length. Each LVARBINARY field in each record includes a 4-byte length header.

LVARBINARY's behavior in different APIs:
  • In FairCom's JSON DB API, a BINARY value is represented in JSON as an array of bytes or a string containing Base64 or HEX characters.

  • In FairCom's SQL API, an LVARBINARY value is submitted and returned in one of three ways:

    • As a binary constant represented as b'11010001100101110110011011001101111'.

    • As a HEX constant represented as x'68656c6c6f'.

    • As an ASCII string (such as 'hello' ), where its ASCII characters are stored directly as a sequence of ASCII codes — for example, 104 101 108 108 111.

  • In FairCom's ISAM and CTDB APIs, a BINARY value is submitted and returned as a sequence of bytes.