Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite how to declare as Byte Array?

Tags:

sqlite

I've got a SQLite database. I'd like to create a field and declare it as type Byte array but I don't know what SQLite calls something that would be of type Byte Array. How would I do this?

like image 251
Skizit Avatar asked Jul 19 '10 10:07

Skizit


People also ask

Can you store an array in SQLite?

In relational databases generally, an array is used to store rows with different key columns as an array dimension that means more than one key for a particular key. But in SQLite we cannot directly implement arrays in SQLite.

What is blob in SQLite database?

A blob is a SQLite datatype representing a sequence of bytes. It can be zero or more bytes in size. SQLite blobs have an absolute maximum size of 2GB and a default maximum size of 1GB. An alternate approach to using blobs is to store the data in files and store the filename in the database.

How can I get table size in SQLite?

sqlite > dbinfo. sql will give you detail info on each table's size on disk.

Can binary data be stored in SQLite?

SQLite cannot store binary data (i.e., strings containing NUL or ' characters) unless it is first encoded to remove these characters. The sqlite. encode() function compactly encodes binary strings so that they can be safely stored in an SQLite database.


1 Answers

You're looking for BLOB.

From the webpage:

BLOB - The value is a blob of data, stored exactly as it was input.

Here's an example of making a table with two columns - an id and some data, which is a BLOB:

CREATE TABLE t1 (id INTEGER PRIMARY KEY, data BLOB); 
like image 97
sarnold Avatar answered Sep 23 '22 15:09

sarnold