萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mssql數據庫 >> SQLite入門之三常用命令

SQLite入門之三常用命令

 3. 數據顯示相關命令

3.1 設置分隔符:.separator 分隔符

help:

? 1 .separator STRING      Change separator used by output mode and .import

 

example:

默認分隔符是 | ? 1 2 3 4 5 6 7 8 9 sqlite> SELECT * FROM Cars; 1|Audi|52642 2|Mercedes|57127 3|Skoda|9000 4|Volvo|29000 5|Bentley|350000 6|Citroen|21000 7|Hummer|41400 8|Volkswagen|21600

 

自定義分隔符

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 sqlite> .separator - sqlite> SELECT * FROM Cars; 1-Audi-52642 2-Mercedes-57127 3-Skoda-9000 4-Volvo-29000 5-Bentley-350000 6-Citroen-21000 7-Hummer-41400 8-Volkswagen-21600 sqlite> .separator ; sqlite> SELECT * FROM Cars; 1;Audi;52642 2;Mercedes;57127 3;Skoda;9000 4;Volvo;29000 5;Bentley;350000 6;Citroen;21000 7;Hummer;41400 8;Volkswagen;21600

 

3.2 設置顯示模式:.mode 模式

? 1 2 3 4 5 6 7 8 9 .mode MODE ?TABLE?     Set output mode where MODE is one of:                          csv      Comma-separated values                          column   Left-aligned columns.  (See .width)                          html     HTML <table> code                          insert   SQL insert statements for TABLE                          line     One value per line                          list     Values delimited by .separator string                          tabs     Tab-separated values                          tcl      TCL list elements

 

默認是list顯示模式

? 1 2 3 4 5 6 7 8 9 sqlite> SELECT * FROM Cars; 1|Audi|52642 2|Mercedes|57127 3|Skoda|9000 4|Volvo|29000 5|Bentley|350000 6|Citroen|21000 7|Hummer|41400 8|Volkswagen|21600

 

更攺顯示模式

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 sqlite> .mode csv sqlite> SELECT * FROM Cars; 1,Audi,52642 2,Mercedes,57127 3,Skoda,9000 4,Volvo,29000 5,Bentley,350000 6,Citroen,21000 7,Hummer,41400 8,Volkswagen,21600 sqlite> .mode tabs sqlite> SELECT * FROM Cars; 1   Audi    52642 2   Mercedes    57127 3   Skoda   9000 4   Volvo   29000 5   Bentley 350000 6   Citroen 21000 7   Hummer  41400 8   Volkswagen  21600

 

3.3 顯示標題欄:.headers on

? 1 .echo ON|OFF           Turn command echo on or off

 

顯示標題欄

? 1 2 3 4 5 6 7 8 9 10 11 sqlite> .headers on sqlite> SELECT * FROM Cars; Id  Name    Cost 1   Audi    52642 2   Mercedes    57127 3   Skoda   9000 4   Volvo   29000 5   Bentley 350000 6   Citroen 21000 7   Hummer  41400 8   Volkswagen  21600

 

不顯示標題欄

? 1 2 3 4 5 6 7 8 9 10 sqlite> .headers off sqlite> SELECT * FROM Cars; 1   Audi    52642 2   Mercedes    57127 3   Skoda   9000 4   Volvo   29000 5   Bentley 350000 6   Citroen 21000 7   Hummer  41400 8   Volkswagen  21600

 

3

copyright © 萬盛學電腦網 all rights reserved