SequoiaDB巨杉数据库SQL to SequoiaDB shell to C

SequoiaDB 的查询用 json(bson)对象表示,下表以例子的形式显示了 SQL 语句,SequoiaDB Shell 语句和 SequoiaDB C 驱动程序语法之间的对照。

SQLSequoiaDB shellC Driver
insert into employee( a, b ) values( 1, -1 )db.sample.employee.insert( { a: 1, b: -1 } )const char *r = “{ a: 1, b: -1 }” ;
jsonToBson ( &obj, r );
sdbInsert( collection, &obj );
select a,b from employeedb.sample.employee.find( null, { a: “”, b: “” } )const char *r = “{ a: “”, b: “” }” ;
jsonToBson ( & select, r ) ;
sdbQuery ( collection, NULL, &select, NULL, NULL, 0, -1, cursor ) ;
select * from employeedb.sample.employee.find()sdbQuery ( collection, NULL, NULL, NULL, NULL, 0, -1, cursor ) ;
select * from employee where age = 20db.sample.employee.find( { age: 20 } )const char *r = “{ age: 20 }” ;
jsonToBson ( &condition, r );
sdbQuery ( collection, & condition, NULL, NULL, NULL, 0, -1, cursor );
select * from employee where age = 20 order by namedb.sample.employee.find( { age: 20 } ).sort( { name: 1 } )const char r1 = “{ age: 20 }” ;
const char r2 = “{ name: 1 }” ;
jsonToBson ( & condition, r1 ) ;
jsonToBson ( &orderBy, r2 ) ;
sdbQuery ( collection, & condition, NULL, & orderBy, NULL, 0, -1, cursor ) ;
select * from employee where age > 20 and age < 30db.sample.employee.find( { age: { $gt: 20, $lt: 30 } } )const char *r = “{ age: { $gt: 20, $lt: 30 } }” ;
jsonToBson ( &condition, r );
sdbQuery ( collection, & condition , NULL, NULL, NULL, 0, -1, cursor ) ;
create index testIndex on employee( name )db.sample.employee.createIndex( “testIndex”, { name: 1 }, false )const char *r = “{ name: 1 }” ;
jsonToBson ( &obj, r );
sdbCreateIndex ( collection, &obj, “testIndex”, FALSE, FALSE )
select * from employee limit 20 offset 10db.sample.employee.find().limit(20).skip( 10 )sdbQuery ( collection, NULL, NULL, NULL, NULL, 10, 20, cursor ) ;
select count( * ) from employee where age > 20db.sample.employee.find( { age: { $gt: 20 } } ).count()const char *r = “{ age: { $gt: 20 } }” ;
jsonToBson ( &condition, r );
sdbGetCount ( collection, &condition, &count ) ;
update employee set a=2 where b=-1db.sample.employee.update( { $set: { a: 2 } }, { b: -1 } )const char r1 = “{ $set: { a: 2 } }” ;
const char r2 = “{ b: -1 }” ;
jsonToBson ( &rule, r1 ) ;
jsonToBson ( &condition, r2 ) ;
sdbUpdate( collection, &rule, &condition, NULL ) ;
delete from employee where a=1db.sample.employee.remove( { a: 1 } )const char *r = “{ a: 1 }” ;
jsonToBson ( &condition, r ) ;
sdbDelete ( collection, &condition, NULL ) ;

更多内容可点击巨杉数据库官网查看。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值