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 Mapping

Concepts and terms

SQL SequoiaDB
database database
table collection
row document / BSON document
column field
index index
table joins embedded documents
primary key (Users can take any unique column as primary key.) primary key (In SequoiaDB, primary key is automatically as the field called "_id".)

Create and Alter

The following table shows create and alter statements on table level in SQL and the corresponding ones in SequoiaDB.

SQL Statements Sequoiadb Statements Relative Link
create table student (id not null,stu_id varchar(50), age number primary key(id)) The system will automatically generate a collection when data is firstly inserted. If the value on "_id" is not specified, the system will automatically generate a "_id" value. "db.collectionspace.student({stu_id:"01",age:20})" Of course, you can also create a collection manually "db.collectionspace.createCL("student")" createCL()
alter table student add name varchar(50) In a collection, the structure is not changable, because there is no relative manipulation to describe or change the structure. But the method update() can add new field to document record with "$set". "db.collectionspace.student.update({},{$set:{name:"Tom"}})" $set
alter table student drop column name In a collection, the structure is not changable, because there is no relative manipulation to describe or change the structure. But the method update() can delete existing field from document record with "$unset". "db.collectionspace.student.update({},{$unset:{name:"Tom"}})" $unset
create index index_stu_id on student (stu_id) db.collectionspace.student.createIndex("index_stu_id",{stu_id:-1}) index
drop table student db.collectionspace.dropCL("student") dropCL()

Insert

The following table shows insert statement on table level in SQL and the corresponding one in SequoiaDB.

SQL Statements SequoiaDB Statements Relative Link
insert into student(stu_id,age) values("01",20) db.collectionspace.student.insert({stu_id:"01",age:20}) insert()

Select

The following table shows read statement on table level in SQL and the corresponding one in SequoiaDB.

SQL Statements SequoiaDB Statements Relative Link
select * from student db.collectionspace.student.find() find()
select stu_id,age from student db.collectionspace.student.find({},{stu_id:"01",age:20}) find()
select * from student where age > 25 db.collectionspace.student.find({age:{$gt:25}}) $gt
select age from student where age = 25 and stu_id = "01" db.collectionspace.student.find({age:25,stu_id="01"},{age:25}) find()
select count(*) from student db.collectionspace.student.count() count()
select count(stu_id) from student db.collectionspace.student.count({stu_id:{$exists:1}}) $exists

Update

The following table shows update statement on table level in SQL and the corresponding one in SequoiaDB.

SQL Statements Sequoiadb Statements Relative Link
update student set age = 25 where stu_id = "01" db.collectionspace.student.update({stu_id:"01"},{$set:{age:25}}) $set
update student set age = age + 2 where stu_id = "01" db.collectionspace.student.update({stu_id:"01"},{$inc:{age:2}}) $inc

Delete

The following table shows delete statement on table level in SQL and the corresponding one in SequoiaDB.

SQL Statements Sequoiadb Statements Relative Link
delete from student where age = 20 db.collectionspace.student.remove({age:20}) remove()
delete from student db.collectionspace.student.remove() remove()
please login to comment.
Latest Comment
  • 2015-02-15

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