duckdb mydb.duckdb -c "SELECT count(*) FROM users;"

Category: Databases & SQL

duckdb mydb.duckdb -c "SELECT count(*) FROM users;"

Run a query and exit

-c executes the statement and exits, which fits scripts; -s does the same, and -f runs a file of SQL. Related: positional SQL argument.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.