CappedCollection to view the collection status information db. cot1.stats (); view the status information of cot1 to delete the specified database. collection1.drop (); the default value of centralized creation for Delete collection1 collection mongoDB is implicitly created. You can use createCollection to display the creation of a collection db. createCollection (collect );
CappedCollection to view the collection status information db. cot1.stats (); // view the status information of cot1 in the collection. Delete the specified database. collection1.drop (); // you can use createCollection to display and create a collection database. createCollection ("collect ");
Capped Collection
View the collection status information db. cot1.stats (); // view the status information of cot1 in the collection. Delete the specified database. collection1.drop (); // you can use createCollection to display and create a collection database. createCollection ("collect"); deletes the specified database. dropDatabase (); // Delete the current database query all databases show dbs // query all databases to display all the collections show tables in the current database; or show collections;
Features of a fixed set
Fixed Set attributes and usage:
Attribute 1: Fast insertion of fixed sets
Attribute 2: Query output in the insert order is extremely fast
Usage 1: store log information
Usage 2: cache a small number of documents
Create a fixed set
Eg. db. createCollection ("collect", {capped: true, size: 10000 });
When you create a capped collection, you can specify the maximum number of documents that can be stored in the collection. However, you must specify the size because you always check the size before checking maxRowNumber. you can use validate () to check the space used by a collection, and then set the size to a large value.> db. createCollection ("mycappedcoll", {capped: true, size: 10000, max: 100}) {"OK": 1}> db. mycappedcoll. validate (); when you create a collection, there is also a parameter "autoIndexID", which can be "true" and "false" to determine whether to create an index on "_ id, for example,> db. createCollection ("mycappedcoll", {capped: true, size: 10000, max: 100, autoIndexId: false}) by default, indexes are created for General collections, however, capped collection is not created. capped collection cannot be Shard, which also makes sense. Sharding is not significant for a table that is often refreshed and of fixed size.
Conversion set
To convert a common set to a fixed set, use the convertTocapped command.
Db. runCommand ({convertTocapped: "test", size: 10000 });
Natural sorting
Db. mycappedcolt. find (). sort ({"$ natural": 1 });
Determines whether a set is a fixed set.
Db. colt. isCapped ();
View Collection status information
Db. colt. stats ();
GridFS
GridFS can avoid file system problems when users upload content.
GridFS does not generate disk fragments
GridFS Storage Data
GrdiFS uses two tables to store data:
Files contains metadata objects
Chunks binary block that contains other related information.
You can change the prefix of a third-party language.
Use GridFS Program Files
Eg .. /program files put testfile.zip. /program files list. /program files get testfile.zip. /Program Files delete testfile.zip verify md5mg5sum testfiles.zip at this time, log on to mongo, show tables, you can see two new files fs. files and fs. chunks. view fs. files content db. fs. files. find (); fs. files stores some basic metadata information. db. fs. chunks. find (); fs. chunks stores some actual content data information.
For more information, see [].
, Hong Kong Server rental, Hong Kong server, Hong Kong Virtual Host