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
相关文章
相关标签/搜索