Home / Articles / Database / mongodb / 5.0 / create-collections

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
  • # use employee switched to db employee
  • Run below command to create new collection or table
  • employee> db.createCollection( "emp_info" ) { ok: 1 }
  • Show the collections in current database
  • employee> show collections emp_info