Show Menu
Cheatography

MongoDB to SQL Cheat Sheet (DRAFT) by

Taken from the mongoDB reference manual http://docs.mongodb.org/manual/reference/sql-comparison/ and http://docs.mongodb.org/manual/reference/sql-aggregation-comparison/

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Terms

SQL
MongoDB
table
collection
row
document / BSON document
column
field
 

Add/Ed­it/­Delete Schema

CREATE DATABASE dbName
use [dbName]
CREATE TABLE testTable (...)
db.tes­tTa­ble.in­sert( {testID: 1, attr: "­a"})
CREATE TABLE testTable (...)
db.cre­ate­Col­lec­tion( "­tes­tTa­ble­")
CREATE INDEX idx_test ON testTa­ble­(te­stID)
db.tes­tTa­ble.en­sur­eIndex( {testID})
DROP TABLE testTable
db.tes­tTa­ble.drop()