如何正确格式化sqlite shell输出?

sqlite> .mode column
sqlite> select * from foo;
234         kshitiz     dba.se


sqlite> .headers on
sqlite> select * from foo;
bar         baz         baf
----------  ----------  ----------
234         kshitiz     dba.se


echo -e'.mode column \ n.headers on \ nselect * from sip_foo; \ n'| sqlite3 database.sqlite | less -S

sqlite3 database.sqlite -cmd“ .mode column” -cmd“ .headers on”“从sip_foo中选择*” |少-S

.mode column
.headers on
.separator ROW "\n"
.nullvalue NULL

sqlite3 <dbfile> ".headers on;.mode column;select * from MyTable"

 sqlite3 -column -header <dbfile> "select * from MyTable"



.mode columns
.headers on

CREATE TABLE my_table (name TEXT, age INTEGER, address TEXT);

INSERT INTO my_table VALUES ("short name",
22, "my house");

INSERT INTO my_table VALUES ("my name is very long",
22, "i live in my house somewhere in the planet Earth");

SELECT name AS "name                ",
       age,
       address AS "address                       "
FROM my_table;
 
posted @ 2023-07-04 14:10  易先讯  阅读(107)  评论(0编辑  收藏  举报