v1.10

Document

How to Start SequoiaDB

Basic Operation

Data Model

Database Management

Aggregation

Index

Replication

Cluster

Connector

Reference

Development

Release Note

FAQ

  • Content
  • Comments
  • History

SQL to SequoiaDB shell to C++

The query in SequoiaDB is in the format of json(bson). The following table shows examples comparing sql statements, sequoiadb shell statements and sequoiadb C++ driver application statements.

SQL Sequoiadb Shell C++ Driver
insert into students(a,b) values(1,-1) db.foo.bar.insert({a:1,b:-1}) sdbCollection collection ;

BSONObj obj = BSON( "a"<<1<<"b"<<-1 ) ;

collection.insert( obj ) ;

select a,b from students db.foo.bar.find(null,{a:"",b:""}) sdbCollection collection ;

sdbCursor cursor ;

BSONObj selected ;

BSONObj obj ;

selected = BSON( "a"<<""<<"b"<<"" ) ;

collection .query( cursor, obj, selected ) ;

select * from students db.foo.bar.find() sdbCollection collection ;

sdbCursor cursor ;

collection .query ( cursor ) ;

select * from students where age=20 db.foo.bar.find({age:20}) sdbCollection collection ;

sdbCursor cursor ;

BSONObj condition ;

condition = BSON("age"<<20) ;

collection .query ( cursor, condition ) ;

select * from students where age=20 order by name db.foo.bar.find({age:20}).sort({name:1}) sdbCollection collection ;

sdbCursor cursor ;

BSONObj obj ;

BSONObj condition ;

BSONObj orderBy ;

condition = BSON("age"<<20) ;

orderBy = BSON("name"<<1) ;

collection .query (cursor, condition , obj, orderBy , obj ) ;

select * from students where age>20 and age<30 db.foo.bar.find({age:{$gt:20,$lt:30}}) sdbCollection collection ;

sdbCursor cursor ;

BSONObj condition ;

condition = BSON("age"<

collection .query (cursor, condition ) ;

create index testIndex on students(name) db.foo.bar.createIndex("testIndex",{name:1},false) sdbCollection collection ;

BSONObj obj ;

obj = BSON( "name"<<1 ) ;

collection.createIndex ( &obj, "testIndex", FALSE, FALSE )

select * from students limit 20 skip 10 db.foo.bar.find().limit(20).skip(10) sdbCollection collection ;

BSONObj obj ;

sdbCursor cursor ;

collection .query (cursor,obj, obj, obj, obj, 10, 20 ) ;

select count(*) from students where age>20 db.foo.bar.find({age:{$gt:20}}).count() sdbCollection collection ;

SINT64 count = 0 ;

BSONObj condition ;

Condition = BSON( "age"<

collection.getCount (count, condition );

update students set a=a+2 where b=-1 db.foo.bar.update({$set:{a:2}},{b:-1}) sdbCollection collection ;

BSONObj condition = BSON( "b"<<1 ) ;

BSONObj rule = BSON( "$set"<

BSONObj obj ;

collection.update ( rule, condition, obj ) ;

delete from students where a=1 db.foo.bar.remove({a:1}) sdbCollection collection ;

BSONObj condition = BSON("a"<<1) ;

collection.del ( condition ) ;
please login to comment.
Latest Comment
  • 2015-03-14

About Us

SequoiaDB is a financial-level distributed database vendor and is the first Chinese database listed in Gartner’s Magic Quadrant OPDBMS report. SequoiaDB has recently released version 3.0.
SequoiaDB is now penetrating the vertical sector Financial Industry quickly and had more than 50 banking clients and hundreds of enterprise customers in industries including government, telecommunication, Internet and IoT.

Beijing:
Tower R, No.8 North Star East Road, Chaoyang District, Beijing,China
Guangzhou:
Tower A, No.22 Qinglan Street, Panyu District, Guangzhou,China
Shenzhen:
Tsing Hua Tech Park, Nanshan District, Shenzhen,China
Tel:400-8038-339
E-mail:contact@sequoiadb.com