How to Start SequoiaDB

Basic Operation

Data Model

Database Management








Release Note


  • Content
  • Comments
  • History

How to start SequoiaDB

1 Installing SequoiaDB

First, you need to download the package of SequoiaDB from its official site. SequoiaDB has two kinds of package, one is for X86 based server, another one is for Power PC based servers. You can select the appropriate one according to your server’s CPU.

1)Decompressing From Package

tar -zxvf sequoiadb-1.10-linux_x86_64-installer.tar.gz

2)Change Package Authority

chmod 755 sequoiadb-1.10-linux_x86_64-installer.run

3)Installing SequoiaDB Database

In installation process, SequoiaDB will create a new OS user named sdbadmin, together with a OS user group named sdbadmin_group. SequoiaDB will be installed under path /opt/sequoiadb by default.

./sequoiadb-1.10-linux_x86_64-installer.run --mode unattended

2 Start SequoiaDB Service

After installation, SequoiaDB won’t start related processes, user need to manually set database options then start the database service by SequoiaDB starting commands. And here is the starting of SequoiaDB’s Standalone Mode, if you want to deploy cluster mode, you may access here, for tutorial.

1)Switch to sdbadmin User

su - sdbadmin

2)Set SequoiaDB process parameters

mkdir -p /opt/sequoiadb/conf/local/11810
cp /opt/sequoiadb/conf/samples/sdb.conf.standalone /opt/sequoiadb/conf/local/11810/sdb.conf

3)Start SequoiaDB Service

/opt/sequoiadb/bin/sdbstart -c /opt/sequoiadb/conf/local/11810/

3 SequoiaDB Operations

3.1 Use SequoiaDB Shell to Operate Database

Users can access sdbshell command client to operate SequoiaDB.


Connect to Database

To operate the database, user need to connect to server first.

> var db = new Sdb("localhost",11810);

View SequoiaDB’s Instruction

View Help

> help

Except for the help, SequoiaDB has different instruction for most of the objects, for example users can use db.help(),db.collectionspace.help(),db.collectionspace.collection.help() to know more about the functions of SequoiaDB.

Create a Collection Space

Collection in SequoiaDB is similar to Table in RDBMS,and Collection Space is similar to database in RDBMS. SequoiaDB won’t create a default Collection Space, so users using SequoiaDB for the first time will have to manually create its first Collection Space. Create a Collection Space named "foo":

> var cs = db.createCS("foo");

View All Collection Space of SequoiaDB

If you want to what you’ve created on last step or what Collection Space is, you may use this command to view all Collection Space:

> db.listCollectionSpaces();

Create Collection

SequoiaDB’s Collection is based on the Collection Space, which is similar to Table in RDBMS. Object Collection is very important for the whole system. SequoiaDB has a lot of operations in Collection, except for basic functions like CRUD, advanced functions like indexing, data sharding are also integrated in it.

Create Collection Named "bar":

> var cl = cs.createCL("bar");

View All Collections in SequoiaDB

Similarly to Collection Space, user can view the Collection created in this host.

> db.listCollections();

Write Data

Execute insert command of Collection, and insert data into Collection

> cl.insert({name:"sequoiadb",web:"www.sequoiadb.com"});
> cl.insert({name:"test",web:"www.sequoiadb.com"});

Query Data In Collection

Query Collection bar

> cl.find();
  "_id": {
    "$oid": "54d84720e9e4b2aa36000002"
  "name": "sequoiadb",
  "web": "www.sequoiadb.com"
  "_id": {
    "$oid": "54d8473ce9e4b2aa36000003"
  "name": "test",
  "web": "www.sequoiadb.com"

Query a Single Record

If user just want to simply view the Collection, you don’t need to print all records, but only one record. And the SequoiaDB Collection provides the tool cl.findOne()

> cl.findOne();

Cursor Using

In some circumstances, user may have different operations for different record, and cursor is needed for traversing all records in Collection.

> while(cursor.next()) println(cursor.current());

Conditional Query

One Collection may contain a lot of records, but user only want to get some specific records, and there is Conditional Query for this usage.

> cl.find({name:"sequoiadb"});
  "_id": {
    "$oid": "54d84720e9e4b2aa36000002"
"name": "sequoiadb", 
"web": "www.sequoiadb.com"

Using Java Driver to Operate SequoiaDB

Java Code

package com.sequoiadb.test;

import org.bson.BSONObject;
import org.bson.BasicBSONObject;

import com.sequoiadb.base.*;
import com.sequoiadb.exception.BaseException;

public class SequoiadbTest {
    public static void main(String[] args){
        Sequoiadb sdb = null;
            // Connect to SequoiaDB Server
            sdb = new Sequoiadb("", 11810, "", "");
            // Get Collection Space Handle
            CollectionSpace cs = sdb.getCollectionSpace("foo");
            // Get Collection Handle
            DBCollection cl = cs.getCollection("bar");

            // Insert data into collection bar
            BSONObject data = new BasicBSONObject();
            data.put("web", "www.sequoiadb.com");
            data = new BasicBSONObject();
            data.put("name", "test");
            data.put("web", "www.sequoiadb.com");

            // Query the Collection, return result set’s cursor
            DBCursor cursor = cl.query();
            // Traverse the cursor, print the query result.
            System.out.println("Print Record just inserted");
                BSONObject record = cursor.getNext();

            // Conditional Query
            BSONObject query = new BasicBSONObject();
            query.put("name", "test");
            cursor = cl.query(query, null, null, null);
            System.out.println("Print conditional queried records");

            // Query record and edit.
            BSONObject rule = new BasicBSONObject();
            BSONObject updateRecord = new BasicBSONObject();
            updateRecord.put("name", "helloworld");
            rule.put("$set", updateRecord);
            cl.upsert(query, rule, null);
            cursor = cl.query();
            System.out.println("Print the edited result.");

            // Remove records
            query = new BasicBSONObject();
            query.put("name", "helloworld");
            cursor = cl.query();
            System.out.println("Print the remaining record after deleting");

            // Disconnect SequoiaDB
        }catch(BaseException e){
please login to comment.
Latest Comment
  • 2015-02-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.

Tower R, No.8 North Star East Road, Chaoyang District, Beijing,China
Tower A, No.22 Qinglan Street, Panyu District, Guangzhou,China
Tsing Hua Tech Park, Nanshan District, Shenzhen,China