当前位置:网站首页>21 days learning mongodb notes
21 days learning mongodb notes
2022-04-23 12:42:00 【Saidywin】
Install local MongoDB
stay bin Under the path of mongod --dbpath c:\data\db
perform MongoDB Code for :
> 2 + 2
4
> db
test
> db.runoob.insert({x:10})
WriteResult({ "nInserted" : 1 })
> db.runoob.find()
{ "_id" : ObjectId("625eaa86311de6f041f0ac26"), "x" : 10 }
> use mydb
switched to db mydb
> db
mydb
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
test 0.000GB
> db.movie.insert({"name":"tutorials point"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
mydb 0.000GB
test 0.000GB
> use mydb
switched to db mydb
> db.createCollection("mycollection")
{ "ok" : 1 }
> show collections
movie
mycollection
> db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol",{capped :true, autoIndexID:true, size : 614800\, max:10000})
uncaught exception: SyntaxError: invalid escape sequence :
@(shell):1:74
> db.createCollection("mycol",{capped :true, autoIndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> use mydb
switched to db mydb
> db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol",{capped :true, autoIndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> show collections
movie
mycollection
> db.createCollection("mycol",{capped :true, size : 614800, max:10000})
{ "ok" : 1 }
> db.createCollection("mycol",{capped :true, ndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.ndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol",{capped :true, ndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.ndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> show collections
movie
mycol
mycollection
> show collections
movie
mycol
mycollection
>
MongoDB The following data types are supported :
- String: character string . Data types commonly used to store data . stay MongoDB in ,UTF-8 The encoded string is legal .
- Integer: Integer values . For storing values . Depending on which server you use , Can be divided into 32 Bit or 64 position .
- Boolean: Boolean value . Used to store Boolean values ( really / false ).
- Double: Double precision floating point value . Used to store floating point values .
- Min/Max keys: Combine a value with BSON( The binary JSON) The ratio of the lowest value of an element to the highest value .
- Arrays: Used to store an array or list or values as a key .
- Timestamp: Time stamp . Record when the document was modified or added .
- Object: Used for embedded documents .
- Null: Used to create a null value .
- Symbol: Symbol . This data type is basically the same as the string type , But the difference is , It is commonly used in languages with special symbol types .
- Date: Date time . use UNIX Time format to store the current date or time . You can specify your own time and date : establish Date object , Incoming year, month and day information .
- Object ID: object ID. For creating documents ID.
- Binary Data: binary data . Used to store binary data .
- Code: Code type . Used for storage in documents JavaScript Code .
- Regular expression: Regular expression type . Used to store regular expressions .
SQL The term / Concept | MongoDB The term / Concept | explain / explain |
---|---|---|
database | database | database |
table | collection | Database table / aggregate |
row | document | Data record row / file |
column | field | Data field / Domain |
index | index | Indexes |
table joins | Table joins ,MongoDB I won't support it | |
primary key | primary key | Primary key ,MongoDB Automatically put _id Field sets the primary key |
版权声明
本文为[Saidywin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231239425864.html
边栏推荐
- Basic software testing Day2 - Case Execution
- Lesson 25 static member variables of classes
- [vulnhub range] - DC2
- Qt重绘事件与剪切
- Lesson 24 analysis of classical problems
- Kubernetes 入门教程
- Outsourcing for five years, abandoned
- uni-app 原生APP-本地打包集成极光推送(JG-JPUSH)详细教程
- On using go language to create websocket service
- 标签与路径
猜你喜欢
NPDP | how can product managers not be excluded by programmers?
XinChaCha Trust SSL Organization Validated
[daily question] chessboard question
天梯赛赛前练习
【每日一题】棋盘问题
S2-062 remote command execution vulnerability recurrence (cve-2021-31805)
Redis deployment of cloud native kubesphere
基于卷积神经网络的遥感影像分类识别系统
【蓝桥杯】4月17日省赛刷题训练(前3道题)
Qt进程间通信
随机推荐
box-sizing
Unlock openharmony technology day! The annual event is about to open!
风尚云网学习-h5的input:type属性的image属性
[unity note] basic lighting in l4unity
天梯赛赛前练习
How does sqlserver insert or update the number of weeks of the day instead of text
Markdown语法学习
Fashion cloud learning - input attribute summary
One way ANOVA of SPSS
使用Source Insight查看编辑源代码
XinChaCha Trust SSL Organization Validated
What are the forms of attack and tampering on the home page of the website
BUUCTF WEB [BJDCTF2020]ZJCTF,不过如此
Source code analysis of synchronousqueue
box-sizing
一个平面设计师的异想世界|ONES 人物
STM32工程移植:不同型号芯片工程之间的移植:ZE到C8
SPSS之单因素方差分析
Luogu p5540 [balkanoi2011] timeismoney | minimum product spanning tree problem solution
I changed to a programmer at the age of 31. Now I'm 34. Let me talk about my experience and some feelings