Command summary (discussed in the following):
- Create a Collection:
use <dbName>; db.<collection>.insertOne({ // document }); or db.createCollection(<collection>);
- Delete a Collection:
use <dbName>; db.<collection>.drop();
The procedure for creating a new collection is identical to the one discussed previously when creating a new database. You first use the database, and then use either of the db.<collection> methods insertOne() or insertMany() to add one or more documents. Alternatively, you can use the db.createCollection() method to create an empty collection. The command show collections shows you which collections have been defined for this database:
To remove the collection, simply issue the command