sqlite的基本使用

一、登陸css

sqlite  da_namesql

二、查看數據庫和表數據庫

.databasescode

.tablessqlite

三、查看錶結構it

.schema  tablenameio

四、導入數據到sqlitetable

  1. sqlite> .separator "," 
  2. sqlite> .import data.txt data_txt_table
  3. sqlite> select * from data_txt_table;
  4. id,name,age,address,hobby
  5. 1,tom,24,beijing,football
  6. 2,liu,27,heibei,fotball
  7. 3,jim,26,shandong,football
  8. 4,han,28,beijing,football
  9. 5,meng,25,beijing,tennis
  10. sqlite>

五、數據導出class

數據導出也是一個經常使用到的操做,能夠將指定表中的數據導出成SQL腳本,供其餘數據庫使用,還能夠將指定的數據表中的數據完整定位到標準輸出,也能夠將指定數據庫中的數據完整的導入到另外一個指定數據庫等,

1. 導出成指定的SQL腳本
   將sqlite中指定的數據表以SQL建立腳本的形式導出,具體命令

test

  1. ywx@ywx:~/yu/sqlite$ sqlite3 test.db
  2. SQLite version 3.7.7.1 2011-06-28 17:39:05
  3. Enter ".help" for instructions
  4. Enter SQL statements terminated with a ";"
  5. sqlite> .output data.sql
  6. sqlite> .dump
  7. sqlite>

 

    1. ywx@ywx:~/yu/sqlite$ ll
    2. 總計 16
    3. drwxr-xr-x 2 ywx ywx 4096 2011-08-13 23:15 ./
    4. drwxr-xr-x 7 ywx ywx 4096 2011-08-13 20:53 ../
    5. -rw-r--r-- 1 ywx ywx 602 2011-08-13 23:17 data.sql
    6. -rw-r--r-- 1 ywx ywx 2048 2011-08-13 22:44 test.db
相關文章
相關標籤/搜索