mongdb学习笔记
生活随笔
收集整理的這篇文章主要介紹了
mongdb学习笔记
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
mongodb學(xué)習(xí)資源:https://www.runoob.com/mongodb
pymongo基本語法
1. 查看所有數(shù)據(jù)庫
$ ./mongo MongoDB shell version: 3.0.6 connecting to: test > show dbs local 0.078GB test 0.078GB2. 切換數(shù)據(jù)庫
運(yùn)行"use"命令,可以連接到一個(gè)指定的數(shù)據(jù)庫。db查看當(dāng)前數(shù)據(jù)庫
> use local
switched to db local
> db?
local
local:?這個(gè)數(shù)據(jù)永遠(yuǎn)不會(huì)被復(fù)制,可以用來存儲限于本地單臺服務(wù)器的任意集合
文檔中的鍵/值對是有序的。
?3.創(chuàng)建數(shù)據(jù)庫
use test01
如果數(shù)據(jù)庫不存在,則創(chuàng)建數(shù)據(jù)庫,否則切換到指定數(shù)據(jù)庫。
4. 查看集合 刪除集合
> show tables > db.site.drop()創(chuàng)建集合 db.createCollection("runoob") mycol2 即使不存在也會(huì)被創(chuàng)建 db.mycol2.insert({"name" : "菜鳥教程"})
db.collection.drop()、
插入文檔
MongoDB 使用 insert() 或 save() 方法向集合中插入文檔,語法如下:db.COLLECTION_NAME.insert(document)
MongoDB 查詢數(shù)據(jù)的語法格式如下:
>db.col.find().pretty()
pretty() 方法以格式化的方式來顯示所有文檔。
?
? ? ? ? ?轉(zhuǎn)載于:https://www.cnblogs.com/andylhc/p/9647451.html
總結(jié)
以上是生活随笔為你收集整理的mongdb学习笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP实现redis限制单ip、单用户的
- 下一篇: [转] getBoundingClie