MongoDB常用操作
发表于:2025-11-10 作者:千家信息网编辑
千家信息网最后更新 2025年11月10日,关系型数据库名词与MongoDB对比:关系数据库MongoDBDatabaseDatabaseTableCollectionRowDocumentIndexIndexJoinLookupForeign
千家信息网最后更新 2025年11月10日MongoDB常用操作
关系型数据库名词与MongoDB对比:
| 关系数据库 | MongoDB |
| Database | Database |
| Table | Collection |
| Row | Document |
| Index | Index |
| Join | Lookup |
| Foreign Key | Reference |
| Multi-table transaction | Single document transaction |
命令行使用MongoDB
插入你的第一数据
> show databases
local 0.000GB
> use test #切换到test数据库,如果没有则新建
switched to db test
> show databases local 0.000GB
> db.demo.insert( { "key" : "value" } ) WriteResult({ "nInserted" : 1 })
> show databases local 0.000GB test 0.000GB
> show collections demo
> db.demo.findOne() { "_id" : ObjectId("573af7085ee4be80385332a6"), "key" : "value" }
python中使用MongoDB
import pymongo## client defaults to localhost and port 27017. eg MongoClient('localhost', 27017)client = pymongo.MongoClient()#连接到本地数据库blogDatabase = client[ "blog" ] #切换到blog数据库usersCollection = blogDatabase[ "users" ] #切换到usersCollectionusersCollection.insert_one( { "username" : "jdrumgoole","password" : "top secret","lang" : "EN" })#插入一条数据user = usersCollection.find_one()#查找最新的一条数据print( user )articlesCollection = blogDatabase[ "articles" ]author = "jdrumgoole"article = { "title" : "This is my first post","body" : "The is the longer body text for my blog post. We can add lots of text here.","author" : author,"tags" : [ "joe", "general", "Ireland", "admin" ]}## Lets check if our author exists#if usersCollection.find_one( { "username" : author }) :articlesCollection.insert_one( article )else:raise ValueError( "Author %s does not exist" % author )
数据
数据库
切换
名词
命令
常用
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全教育 教学评价
办公网络安全故事
杭州软件开发培训可靠吗
上海飞鹰网络技术有限公司
数据库安全性
数据库来了
软件开发无锡友鹏
企业网络安全解决
恢复服务器硬盘数据库价格行情
告诉家长要注意网络安全
临沂5g基站服务器代码
什么是5g无线网络技术
立体版网络安全手抄报
西安微趋道互联网科技
石林信息化软件开发
如家公共网络安全么
霞浦县胜特网络技术服务部
mysql数据库创建树结构
重庆网络安全监察部门
魅族浏览器数据库
外部的数据库驱程序 1
apex我们玩的是什么服务器
软件开发公司门槛高吗
京东用的是哪一家的云计算服务器
济南ntp网络时间服务器
类似svn的文件服务器管理软件
数据共享和数据库
华为鲲鹏服务器直销厂家
中医特色技术人才数据库王平
大汉软件开发者大会