Reputation: 3487
I have a function which maps java to SQL types. As I want to store binary data, is there any type defined by the SQL standard which I can use both in PostgreSQL and hsqldb?
Upvotes: 4
Views: 7898
Reputation: 1769
SQL has supported binary types since 1999: [https://mariadb.com/kb/en/sql-data-types/]. Vendors have had over a decade to add support for binary types, and most SQL databases do.
Upvotes: 1
Reputation: 24372
BINARY and VARBINARY are defined by the the SQL Standard. The Standard is currently at SQL:2011 (after 92, 1999, 2003 and 2008). HSQLDB supports all the core data types defined by the Standard.
The PostgreSQL BYTEA is similar to VARBINARY. You can define the BYTEA type in HSQLDB as a VARBINARY type with a large maximum size:
CREATE TYPE BYTEA AS VARBINARY(1000000)
Upvotes: 8
Reputation: 238176
The SQL 92 standard does not define a binary type. PostgreSQL has a bytea
type, hsqldb has a binary
type.
For a very portable (if not efficient) solution, convert the binary to base64, and store it in a string.
Upvotes: 9