当前位置:网站首页>Collection of mongodb databases

Collection of mongodb databases

2020-11-10 16:01:00 Peng Yuer's Keeper

MongoDB Set related commands
One 、 View all collections in the current database :
show collections
Two 、 Create set

  1. Automatically create collections
    To the nonexistent set 1 Secondary addition ⼊ Data time , The collection will be created
  2. Create collections manually
    The command format is as follows :
    db.createCollection(name,options)
    demo:
    db.createCollection("stu")
    demo2:
    db.createCollection("sub", { capped : true, size : 10 } )
    explain :

Parameters capped: The default value is false Means no upper limit is set , The value is true Indicates setting the upper limit
Parameters size: When capped The value is true when , This parameter needs to be specified , Indicates the upper limit ⼤⼩, When ⽂ When the gear reaches the upper limit , Will overwrite the previous data , The unit is byte
Check if the set has an upper limit : db. Collection name .isCapped()
3、 ... and 、 Delete the collection
db. Collection name .drop()

版权声明
本文为[Peng Yuer's Keeper]所创,转载请带上原文链接,感谢