Subject Re: [firebird-support] binary or string?
Author Ann W. Harrison
At 12:22 AM 12/11/2004, Storage Box wrote:

>I'd like to use an 8-bit binary object as a primary key but I'm wondering
>what the most efficient way to store this is and how indexing will be
>affected.

integer suggests itself, though if you're actually using an eight bit
value, you could call it char(1). But a table with an eight bit primary
key is kind of restrictive... 256 records and you're done. If you're
actually talking about an 8-byte binary key use int64. It's an exact
match.

>Blobs are binary

Everything on a computer is binary. And it can all be expressed as
hex or octal. Char is just binary with some fancy rules for comparisons,
like ignoring trailing blanks. Char with a specified character set and
collation has fancier rules - one particular character set called octets
cause a char string to compare exactly as the stored bytes compare -
nothing special about spaces.

Blobs are "Basic Large OBjects" with the emphasis on LARGE. Eight bits,
eight bytes, even 8 long words isn't large.

>
>In SQL Server I would store them as a binary(8) object (not a blob) but I'm
>not sure what the equivalent would be in FB?

The equivalent would be char(8) character set octets. And that's fine
for longer strings of bytes, but since there's a native binary eight
byte type, I'd use that.

Regards,


Ann