SQLite Forum

output in column mode is truncated

output in column mode is truncated

(1) By Ondrej Dubaj (odubaj) on 2020-05-14 09:34:40 [source]

Description of problem:
When sqlite is in column mode, it truncates output of select query. It seems that sqlite estimates width of text column by using length of text value in the first returned row.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1) Create a table containing text field and fill in some (text) values of different length.
2) Switch to column mode
3) Select the text column from the table and order it from the shortest to the longest. Now you should see, that the longer values are truncated.
4) Try reversing the order (from the longest to the shortest). Now you should see untruncated results.


sqlite3 test.sqlite << EOF
create table tab1(str text);
insert into tab1 values('sth');
insert into tab1 values('something a bit longer');
.mode column
select * from tab1 order by length(str);
select '--------------------------------';
select * from tab1 order by length(str) desc;

Actual results:

something a bit longer

Expected results:

something a bit longer 
something a bit longer

(2) By Donald Griggs (dfgriggs) on 2020-05-14 13:38:35 in reply to 1 [link] [source]

And in case a spreadsheet isn't suitable for your needs, you're probably aware of the .width command in the command line shell.

See section 5 of: https://sqlite.org/cli.html