SQL to SequoiaDB映射表

    Create 和 Alter

    SQL 语句API 语句
    create table student ( id not null, stu_id varchar(50), age number primary key(id) )如果未指定 _id 字段,_id 字段自动添加 db.collectionspace.student( { stu_id: “01”, age: 20 } ),当然你也可以明确的创建一个集合 db.collectionspace.createCL( “student” )
    alter table student add name varchar(50)集合不描述或强制执行文档的结构,即在集合上没有结构的改动操作,但是 update() 方法可以使用 $set 向文档记录添加不存在的字段。db.collectionspace.student.update( {}, { $set: { name: “Tom” } } )
    alter table student drop column name集合不描述或强制执行文档的结构,即在集合上没有结构的改动操作,但是 update() 方法可以使用 $unset 向文档记录删除存在的字段。db.collectionspace.student.update( {}, { $unset: { name: “Tom” } } )
    create index index_stu_id on student ( stu_id )db.collectionspace.student.createIndex( “index_stu_id”, { stu_id: -1 } )
    drop table studentdb.collectionspace.dropCL( “student” )

    Select

    SQL 语句API 语句
    select from studentdb.collectionspace.student.find()
    select stu_id, age from studentdb.collectionspace.student.find( {},{ stu_id: “01”, age: 20 } )
    select from student where age > 25db.collectionspace.student.find( { age: { $gt: 25 } } )
    select age from student where age = 25 and stu_id= “01”db.collectionspace.student.find( { age: 25, stu_id: “01” }, { age: 25 } )
    select count( * ) from studentdb.collectionspace.student.count()
    select count( stu_id ) from studentdb.collectionspace.student.count( { stu_id: { $exists: 1 } } )

    Delete

    SQL 语句API 语句
    delete from student where age = 20db.collectionspace.student.remove( { age: 20 } )
    delete from studentdb.collectionspace.student.remove()