SQLite Forum

How to insert control characters?

How to insert control characters?

(1) By 6kEs4Majrd on 2021-03-14 14:53:40 [link] [source]

I want to insert control characters like TAB, CR or x01. I am not sure what is the correct way to do so. Could anybody let me know? Thanks.

sqlite3 dbfile <<-'EOF' create table test (id integer primary key, value text); insert into test (value) values('atb'); EOF

(2) By Keith Medcalf (kmedcalf) on 2021-03-14 16:17:57 in reply to 1 [source]

The ASCII Horizontal Tab is ASCII code 9.

insert into test (value) values ('a' || char(9) || 'b');

Strings consisting of characters other than 0 (which is the terminator of a C string) are inserted as-is. So you can also simply insert the data you want inserted.