zoukankan      html  css  js  c++  java
  • Sqlite使用

    1. 安装命令行工具
      http://www.sqlite.org/download.html下载Precompiled Binaries for Windows下的sqlite-tools-win32-x86,解压到某个目录,然后将此目录配置到环境变量path中。
      从命令行执行sqlite3进入到了sqlite命令行,则说明配置ok。
      常用命令:
      1. 获取命令列表.help
      2. 格式化输出:
        .header on
        .mode column
        .timer on
      3. 查看表的信息:.schema sqlite_master
      4. --
    2. sqlite的元数据信息存放在表sqlite_master里
      比如要获取表users是否存在,可以查询:
      select count(1) from sqlite_master where type='table' and tbl_name='users';
    3. 创建数据库
      sqlite3 DatabaseName.db
      如果直接执行sqlite3,不带文件路径,则会提示“Connected to a transient in-memory database”。
      可以使用 SQLite 的 .databases 命令来检查它是否在数据库列表中。
    4. 导出与导入
      导出:sqlite3 testDB.db .dump > testDB.sql
      导入:sqlite3 testDB.db .dump < testDB.sql
    5. 附加数据库
      ATTACH DATABASE 'testDB.db' as 'TEST';
    6. 分离数据库
      DETACH DATABASE 'Alias-Name';
      注:无法分离main或者temp数据库
    7. 查询表的列信息
      PRAGMA table_info(users)
      注意:PRAGMA必须大写
  • 相关阅读:
    Javascript FP-ramdajs
    微信小程序开发
    SPA for HTML5
    One Liners to Impress Your Friends
    Sass (Syntactically Awesome StyleSheets)
    iOS App Icon Template 5.0
    React Native Life Cycle and Communication
    Meteor framework
    RESTful Mongodb
    Server-sent Events
  • 原文地址:https://www.cnblogs.com/liqipeng/p/6105888.html
Copyright © 2011-2022 走看看