drush sql-query

Execute a query against a database.

Drush Command

drush sql-query

Arguments

query : An SQL query. Ignored if 'file' is provided.

Aliases

drush sqlq

Options

--result-file : [object Object]
--file : Path to a file containing the SQL to be run. Gzip files are accepted.
--extra : [object Object]
--db-prefix : Enable replacement of braces in your query.
--db-spec : [object Object]
--database : [object Object]
--target : [object Object]
--db-url : [object Object]

Examples

Browse user record. Table prefixes, if used, must be added to table names by hand.

drush sql-query "SELECT * FROM users WHERE uid=1"
Browse user record. Table prefixes are honored. Caution: curly-braces will be stripped from all portions of the query.
drush sql-query --db-prefix "SELECT * FROM {users} WHERE uid=1"
Import sql statements from a file into the current database.
</span>drush sql-connect<span class="sb"> < example.sql
Alternate way to import sql statements from a file.
drush sql-query --file=example.sql