Create a database
>use MyDB
Switched to DB MyDB
View all data Sheets
>show Collections
System.indexes
Create a data table
>db.createcollection ("Tb_user")
{"OK":1}
> Db.createcollection ("Test", {capped:true, size:10000}) {"OK": 1}
{"OK": 1}
--Description
Capped:true, which indicates that the structure of the collection cannot be modified;
Size: A certain amount of space is specified at the beginning of the table, and subsequent insertions continue sequentially append the data in this pre-allocated file, and if the space size is exceeded, back to the file header overwriting the original data and continuing the insertion. This structure guarantees the efficiency of insert and query, it does not allow the deletion of individual records, there is also a limit to update: cannot exceed the size of the original record. This kind of table is very efficient, it is suitable for some temporary preservation of the data, such as the site of the user's session information, such as some of the program's monitoring log, is a certain amount of time can be overwritten by the data.
Modify the data table name
>db.tb_user.renamecollection ("Tb_user1")
{"OK":1}
Database basic operations for MongoDB