MongoDB for SQL users
Writing by shivdev on Thursday, 18 of December , 2014 at 11:42 pm
Here’s a Quick Reference to get started
Description | SQL | Mongo DB | |
---|---|---|---|
Lingo 1 | Table; Relation | Collection | |
Lingo 2 | Row; Record; Tuple | Document | |
List Databases | SHOW databases | show databases | |
List Tables | SHOW tables | show collections | |
Switch to a DB | USE db | use db | |
Show Table Data | SELECT * FROM table | db.collection.find.pretty() | |
Filter Table Data | WHERE colum = 'value' | db.collection.find({'column':'value'}) | |
Select Columns | SELECT col1, col2 | db.collection.find({},{col1:1, col2:1}) | |
Delete Rows | DELETE FROM table WHERE col='val' | db.collection.remove({'col':'val'}) | |
Get Rid of a Table | DROP table | db.collection.drop() | |
Leave a comment
- Add this post to
- Del.icio.us -
- Digg -
- -
- Tweet -
-
-