Wednesday, March 30, 2016

MONGO DB BASICS

*******************************
LOGIN INTO MONGO DATABASE
*******************************

C:\MongoDB\bin>mongo.exe
2016-03-30T10:31:31.317-0500 I CONTROL  [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
MongoDB shell version: 3.2.4
connecting to: test
> show dbs
local  0.000GB

*******************************
USE MYDB DATABASE
*******************************

> use mydb
switched to db mydb
> show dbs
local  0.000GB
> db
mydb

**********************************
Insert into MYDB
**********************************
> db.movie.insert({"name":"tutorials point"})
WriteResult({ "nInserted" : 1 })
> show dbs
local  0.000GB
mydb   0.000GB

*******************************
DROP MYDB DATABASE
*******************************

If you want to drop a database in MONGO DB <mydb>, then dropDatabase() command would be as follows:

1. change your current DB to MYDB
2. Drop using below cmd.

> use mydb
switched to db mydb

> db.dropDatabase()
{ "dropped" : "mydb", "ok" : 1 }
> show dbs
local  0.000GB
>

*******************************
CHECK MONGODB VERSION
*******************************


> db.version()
3.2.4