MongoDB equivalent of SQL 'SELECT * FROM ...'

Whereas in SQL you might run

select_all.sql
SELECT * FROM mytable;

to view all entries in a table, you can run

mongo_find_example.js
db.getCollection("mytable").find({})

in MongoDB. Also see the official SQL to MongoDB mapping chart.

In order to run that (assuming the default configuration of mongod), you can run

mongo_shell_cmd.sh
mongo [name of database]

in your preferred shell.


Check out similar posts by category: Databases