database

Database query examples

Update the 'pair' field using an expression to concatenate the fields.

$database = \Drupal::service('database');
$database->update('mono_currency_rates')
  ->expression('pair', "CONCAT(currency_code_sell, '/', currency_code_buy)")
  ->isNull('pair')
  ->execute();

Sort:

Database manipulations

Restore database:

drush sql:drop -y && pv ~/www/SITE_NAME/web/sites/default/files/backups/last.mysql | drush sql-cli --extra=-A

Restore zipped database:

drush sql:drop -y && unzip -p ~/www/_db_backups/SITE_NAME/last.mysql.zip | pv | drush sql-cli --extra=-A


Backup database:

drush sql:dump --structure-tables-list="cache,cache_*" > new.sql 
Subscribe to database