ตรวจสอบฐานข้อมูลปัจจุบันที่ใช้งานอยู่
ใช้คำสั่ง db เพื่อแสดงชื่อฐานข้อมูลที่กำลังใช้งานอยู่
ตัวอย่างการใช้งาน
> show dbs;
admin 0.000GB config 0.000GB local 0.000GB sample 0.000GB sampleDemo 0.000GB studentSearch 0.000GB test 0.003GB
> db;
sample
แสดงว่ากำลังใช้งานฐานข้อมูล 'sample' อยู่
สลับฐานข้อมูลและตรวจสอบอีกครั้ง
> use test; switched to db test > db;
test
วิธีอื่นๆ ในการตรวจสอบ
db.getName()- คืนค่าชื่อฐานข้อมูลปัจจุบันdb.current- แสดงฐานข้อมูลปัจจุบัน (รูปแบบ test.current)
> db.getName();
test
> db.current;
test.current