部署独立模式:
切换到 sdbadmin 用户  su - sdbadmin
启动 SequoiaDB Shell 控制台  /opt/sequoiadb/bin/sdb
连接到本地的集群管理服务进程 sdbcm   var oma = new Oma("localhost", 11790)
创建独立模式的数据节点oma.createData(11810, "/opt/sequoiadb/database/standalone/11810")
启动该节点 oma.startNode(11810)
部署集群模式:
切换到 sdbadmin 用户 su - sdbadmin
启动 SequoiaDB Shell 控制台 /opt/sequoiadb/bin/sdb
连接到本地的集群管理服务进程 sdbcm   var oma = new Oma("localhost", 11790)
创建临时协调节点 oma.createCoord(18800, "/opt/sequoiadb/database/coord/18800")
      删除临时协调节点 oma.removeCoord(18800)
启动临时协调节点 oma.startNode(18800)
      连接临时协调节点:var db = new Sdb("localhost",18800)
      创建编目节点组:db.createCataRG("sdbserver1", 11800, "/opt/sequoiadb/database/cata/11800")
      创建编目节点:var cataRG = db.getRG("SYSCatalogGroup")
                             var node1 = cataRG.createNode("sdbserver2", 11800,"/opt/sequoiadb/database/cata/11800")
                             var node2 = cataRG.createNode("sdbserver3", 11800,"/opt/sequoiadb/database/cata/11800")
    启动编目节点:node1.start()
                            node2.start()
    创建数据节点组:var dataRG = db.createRG("datagroup")
    创建数据节点:dataRG.createNode("sdbserver1", 11820, "/opt/sequoiadb/database/data/11820")
                            dataRG.createNode("sdbserver2", 11820, "/opt/sequoiadb/database/data/11820")
                            dataRG.createNode("sdbserver3", 11820, "/opt/sequoiadb/database/data/11820")
    启动数据节点组:dataRG.start()
    创建协调节点组:var coordRG = db.createCoordRG()
    创建协调节点:coordRG.createNode("sdbserver1", 11810, "/opt/sequoiadb/database/coord/11810")
                            coordRG.createNode("sdbserver2", 11810, "/opt/sequoiadb/database/coord/11810")
                            coordRG.createNode("sdbserver3", 11810, "/opt/sequoiadb/database/coord/11810")
    启动协调节点组:coordRG.start()
SequoiaDB shell 主要包括 database(db),collectionspace(cs),collection(cl),cursor(cur),replicagroup(rg),node(nd),domain(dm) 这7大级别的操作
1、 启动 shell:
su - sdbadmin
     /opt/sequoiadb/bin/sdb
2、连接数据库
var db = new Sdb('localhost',11810) 
字段:
数值类型 定义 比较优先级权值 用例
整数
整数,范围 -2147483648 至 2147483647 |
10 |
{ "key" : 123 }
长整数
整数,范围 -9223372036854775808 至 9223372036854775807 如果用户指定的数值无法适用于整数,则 SequoiaDB 自动将 其转化为浮点型
10
{ "key" : 3000000000 }
浮点数
浮点数,范围 -1.7E+308 至 1.7E+308
10
{ "key" : 123.456 } 或 { "key" : 123e+50 }
字符串
双引号包含的字符串
15
{ "key" : "value" }
对象 ID(OID)
十二字节对象 ID
35
{ "key" : { "$oid" : "123abcd00ef12358902300ef" } }
布尔
true 或者 false
40
{ "key" : true } 或 { "key" : false }
日期
YYYY-MM-DD 的日期形式 范围 1900-01-01 至 9999-12-31
45
{ "key" : { "$date" : "2012-01-01" } }
时间戳
YYYY-MM-DD-HH.mm.ss.ffffff 的形式存取 范围 1902-01-01 00:00:00.000000 至 2037-12-31 23:59:59.999999
45
{ "key" : { "$timestamp" : "2012-01-01-13.14.26.124233" } }
二进制数据
Base64 形式的二进制数据
30
{ "key" : { "$binary" : "aGVsbG8gd29ybGQ=", "$type" : "1" } }
正则表达式
正则表达式
50
{ "key" : { "$regex" : "^张", "$options" : "i" } }
对象
嵌套 JSON 文档对象
20
{ "key" : { "subobj" : "value" } }
数组
嵌套数组对象
25
{ "key" : [ "abc", 0, "def" ] }
null
5
{ "key" : null }
1、Java驱动
SequoiaDB 数据库实例 代表一个单独的数据库连接
CollectionSpace 集合空间实例 代表一个单独的集合空间
DBCollection 集合实例 代表一个单独的集合
DBCursor 游标实例 代表一个查询产生的结果集
DBLob 大对象实例 代表一个大对象
2、SQL to SequoiaDB shell to Java
SQL SequoiaDB shell Java Driver
insert into students(a,b) values(1,-1)
db.foo.bar.insert({a:1,b:-1})
bar.insert("{'a':1,'b':-1}")
select a,b from students
db.foo.bar.find(null,{a:"",b:""})
bar.query("", "{'a':'','b':''}", "", "")
select * from students
db.foo.bar.find()
bar.query()
select * from students where age=20
db.foo.bar.find({age:20})
bar.query("{'age':20}", "", "", "")
select * from students where age=20 order by name
db.foo.bar.find({age:20}).sort({name:1})
bar.query("{'age':20}", "", "{'name':1}", "")
select * from students where age > 20 and age < 30
db.foo.bar.find({age:{$gt:20,$lt:30}})
bar.query("{'age':{'$gt':20,'$lt':30}}", "", "", "")
create index testIndex on students(name)
db.foo.bar.createIndex("testIndex",{name:1},false)
bar.createIndex("testIndex", "{'name':1}", false, false)
select * from students limit 20 skip 10
db.foo.bar.find().limit(20).skip(10)
bar.query("", "", "", "", 10, 20)
select count(*) from students where age > 20
db.foo.bar.find({age:{$gt:20}}).count()
bar.getCount("{'age':{'$gt':20}}")
update students set a=a+2 where b=-1
db.foo.bar.update({$set:{a:2}},{b:-1})
bar.update("{'b':-1}", "{'$inc':{'a':2}}", "")
delete from students where a=1
db.foo.bar.remove({a:1})
bar.delete("{'a':1}")
SQL语法
1、创建集合空间
db.execUpdate("create collectionspace foo") //等价于 db.createCS("foo")
2、删除集合空间
db.execUpdate("drop collectionspace foo") //等价于 db.dropCS("foo")
3、创建集合
db.execUpdate("create collection foo.bar") //等价于 db.foo.createCL("bar")
4、删除集合
db.execUpdate("drop collection foo.bar") //等价于 db.foo.dropCL("bar")
5、创建索引
db.execUpdate("create unique index test_index on foo.bar (age desc,name asc)")
6、删除索引
db.execUpdate("drop index test_index on foo.bar") //等价于 db.foo.bar.dropIndex("test_index")
7、返回所有集合空间
db.exec("list collectionspaces") 
8、返回所有集合
db.exec("list collections") 
9、insert into
db.execUpdate("insert into foo.bar(age,name) values(25,"Tom")")
db.foo.bar.insert({
    _id:1,
    name:{fist:"Jhon",last:"Black"},
    phone:[1853742000,1802321000],
    remark:[{
        position:"manager",
        year:2000
    },{
        position:"CEO",
        year:2012
    }]
})
10、select
db.exec("select * from foo.bar")
db.foo.bar.find(
{
    "_id": {
        "$oid": "53a82aa2c4b970091e000000"
    },
    "name": "sequoiadb"
});
11、update
db.execUpdate("update foo.bar set age=20 where age < 10")
db.foo.bar.update({$set:{"name.first":"Mike"}},{_id:1})
12、delete     
db.execUpdate("delete from foo.bar where age <10")
     db.foo.bar.remove({name:"Tom"})
13、transaction     
    db.execUpdate( "begin transaction" )
    db.execUpdate( "commit" )
14、group by
db.exec("select dept_no,count(emp_no) as 员工总数 from foo.bar group by dept_no") 
15、order by
db.exec("select dept_no,count(emp_no) as 员工总数 from foo.bar group by dept_no order by dept_no desc")
16、split by ( 按照某个数组字段将记录拆分)
SELECT * FROM foo.bar SPLIT BY c
17、前10条limit
db.exec("select * from foo.bar limit 10") 
18、跳过前5条offset
db.exec("select * from foo.bar offset 5") 
19、as
集合别名
db.exec("select T1.age,T1.name from foo.bar as T1 where T1.age>10") 
字段别名
db.exec("select age as 年龄 from foo.bar where age>10")
结果集别名
db.exec("select T.age,T.name from (select age,name from foo.bar) as T where T.age>10")
20、inner join
db.exec("select E.emp_no,D.dept_name from foo.emp as E inner join foo.dept as D on E.dept_no=D.dept_no")
21、left outer join 
有员工信息表 foo.emp 和部门信息表 foo.dept,查询员工号 emp_no 所在的部门名 dept_name:
db.exec("select E.emp_no,D.dept_name from foo.emp as E left outer join foo.dept as D on E.dept_no=D.dept_no where D.dept_no < 4")
22、right outer join 
有员工信息表 foo.emp 和部门信息表 foo.dept,查询员工号 emp_no <10 所在的部门名 dept_name:
db.exec("select E.emp_no,D.dept_name from foo.emp as E right outer join foo.dept as D on E.dept_no=D.dept_no where E.emp_no < 10")
23、求和sum
db.exec("select sum(age) as 年龄总和 from foo.bar")
24、计数count
db.exec("select count(age) as 数量 from foo.bar")
25、平均avg
db.exec("select avg(age) as 平均年龄 from foo.bar")
26、最大max
db.exec("select max(age) as 最大年龄 from foo.bar")
27、最小min
db.exec("select min(age) as 最小年龄 from foo.bar")
28、first  选择范围内第一条数据。
    db.exec( "select first(a) as a, b from sample.employee group by b" )
29、last  选择范围内最后一条数据
    db.exec( "select last(a) as a, b from sample.employee group by b" )
30、push  将多个值合并为一个数组。
    db.exec( "select a, push(b) as b from sample.employee group by a" )
30、addtoset 将集合中多条记录中的相同字段的值合并到一个没有重复值的数组中。
    db.exec("select a, addtoset(b) as b from sample.employee group by a")
31、buildtoobj 多个字段合并 
SELECT a, buildobj(b, c) AS d FROM foo.bar
32、mergearrayset  多个数组字段合并为不重复字段的数组
SELECT a, MERGEARRAYSET(b) AS b FROM foo.bar GROUP BY a
SQL to SequoiaDB 映射表

Create 和 Alter

下表列出了各种 SQL 语句表级别的操作和在 SequoiaDB 中对应的操作:
SQL 语句 SequoiaDB 语句
create table student (id not null, stu_id varchar(50), age number primary key(id))
db.collectionspace.student({stu_id:"01",age:20})
db.collectionspace.createCL("student")
alter table student add name varchar(50) db.collectionspace.student.update({},{$set:{name:"Tom"}})
alter table student drop column name 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 student db.collectionspace.dropCL("student")

Insert

下表给出了各种 SQL 语句在表级上的插入操作和 SequoiaDB 上相应的操作:
SQL 语句 SequoiaDB 语句
insert into student(stu_id,age) values("01",20)
db.collectionspace.student.insert({stu_id:"01",age:20})

Select

下表给出了各种 SQL 语句在表级上的读操作和 SequoiaDB 上相应的操作:
SQL 语句 SequoiaDB 语句
select * from student
db.collectionspace.student.find()
select stu_id, age from student
db.collectionspace.student.find({},{stu_id:"01",age:20})
select * from student where age > 25
db.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 student
db.collectionspace.student.count()
select count(stu_id) from student
db.collectionspace.student.count({stu_id:{$exists:1}})

Update

下表给出了各种 SQL 语句在表级上的更新操作和 SequoiaDB 上相应的操作:
SQL 语句 SequoiaDB 语句
update student set age = 25 where stu_id = "01" db.collectionspace.student.update({stu_id:"01"},{$set:{age:25}})
update student set age = age + 2 where stu_id = "01" db.collectionspace.student.update({stu_id:"01"},{$inc:{age:2}})

Delete

下表给出了各种 SQL 语句在表级上的删除记录操作和 SequoiaDB 上相应的操作:
SQL 语句 SequoiaDB 语句
delete from student where age = 20 db.collectionspace.student.remove({age:20})
delete from student db.collectionspace.student.remove()
关系型数据库和非关系型数据库区别:
1、数据存储方式不同。
关系型数据存储在数据表的行和列中,数据表可以彼此关联协作存储。
非关系型数据通常存储在数据集中,就像文档、键值对或者图结构。
2、扩展方式不同。
SQL数据库是纵向扩展,操作的性能瓶颈可能涉及很多个表,这都需要通过提高计算机性能来克服。虽然SQL数据库有很大扩展空间,但最终肯定会达到纵向扩展的上限。
而非关系型数据存储是分布式的,NoSQL数据库的扩展可以通过给资源池添加更多普通的数据库服务器(节点)来分担负载。
3、对事务性的支持不同。
SQL数据库支持对事务原子性细粒度控制,并且易于回滚事务。
NoSQL数据库一般不支持ACID特性

sequoiadb学习笔记相关推荐

  1. 巨杉数据库 sequoiadb学习笔记

    1. sequoiaDB 5.0 支持安全鉴权协议是:SCRAM-SHA-256 和 MD5 2. sequoiaDB 逻辑时间包含:本地,全局,逻辑时间容错差        3种 3. sequoi ...

  2. SequoiaDB v5.2 学习笔记

    SequoiaDB v5.2 学习笔记 文章目录 SequoiaDB v5.2 学习笔记 湖仓一体 什么是"湖仓一体"? 为什么要引入湖仓一体? 市场需求 "数据沼泽&q ...

  3. NoSQL学习笔记之MongoDB-01初识NoSQL

    NoSQL学习笔记之MongoDB-01初识NoSQL 一.什么是NoSQL NoSQL的出现背景: 随着互联网的发展,数据量激增,传统的集中式关系型数据库已经无法满足互联网海量数据的存储及使用需求. ...

  4. 巨杉数据库学习笔记+巨杉数据库实操项目实践

    @TOC巨杉数据库学习笔记+项目实践心得 SequoialDB简介 SequoiaDB 巨杉数据库是一款金融级分布式数据库,主要面对高并发实时处理型场景提供高性能.可靠稳定以及无限水平扩展的数据库服务 ...

  5. PyTorch 学习笔记(六):PyTorch hook 和关于 PyTorch backward 过程的理解 call

    您的位置 首页 PyTorch 学习笔记系列 PyTorch 学习笔记(六):PyTorch hook 和关于 PyTorch backward 过程的理解 发布: 2017年8月4日 7,195阅读 ...

  6. 容器云原生DevOps学习笔记——第三期:从零搭建CI/CD系统标准化交付流程

    暑期实习期间,所在的技术中台-效能研发团队规划设计并结合公司开源协同实现符合DevOps理念的研发工具平台,实现研发过程自动化.标准化: 实习期间对DevOps的理解一直懵懵懂懂,最近观看了阿里专家带 ...

  7. 容器云原生DevOps学习笔记——第二期:如何快速高质量的应用容器化迁移

    暑期实习期间,所在的技术中台-效能研发团队规划设计并结合公司开源协同实现符合DevOps理念的研发工具平台,实现研发过程自动化.标准化: 实习期间对DevOps的理解一直懵懵懂懂,最近观看了阿里专家带 ...

  8. 2020年Yann Lecun深度学习笔记(下)

    2020年Yann Lecun深度学习笔记(下)

  9. 2020年Yann Lecun深度学习笔记(上)

    2020年Yann Lecun深度学习笔记(上)

最新文章

  1. hadoop配置文件默认配置
  2. 利用canvas绘制动态仪表盘
  3. django缓存优化(二)
  4. 计算机爱好者协会义务维修的目的,计算机协会义务维修活动总结范文
  5. [洛谷P4838]P哥破解密码
  6. Isight做MATLAB优化,iSight结构优化基础16讲-学会使用isight控制ABAQUS、APDL等CAE软件...
  7. 常见数据结构面试题(2022年最新版)
  8. 对多元函数微分一些思考和总结
  9. librosa的短时傅里叶实现librosa.stft()
  10. 什么叫DMZ区?DMZ区它有什么作用?
  11. 幼儿-综合素质【9】
  12. 条件覆盖,路径覆盖,语句覆盖
  13. 蜘蛛:请求头、响应头、响应码
  14. leetcode_Permutations II
  15. pion demo运行
  16. 你真的了解“药品追溯码”吗?
  17. 蓝牙HC-05出现进入AT模式之后串口发送AT无返回值或者返回乱码情况
  18. 无法加载操作系统,原因是关键系统驱动驱动程序丢失或包含错误 kisboot.sys
  19. mysql compact_在 MySQL InnoDB 中,COMPRESSED, COMPACT 和DYNAMIC 有什么区别?
  20. 与2,3,5无关的数

热门文章

  1. 0CTF-2016-piapiapia(php反序列化长度变化尾部字符串逃逸)
  2. 物联网毕设 -- 基于STM32的水产养殖
  3. 24.(C语言)根据输入的三角形的三边判断是否能组成三角形,若可以则输出它的面积
  4. CVE-2016-0165 分析利用POC
  5. 《谁动了我的奶酪》阅读笔记
  6. Webservice应用
  7. 多串口卡在装车计量系统中的应用 (转)
  8. 陕西铨讯电子厂工程师_2020年陕西省工业和信息化厅关于工程师职称评审的公告...
  9. 借助台式机和笔记本完成vsphere5.1的实验
  10. 使用css样式替换pre标签