Last active
August 29, 2015 14:08
-
-
Save byplayer/b190ff1ab94a6f7a0abc to your computer and use it in GitHub Desktop.
mongo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// concept | |
database | |
- collection(table) | |
- document(row) | |
- field(column) | |
// | |
// definition | |
// use [database name] | |
use [database name] | |
// show databases | |
show dbs | |
// show tables | |
show collections | |
// drop database | |
use [target database name] | |
db.dropDatabase() | |
// index | |
// create index | |
db.unicorns.ensureIndex({name: 1}); | |
// drop index | |
db.unicorns.dropIndex({name: 1}); | |
// unique index | |
db.unicorns.ensureIndex({name: 1}, {unique: true}); | |
// comprex index | |
db.unicorns.ensureIndex({name: 1, vampires: -1}); | |
// explain | |
db.unicorns.find().explain() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment