function Truncate::__toString
Same name in this branch
- main core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php \Drupal\sqlite\Driver\Database\sqlite\Truncate::__toString()
- main core/lib/Drupal/Core/Database/Query/Truncate.php \Drupal\Core\Database\Query\Truncate::__toString()
Same name and namespace in other branches
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php \Drupal\sqlite\Driver\Database\sqlite\Truncate::__toString()
- 11.x core/lib/Drupal/Core/Database/Query/Truncate.php \Drupal\Core\Database\Query\Truncate::__toString()
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php \Drupal\sqlite\Driver\Database\sqlite\Truncate::__toString()
- 10 core/lib/Drupal/Core/Database/Query/Truncate.php \Drupal\Core\Database\Query\Truncate::__toString()
- 9 core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php \Drupal\sqlite\Driver\Database\sqlite\Truncate::__toString()
- 9 core/lib/Drupal/Core/Database/Query/Truncate.php \Drupal\Core\Database\Query\Truncate::__toString()
- 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Truncate.php \Drupal\Core\Database\Driver\sqlite\Truncate::__toString()
- 8.9.x core/lib/Drupal/Core/Database/Query/Truncate.php \Drupal\Core\Database\Query\Truncate::__toString()
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/Truncate.php \Drupal\pgsql\Driver\Database\pgsql\Truncate::__toString()
On PostgreSQL, TRUNCATE is fully transactional: it can be rolled back and does not cause an implicit commit, so there is no need to fall back to the slower DELETE query when inside a transaction. TRUNCATE is much faster on large tables and, unlike DELETE, does not leave dead rows behind for VACUUM to clean up.
Note that TRUNCATE takes an ACCESS EXCLUSIVE lock on the table that is held until the transaction ends, and it is not MVCC-safe with respect to concurrent transactions using a snapshot taken before the truncation.
Return value
string The prepared statement.
Overrides Truncate::__toString
See also
https://www.postgresql.org/docs/current/sql-truncate.html
File
-
core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Truncate.php, line 50
Class
- Truncate
- PostgreSQL implementation of \Drupal\Core\Database\Query\Truncate.
Namespace
Drupal\pgsql\Driver\Database\pgsqlCode
public function __toString() {
// Create a sanitized comment string to prepend to the query.
$comments = $this->connection
->makeComment($this->comments);
return $comments . 'TRUNCATE {' . $this->connection
->escapeTable($this->table) . '} ';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.