支持的SQL语法
杨爽 hat diese Seite bearbeitet vor 1 Jahr

Select

查询语句中必须加key的where条件,因为dtc是key-value缓存服务。

  • select * from opensource where uid = 1 通配符星号(*)查询所有字段
  • select uid, name from opensource where uid = 1 查询部分字段
  • select * from opensource where uid =1 and name = 'dtc' AND符号
  • select * from opensource where uid =1 and name = 'dtc' 字符串类型支持单引号
  • select * from opensource where uid = 1 and age > 18 数字类型支持大于符号
  • select * from opensource where uid = 1 and age >= 18 数字类型支持大于等于符号
  • select * from opensource where uid = 1 and age < 18 数字类型支持小于符号
  • select * from opensource where uid = 1 and age <= 18 数字类型支持大于等于符号
  • select * from opensource where uid = 1 and age != 18 数字类型支持不等于符号
  • select * from opensource where uid = 1 limit 1 支持关键字limit返回指定条数的结果
  • select * from opensource where uid = 1 limit 1,3 支持limit(start, offset)的用法

暂不支持

  • or 不支持或符号
  • count() 不支持计数函数

    Insert

  • insert into opensource(uid, name) values(1, 'hello') 指定字段插入数据

  • insert into opensource set uid = 33, name = 'hello' set形式的插入操作

  • "insert into opensource(uid,name,city,sex,age) values(1, 123, 'Shanghai', 1, 18) 类型自动兼容,name定义为string,但插入数字类型,会自动转换成字符串

  • insert into opensource(uid,name,city,sex,age) values(2, 'jack', 'Shanghai', 1, '18') 类型自动兼容,string转int

  • insert into opensource(uid, name) values(33, \"hello\") 字符串支持单引号和双引号

  • insert intoopensource(uid, name) values(33, 'hello') 表名、字段名支持重力符号(实际应为一个重力符号,由于显示问题打印两次)

Update

  • update opensource set name = 'Lee' where uid = 1 更新操作的常规语法,其他规则和上述相同。

Delete

  • delete from opensource where uid = 1 删除操作的常规语法,其他规则和上述相同。