Wednesday, January 29, 2014

RDBMS and MongoDB cheat sheet

In this post I am going to share the RDBMS and MongoDB CheatSheat. If you come from RDBMS (Oracle, SQL Server, DB2 etc.) background, this will help you for your quick reference.

You can also download the cheat sheet here

RDBMS MongoDB
Database Database
Table Collection
Row Document
To create Database

CREATE DATABSE database_name(…)
To create Database

use database_name
To drop Database

DROP DATABSE database_name
To drop Database

use databasename
db.dropDatabase()
To create Table

CREATE TABLE table_name (…)
To create collection

db.createCollection(collection_name)
OR
db.Collectio_Name.Insert(…)
To drop Table

DROP TABLE table_name
To drop Collection

db.collectioname.drop()
To see all the records of a table

SELECT * FROM tablename
db.collectionname.find()
To see all the database

SELECT name, database_id, create_date
FROM sys.databases
show dbs
To add records in table

INSERT INTO tablename Values(value1, value2 …)
db.collectioname.insert({key1:value1,key2:value2,…})
To Delete all records of a table

Truncate Table tablename
db.collectioname.remove()
To Delete specific records of a table

DELTE FROM tablename WHERE condition
To Delete specific records of a collection

db.collectioname.remove(Deletion_Criteria)
To update records

UPDATE table_name SET …
To update documents
db.collectioname.update(selection_criteria, new_data)
Logical Operators in RDBMS

- AND
- OR
- ANY
- BETWEEN
- LIKE
- IN
- NOT
- ALL
Logical Operators in RDBMS

- AND = {,}
- OR = $or:[ ... ]
Comparison Opeators in RDBMS

= (Equal)
< (Less than)
<= (Less than or equal to)
> (Greater than)
>= (Greater than or equal to)
!= (Not equal to)
Comparison Opeators in MongoDB

:
$lt
$lte
$gt
$gte
$ne

Popular Posts

Real Time Web Analytics