zoukankan      html  css  js  c++  java
  • sqlite数据库查看操作

    经常看到Settings.System.**。这些数据都保存在/data/data/com.android.provider.settings/下。要看这些数据,就需要查表。于是就看了下数据库的一些简单操作命令。

    显示所有命令

    sqlite>.help

    退出sqlite3

    sqlite>.quit

    查看表的结构

    sqlite>.schema <table_name>

    以上命令以;结束


    创建数据库user

    sqlite3 user  

    创建表tbl

    create table tbl(name char(10), age smallint, score float);

    查询表

    .table

    插入数据

    insert into tbl values('yanggang', 24, 98);

    insert into tbl values('sunboy', 20, 78.5);

    查询表中所有记录

    select * from tbl;

    修改显示模式

    .mode column

    按指定条件查询表中记录

    sqlite>select  *  from  <table_name>  where  <expression>;

    更新表中记录
    sqlite>update  <table_name>  set  <f1=value1>, <f2=value2>…   where  <expression>;
    sqlite> update student set score=0;
    sqlite> update student set name=’sun’ where no=3;

    删除表

    sqlite>drop table <table_name>

    在表中添加字段

    sqlite>alter table <table> add column <field> <type>;

    在表中删除字段

    sqlite中不允许删除字段,可以通过下面步骤达到同样的效果

    sqlite>create table stu as select no, name, score from student

    sqlite>drop table student 删除旧表

    sqlite>alter table stu rename to student改名

    导出数据库

    sqlite> .databases  (显示当前打开的数据库文件)
    sqlite> .backup main .user.sql  (备份数据库main)
    sqlite> .backup .user2.sql    (备份默认数据库main)

    导出表

    sqlite> .output user_tbl.sql
    sqlite> .dump tbl


    shardPreferences保存的xml文件在/data/data/<package name>/shared_prefs下。

  • 相关阅读:
    查漏补缺:QT入门
    添砖加瓦:设计模式(工厂方法模式)
    Luogu 4784 [BalticOI 2016 Day2]城市
    Luogu 1606 [USACO07FEB]白银莲花池Lilypad Pond
    Luogu 3698 [CQOI2017]小Q的棋盘
    CF547D Mike and Fish
    Luogu 3066 [USACO12DEC]逃跑的BarnRunning Away From…
    Luogu 2403 [SDOI2010]所驼门王的宝藏
    NEERC17 J Journey from Petersburg to Moscow
    Luogu 3350 [ZJOI2016]旅行者
  • 原文地址:https://www.cnblogs.com/chengliu/p/3636416.html
Copyright © 2011-2022 走看看