Important
New database features are no longer connected to engine versions; features are now enabled independently during scheduled update windows, and “major” and “minor” releases no longer exist in Helios. Please visit the release notes to view the latest features available in your database clusters.
sql
On this page
Runs the specified SQL statement and returns the result as a cursor.
Syntax
db.runCommand({sql: <string>})
Example
The following example runs an OPTIMIZE TABLE command, where dbTest and mycollection are the names of the database and collection, respectively.
db.runCommand({ sql: "OPTIMIZE TABLE `dbTest`.`mycollection` FULL" });
Here's another example that runs a SELECT statement:
db.runCommand({ sql: "SELECT * FROM `dbTest`.`mycollection`" });
Last modified: