Here
we will learn to create and drop the MongoDB Collection. For this we have to
require MongoDB client and server.
In
MongoDB, collection term is used instead of SQL table and document is used in
term of collection element.
Step-1: Switch to required Database
Here
use command used to change the database that is available if that named
database is not available than it will create new database automatically.
Create the Collection
In client window type follow command to create Collection.
Here given command used to insert document in collection that is available if that named collection
is not available than it will create new collection automatically. This command will not give any collection not
found type such errors.
The
document format is shown as below.
Document
specify key_name and its value seprated by : (Colon) and multiple key_names are
seprated by ,(coma).
Drop the Collection
In client window type follow command to drop the specific collection.
Syntex: db.Collection_Name.drop();
Here drop() function is used with current database reference
variable db and specific collection name to drop the collection.
This comment has been removed by a blog administrator.
ReplyDelete