mongodb常用語句(一)
阿新 • • 發佈:2019-01-10
建立資料庫
1
use mydb
2
show dbs
3
db.movie.insert({"name":"tutorials point"})
刪除資料庫
1
>use mydb
switched to db mydb
>db.dropDatabase()
>{ "dropped" : "mydb", "ok" : 1 }
db.site.drop()
建立集合
1
db.createCollection("mycollection")
2
db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
3
db.tutorialspoint.insert({"name" : "tutorialspoint"})
刪除集合
1
db.mycollection.drop()
插入文件
>db.col.insert({title:'MongoDB 教程', description:'MongoDB 是一個 Nosql 資料庫',by:'菜鳥教程', url:'http://www.runoob.com', tags:['mongodb','database','NoSQL'], likes:100})