命令来显示我当前在 MongoDB 中使用的 db?

在 MongoDB shell 中显示当前 db 的命令是什么?

(我在谷歌上找不到)

29826 次浏览

Found it by guessing :) Simply:

db

The command to get database name in the shell is:

> db.getName()

While just typing db works, you will find that this only works interactively and if you're working on a script this may not give the result you want.

db.current

is a CLI command that will show you the database you are currently working in