1 刪除數據庫
命令:db.dropDatabase()
用法:
show dbs
use mydb
db.dropDatabase()
最后,通過 show dbs 查看是否刪除成功。
2 刪除集合
命令:db.collection.drop()
用法:
use testDb 切換到指定數據庫
show tables 列舉所有的集合
db.myColl.drop() 刪除指定集合
show tables 最后通過show tables命令查看集合是否刪除成功。
3 重命名集合
db.collection.rename("xxx");