zoukankan      html  css  js  c++  java
  • 【Android】Sqlite3命令详解

    Sqlite3常用命令

    Sqlite3命令有“.”符合作为前缀。

    基本操作

    1、创建或者打开数据库 sqlite3 xxx.db

    image

    如果xxx.db存在则打开如果没有则新建此时执行创建表的命令后才会出现xxx.db文件。

    创建xxx.db数据库

    sqlite3 xxx.db
    
    CREATE TABLE record(id integer primary key autoincrement,time varchar(20),name varchar(30),count int);

    2、查看表结构

    sqlite> .schema record

    查看表record结构

    3、查看所有表

    sqlite> .tables

    4、查看数据库

    sqlite> .databases

    5、执行sql脚本

    sqlite> .read insert.sql

    6、查看帮助

    sqlite> .help

    7、备份数据库

    sqlite> .backup C:/users/ghost/desktop/lemo/xx.sql

    数据的增删改查

    1、创建表

    CREATE TABLE record(id integer primary key autoincrement,time varchar(20),name varchar(30),count int);

    2、修改表

    3、插入数据

    insert into record(time,name) values('20160124','徐凤年');

    4、查询数据

    select * from record;

    5、改数据

    update record set name='g' where id=1;

    6、删

    delete from record where id=1

    .backup ?DB? FILE           Backup DB (default "main") to FILE
    .bail ON|OFF                  Stop after hitting an error.  Default OFF
    .databases                     List names and files of attached databases
    .dump ?TABLE? ...          Dump the database in an SQL text format
                                     If TABLE specified, only dump tables matching
                                     LIKE pattern TABLE.
    .echo ON|OFF               Turn command echo on or off
    .exit                          Exit this program
    .explain ?ON|OFF?          Turn output mode suitable for EXPLAIN on or off.
                                     With no args, it turns EXPLAIN on.
    .header(s) ON|OFF          Turn display of headers on or off
    .help                          Show this message
    .import FILE TABLE        Import data from FILE into TABLE
    .indices ?TABLE?           Show names of all indices
                                    If TABLE specified, only show indices for tables
                                     matching LIKE pattern TABLE.
    .log FILE|off                  Turn logging on or off.  FILE can be stderr/stdout
    .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
    .nullvalue STRING          Print STRING in place of NULL values
    .output FILENAME           Send output to FILENAME
    .output stdout                 Send output to the screen
    .prompt MAIN CONTINUE     Replace the standard prompts
    .quit                          Exit this program
    .read FILENAME             Execute SQL in FILENAME
    .restore ?DB? FILE         Restore content of DB (default "main") from FILE
    .schema ?TABLE?           Show the CREATE statements
                                     If TABLE specified, only show tables matching
                                     LIKE pattern TABLE.
    .separator STRING          Change separator used by output mode and .import
    .show                          Show the current values for various settings
    .stats ON|OFF              Turn stats on or off
    .tables ?TABLE?           List names of tables
                             If TABLE specified, only list tables matching
                             LIKE pattern TABLE.
    .timeout MS            Try opening locked tables for MS milliseconds
    .vfsname ?AUX?         Print the name of the VFS stack
    .width NUM1 NUM2 ...   Set column widths for "column" mode
    .timer ON|OFF          Turn the CPU timer measurement on or off

    over

    作者:leemoaly
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    互联网产品跨部门沟通的10个原则(转)
    Axure 全局辅助线(转)
    2015最新移动App设计尺寸视觉规范【图文版】(转)
    iOS和Android的app界面设计规范(转)
    安卓app设计规范整理和Android APP设计篇(转)
    19条ANDROID平台设计规范(转)
    Objective-C编码规范:26个方面解决iOS开发问题(转)
    AxureRP7.0各类交互效果汇总帖(转)
    Windows Server 2016与旧版本系统比较
    application Initialization设置导致处理程序ExtensionlessUrlHandler-Integrated-4.0在其模块列表中有一个错误模块问题的解决
  • 原文地址:https://www.cnblogs.com/kavs/p/5155953.html
Copyright © 2011-2022 走看看