当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
风尚云网学习-h5的input:type属性的image属性
How does sqlserver insert or update the number of weeks of the day instead of text
A graphic designer's fantasy world | ones characters
万事有你 未来可期 | ONES 2022校园招聘正式开启
PHP generates JSON to process Chinese
Unlock openharmony technology day! The annual event is about to open!
Stacks and queues a
MySQL函数-递归函数
Fashion cloud learning - input attribute summary
基于卷积神经网络的遥感影像分类识别系统
Lesson 24 analysis of classical problems
Introduction to metalama 4 Use fabric to manipulate items or namespaces
box-sizing
RT-thread中关键词解释及部分API
甲辰篇 創世紀《「內元宇宙」聯載》
[csnote] ER diagram
Analysis of InnoDB execution process in MySQL
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
SSM框架系列——Junit单元测试优化day2-3
网络信息安全之零信任









![[vulnhub range] - DC2](/img/b7/c34f69a231dad653b8a912f1f36bef.png)