SQLite | SQLite Functions | Create a BLOB 0x00 Value of a Specified Number of Bytes (zeroblob Function)

The zeroblob function can create a BLOB value of 0x00 with the specified number of bytes. This section explains how to use the zeroblob function.

How to Use the zeroblob Function

The zeroblob function is used to create a BLOB value of 0x00. The format is as follows.

zeroblob(bytes)

The byte count specified in the argument creates a BLOB 0x00 value. Specify a positive value for the byte count. This function seems to be used to precreate and control data for the specified number of bytes.

Now, use the zeroblob function in practice to create values. The generated values are output in hexadecimal by using the hex function. (For the hex function, see Convert a BLOB Type Value to Hexadecimal (hex Function).)

select hex(zeroblob(2)), hex(zeroblob(3));
sqlite> .mode column
sqlite> .header on
sqlite> 
sqlite> select hex(zeroblob(2)), hex(zeroblob(3));
hex(zeroblob(2))  hex(zeroblob(3))
----------------  ----------------
0000              000000          
sqlite> 

Each time the SELECT statement was executed, 2-byte and 3-byte BLOB values of 0x00 were obtained.