You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
422 B
Plaintext

// Create an index
db.books.createIndex({title:1})
// Type 1 means ascending; -1 means descending
// Create a unique index
db.books.createIndex( {isbn:1},{unique:true} )
// Create a index on multiple fields (compound index)
db.books.createIndex({title:1, author:-1})
// Show all indexes in a collection
db.books.getIndexes()
// Drop an index
db.books.dropIndex({author:-1})
// Show index statistics
db.books.stats()