美文网首页
SQLite常用语法

SQLite常用语法

作者: crazyfox | 来源:发表于2017-04-03 01:43 被阅读12次

常用语法

  1. 建表
    // if not exists 判断是否存在,不存在才创建 PRIMARY KEY 主键
    语法:creat table if not exists 表名 (字段1 类型,字段2 类型,id integer PRIMARY KEY,...);
  2. 删表
    drop 表名 if exists ;
  3. 重命名
    alter table 旧表名 rename to 新表名;
  4. 添加字段
    alter table 表名 add column 字段名 数据类型 限定符;

增删改查


  1. insert into 表名 (字段1, 字段2, …) values (字段1的值, 字段2的值, …) ;

  2. delete from 表名 where 条件;

  3. update 表名 set 字段1 = 字段1的值, 字段2 = 字段2的值 where 条件;

  4. 格式1: select * from 表名;, *:通配符,表示所有字段.
    格式2: select 字段1, 字段2, … from 表名;
    格式3: select 字段1, 字段2, … from 表名 where 条件;

参考http://www.jianshu.com/p/b0ec725451fa
http://www.jianshu.com/p/cf76e2e81230
http://www.jianshu.com/p/24aa120ac998

相关文章

网友评论

      本文标题:SQLite常用语法

      本文链接:https://www.haomeiwen.com/subject/vjbbottx.html