Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the equivalent of varbinary(10) in postgresql

I'm trying to define a bit field of 10 bytes. In SQL Server I'd use varbinary(10). I know that bytea replaces varbinary (MAX) for images, but didn't find any documentation on limiting the number of bits in it.

Is there a way to do that?

like image 249
liv a Avatar asked Oct 23 '13 19:10

liv a


People also ask

What datatype is VARBINARY?

Store raw-byte data, such as IP addresses, up to 65000 bytes. The BINARY and BINARY VARYING (VARBINARY) data types are collectively referred to as binary string types and the values of binary string types are referred to as binary strings.

Is VARBINARY same as binary?

The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than non-binary character strings. M represents the maximum column length in bytes. It contains no character set, and comparison and sorting are based on the numeric value of the bytes.

What is PostgreSQL 10?

PostgreSQL 10 introduces a table partitioning syntax that lets users easily create and maintain range and list partitioned tables. The addition of the partitioning syntax is the first step in a series of planned features to provide a robust partitioning framework within PostgreSQL.

How many bytes is a VARBINARY?

varbinary [ ( n | max) ] Variable-length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes.


1 Answers

you want to look at bit(n), not bytea

http://www.postgresql.org/docs/current/static/datatype-bit.html

like image 183
Leo Avatar answered Oct 19 '22 01:10

Leo