CouchDB是一种文件存储数据库,一种开源的非关系数据库,CouchDB使用JSON来存储数据,使用JavaScript作为查询语言来转换文档,使用MapReduce和HTTP作为API。
The CouchDB file layout and commitment system features all Atomic Consistent Isolated Durable (ACID) properties. On-disk, CouchDB never overwrites committed data or associated structures, ensuring the database file is always in a consistent state.
Document fields are uniquely named and contain values of varying types (text, number, boolean, lists, etc), and there is no set limit to text size or element count.
Any number of clients can be reading documents without being locked out or interrupted by concurrent updates, even on the same document. CouchDB read operations use a Multi-Version Concurrency Control (MVCC) model where each client sees a consistent snapshot of the database from the beginning to the end of the read operation.
数据结构
Documents are indexed in B-trees by their name (DocID) and a Sequence ID.These B-tree indexes are updated simultaneously when documents are saved or deleted. The index updates always occur at the end of the file (append-only updates).
数据存储
Documents have the advantage of data being already conveniently packaged for storage rather than split out across numerous tables and rows in most database systems. When documents are committed to disk, the document fields and metadata are packed into buffers, sequentially one document after another (helpful later for efficient building of views).
When CouchDB documents are updated, all data and associated indexes are flushed to disk and the transactional commit always leaves the database in a completely consistent state.
Data in CouchDB is stored in semi-structured documents. CouchDB documents are flexible and each has its own implicit structure, which alleviates the most difficult problems and pitfalls of bi-directionally

Curl 默认执行GET操作,使用curl -X POST 或PUT更改操作。-X命令用于记录历史操作记录
To make it easy to work with our terminal history, we usually use the -X option even when issuing GET requests.
Everything is done using GET, PUT, POST, and DELETE with a URI.
查看现有的数据库:
curl -X GET http://127.0.0.1:5984/_all_dbs
创建新的数据库:
curl -X PUT http://127.0.0.1:5984/baseball

删除数据库:
curl -X DELETE http://127.0.0.1:5984/baseball
-v(verbose)命令用于打印进程信息curl -vX DELETE http://127.0.0.1:5984/baseball

使用curl创建文档:
在数据库hello中创建“id”:“10010”的文档,并且写入多个数据,注意这里的格式与网络上的教程有差别,网上教程的格式无法正常写入(正常仅使用双引号,并且在JSON中的双引号前加\)
curl -H “Content-Type: application/json” -X PUT http://localhost:5984/hello/“10010” -d “{\”name\”:\”minsu\”, \”age\”:\”24\” , \”address\” : \”No. 112 ZhongShangRoad GuangZhou\” }”

使用id查看文档的数据:curl http://127.0.0.1:5984/hello/10010

使用curl修改文档:
查看文档当前的版本信息:
C:\Users\zhengxf>curl http://127.0.0.1:5984/hello/10010
{“_id”:”10010”,”_rev”:”2-24c0341a26e2c5bf14d6f7b88ba4ea59”,”age”:”24”}

使用当前的版本信息对文档进行修改:
C:\Users\zhengxf>curl -H “Content-Type: application/json” -X PUT http://localhost:5984/hello/10010 -d “{\”age\”:\”23\” ,\”_rev\”:\”2-24c0341a26e2c5bf14d6f7b88ba4ea59\” }”
修改时需要给出文档的版本号

使用curl删除文档:
C:\Users\zhengxf>curl -H “Content-Type: application/json” -X DELETE http://localhost:5984/hello/001?rev=1-384d2bc91a881c6f9509b974573707bb
同样需要指定删除文档的版本号

CouchDB学习总结相关推荐

  1. 史上最全的“大数据”学习资源

    2019独角兽企业重金招聘Python工程师标准>>> 资源列表: 关系数据库管理系统(RDBMS) 框架 分布式编程 分布式文件系统 文件数据模型 Key -Map 数据模型 键- ...

  2. couchdb 视图操作_couchDB视图

    视图函数 map函数 Map方法的参数只有一个,就是当前的文档对象.Map方法的实现需要根据文档对象的内容,确定是否要输出结果. 如果需要输出的话,可以通过emit来完成. emit方法有两个参数,分 ...

  3. 我自学python的路-Python的学习路经

    本系列Python技术路径中包含 入门知识.Python基础.Web框架.基础项目.网络编程.数据与计算.综合项目.想学习Python的可以加下QQ群:589306326 七个模块.路径中的教程将带你 ...

  4. 2017 年该学习的编程语言、框架和工具

    转:http://top.jobbole.com/35926/?utm_source=blog.jobbole.com&utm_medium=sidebar-top-news 软件开发行业继续 ...

  5. nosql数据库学习总结

    大数据时代的数据库选择:SQL还是NoSQL? 执行大数据项目的企业面对的关键决策之一是使用哪个数据库,SQL还是NoSQL?SQL有着骄人的业绩,庞 大的安装基础;而NoSQL正在获得可观的收益,且 ...

  6. 【学习】程序员技术练级攻略

    为什么80%的码农都做不了架构师?>>>    月光博客6月12日发表了<写给新手程序员的一封信>,翻译自<An open letter to those who ...

  7. 第二弹:超全Python学习资源整理(进阶系列)

    造一个草原要一株三叶草加一只蜜蜂.一株三叶草,一只蜂,再加一个梦.要是蜜蜂少,光靠梦也行. - 狄金森 "成为编程大牛要一门好语言加一点点天分.一门好语言,一点点天分,再加一份坚持.要是天分 ...

  8. Python3 爬虫学习笔记 C11【数据储存系列 — MongoDB】

    Python3 爬虫学习笔记第十一章 -- [数据储存系列 - MongoDB] 文章目录 [11.1]关于 MongoDB [11.2]MongoDB 基本操作语句 [11.3]连接 MongoDB ...

  9. 最全的“大数据”学习资源

    关系数据库管理系统(RDBMS) 框架 分布式编程 分布式文件系统 文件数据模型 Key -Map 数据模型 键-值数据模型 图形数据模型 NewSQL数据库 列式数据库 时间序列数据库 类SQL处理 ...

最新文章

  1. Linux 下关于网络的几个命令
  2. docker安装Jenkins:查看安装版本信息
  3. HIBERNATE 持久化基础
  4. get_children 方法里面参数 iv_as_copy 有什么用?
  5. 怎么实现页面友好跳转_如何实现软,友好和一致的UI设计
  6. JavaOne正在重建动力
  7. 浅谈V8引擎中的垃圾回收机制
  8. Windows xp 定时关机命令
  9. oracle ola_Ola HallengrenSQL Server维护解决方案–索引和统计信息维护
  10. php 获取TZ时间格式
  11. 【完美解决】arcgis engine 10.0 for cross platform C++ 在visual studio2010上编译的AE程序 的License无法初始化错误。...
  12. 欧几里得算法和唯一分解定理
  13. sm是什么职位_职位或职级ED MD SM M 是什么意思?
  14. python 编程 安卓脚本_详解基于Android的Appium+Python自动化脚本编写
  15. ESR-CMDS参数含义
  16. Dynamics CRM 客户端程序开发:常用工具介绍之Dynamics XRM Tools
  17. 【单片机笔记】运放电流检测实用电路
  18. 新版火狐 拖 功能_Firefox 33的新功能
  19. 计算机控制键盘,键盘装置及其计算机控制系统的制作方法
  20. 用html实现抽奖大转盘,【项目实战】用CSS实现一个抽奖转盘(附详细代码+思路)...

热门文章

  1. cpu超线程优缺点_超线程 多核 多处理器区别
  2. 化简分数,输入分子和分母,输出化简后的分子和分母。采用无脑迭代法;
  3. IOT超低功耗设计应用笔记
  4. 汽车车载天线整车测试方案
  5. 《 敏捷软件开发》已开始连载
  6. 《CISP》(十)软件安全开发
  7. 客快物流大数据项目(一百零八):Spring Cloud 技术栈
  8. 聊一聊CSS3的渐变——gradient
  9. 卡西尼卵形线matlab,每日一题[339]卡西尼卵形线
  10. SQL Server 存储过程中使用raiserror抛出异常