drush sql:queryfor drush 9x

Execute a query against a database.

drush sql:query

  • Aliases

    sql:query has 2 alias/es:

    drush sqlq

    drush sql-query

  • Arguments

    sql:query accepts 1 argument/s:

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

  • Options

    sql:query accepts 10 option/s:


    --result-file : result-file


    --file : file


    --extra : extra


    --db-prefix : db-prefix


    --database : database


    --target : target


    --db-url : db-url


    --notify : notify


    --druplicon : druplicon


    --xh-link : xh-link

  • 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: All curly-braces will be stripped.

    drush sql:query --db-prefix "SELECT * FROM {users}"

    Import sql statements from a file into the current database.

    `drush sql-connect` < example.sql

    Alternate way to import sql statements from a file.

    drush sql:query --file=example.sql

  • Comments

    comments powered by Disqus