Skip to content
Menu
  • Company
    • About Us
    • Store
    • Contact Us
  • E – Seva Kendra Common Service Center
  • Products And Services
  • Join our Social Network
  • Search
  • Company
    • About Us
    • Store
    • Contact Us
  • E – Seva Kendra Common Service Center
  • Products And Services
  • Join our Social Network

Instarr Softwares Ichalkaranji

Good sales people are first to be hired and last to be fired - Mr Shiv Khera

Create Database

MongoDB Create Database
Use Database method:

There is no create database command in MongoDB. Actually, MongoDB do not provide any command to create database.

SQL: To create a database, table and insert values in the table manually.

MongoDB: To create a database manually because MongoDB will create it automatically when you save the value into the defined collection at first time.

If there is no existing database, the following command is used to create a new database.

Syntax:

use DATABASE_NAME

If the database already exists, it will return the existing database.

 

To check the currently selected database, use the command db:

 >db

To check the database list, use the command show dbs:

 >show dbs
Insert document it to database:

>db.movie.insert({“name”:“javatpoint”})

 

MongoDB Drop Database

The dropDatabase command is used to drop a database,deletes the associated data files.
Syntax:

 db.dropDatabase()

Now check the list of databases:

 >show dbs

MongoDB Create Collection

In MongoDB, db.createCollection(name, options) is used to create collection. But usually you don?t need to create collection. MongoDB creates collection automatically when you insert some documents.

Syntax:

 db.createCollection(name, options)

Name: is a string type, specifies the name of the collection to be created.

Options: is a document type, specifies the memory size and indexing of the collection.

>db.createCollection(“SSSIT”)

To check the created collection, use the command “show collections”.

>show collections

 

How does MongoDB create collection automatically

MongoDB creates collections automatically when you insert some documents.

For example:

Insert a document named seomount into a collection named SSSIT. The operation will create the collection if the collection does not currently exist.

 >db.SSSIT.insert({“name” : “seomount”})

>show collections

SSSIT

If you want to see the inserted document, use the find() command.

Syntax:

db.collection_name.find()

MongoDB Drop collection

It completely removes a collection from the database

db.COLLECTION_NAME.drop()

Now drop the collection with the name SSSIT:

>db.SSSIT.drop()

  • Web Development Course HTML | CSS | Javascript
  • Mysql Database Course
  • PHPmyadmin Course
  • PHP Coding Course
  • Image OCR to Text
  • Solutions to Problems
  • New Instarr Email yourname.instarr@gmail.com
  • Sign Up to Trello for your daily work assignments
  • Keep Open Whatsapp in PC
  • Install XAMPP to Linux
  • Create Gmail Email Templates for Marketing
  • PDF Tools
  • Files Shared instarrcom@gmail.com
  • Learning Center

Copyright © 2025 Instarr Softwares Ichalkaranji. All Rights Reserved.

Codilight Theme by FameThemes