Create Collections or Tables
Open MongoDB Shell
- Open the MongoDB Shell from Linux shell
# mongosh
Current Mongosh Log ID: 6117225c105379b62b6abaa9
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 5.0.2
Using Mongosh: 1.0.5
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
test>
Create Collections
- Switch to our "employee" database
- Run below command to create new collection or table
- Show the collections in current database
# use employee
switched to db employee
employee> db.createCollection( "emp_info" )
{ ok: 1 }
employee> show collections
emp_info