data query
Execute a SOQL query.
Specify the SOQL query at the command line with the –query flag or read the query from a file with the –file flag.
If your query returns more than 10,000 records, prefer to use the sf data export bulk command instead. It runs the query using Bulk API 2.0, which has higher limits than the default API used by the command.
force:data:soql:query
| Flag Name (Long) | Flag Name (Short) | Description |
|---|---|---|
‑‑all‑rows | N/A | Type: Boolean Include deleted records. By default, deleted records are not returned. |
‑‑api‑version | N/A | Type: Value Override the api version used for api requests made by this command |
‑‑file | ‑f | Type: Value File that contains the SOQL query. |
‑‑flags‑dir | N/A | Type: Value Import flag values from a directory. |
‑‑json | N/A | Type: Boolean Format output as json. |
‑‑output‑file | N/A | Type: Value File where records are written; only CSV and JSON output formats are supported. |
‑‑query | ‑q | Type: Value SOQL query to execute. |
‑‑result‑format | ‑r | Type: Value Valid Values: human, csv, jsonDefault value: humanFormat to display the results; the –json flag overrides this flag. |
‑‑target‑org | ‑o | Type: Value Required Username or alias of the target org. Not required if the target-org configuration variable is already set. |
‑‑use‑tooling‑api | ‑t | Type: Boolean Use Tooling API so you can run queries on Tooling API objects. |
Specify a SOQL query at the command line; the command uses your default org:
Read the SOQL query from a file called “query.txt” and write the CSV-formatted output to a file; the command uses the org with alias “my-scratch”:
Use Tooling API to run a query on the ApexTrigger Tooling API object: