diff --git a/core/includes/database.inc b/core/includes/database.inc
index 668b2a6409..b7b2ac6ad1 100644
--- a/core/includes/database.inc
+++ b/core/includes/database.inc
@@ -155,6 +155,7 @@ function db_query_temporary($query, array $args = [], array $options = []) {
  * @see \Drupal\Core\Database\Connection::defaultOptions()
  */
 function db_insert($table, array $options = []) {
+  @trigger_error('db_insert() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\Database::getConnection()->insert() instead. See https://www.drupal.org/node/2989742', E_USER_DEPRECATED);
   if (empty($options['target']) || $options['target'] == 'replica') {
     $options['target'] = 'default';
   }
diff --git a/core/lib/Drupal/Core/Database/database.api.php b/core/lib/Drupal/Core/Database/database.api.php
index 96ec858232..610cd4cb6a 100644
--- a/core/lib/Drupal/Core/Database/database.api.php
+++ b/core/lib/Drupal/Core/Database/database.api.php
@@ -126,14 +126,15 @@
  * @section_insert INSERT, UPDATE, and DELETE queries
  * INSERT, UPDATE, and DELETE queries need special care in order to behave
  * consistently across databases; you should never use db_query() to run
- * an INSERT, UPDATE, or DELETE query. Instead, use functions db_insert(),
- * db_update(), and db_delete() to obtain a base query on your table, and then
- * add dynamic conditions (as illustrated in @ref sec_dynamic above).
+ * an INSERT, UPDATE, or DELETE query. Instead, use functions
+ * \Drupal::database()->insert(), db_update(), and db_delete() to obtain a base
+ * query on your table, and then add dynamic conditions (as illustrated in @ref
+ * sec_dynamic above).
  *
- * As a note, db_insert() and similar functions are wrappers on connection
- * object methods. In most classes, you should use dependency injection and the
- * database connection object instead of these wrappers; See @ref sec_connection
- * below for details.
+ * As a note, \Drupal::database()->insert() and similar functions are wrappers
+ * on connection object methods. In most classes, you should use dependency
+ * injection and the database connection object instead of these wrappers; See
+ * @ref sec_connection below for details.
  *
  * For example, if your query is:
  * @code
@@ -142,7 +143,7 @@
  * You can execute it via:
  * @code
  * $fields = array('id' => 1, 'uid' => 2, 'path' => 'path', 'name' => 'Name');
- * db_insert('example')
+ * \Drupal::database()->insert('example')
  *   ->fields($fields)
  *   ->execute();
  * @endcode
@@ -164,7 +165,7 @@
  *   $txn = db_transaction();
  *
  *   try {
- *     $id = db_insert('example')
+ *     $id = \Drupal::database()->insert('example')
  *       ->fields(array(
  *         'field1' => 'mystring',
  *         'field2' => 5,
diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php
index ac137330f8..cccf0f3fa6 100644
--- a/core/lib/Drupal/Core/Entity/entity.api.php
+++ b/core/lib/Drupal/Core/Entity/entity.api.php
@@ -1081,7 +1081,7 @@ function hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) {
  */
 function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
   // Insert the new entity into a fictional table of all entities.
-  db_insert('example_entity')
+  \Drupal::database()->insert('example_entity')
     ->fields([
       'type' => $entity->getEntityTypeId(),
       'id' => $entity->id(),
@@ -1105,7 +1105,7 @@ function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
  */
 function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) {
   // Insert the new entity into a fictional table of this type of entity.
-  db_insert('example_entity')
+  \Drupal::database()->insert('example_entity')
     ->fields([
       'id' => $entity->id(),
       'created' => REQUEST_TIME,
diff --git a/core/modules/contact/tests/drupal-7.contact.database.php b/core/modules/contact/tests/drupal-7.contact.database.php
index e63ee29d16..95d0c090e0 100644
--- a/core/modules/contact/tests/drupal-7.contact.database.php
+++ b/core/modules/contact/tests/drupal-7.contact.database.php
@@ -16,7 +16,7 @@
   ->execute();
 
 // Add a custom contact category.
-db_insert('contact')->fields([
+\Drupal::database()->insert('contact')->fields([
   'category',
   'recipients',
   'reply',
diff --git a/core/modules/file/tests/src/Kernel/UsageTest.php b/core/modules/file/tests/src/Kernel/UsageTest.php
index 014949a945..21271105f0 100644
--- a/core/modules/file/tests/src/Kernel/UsageTest.php
+++ b/core/modules/file/tests/src/Kernel/UsageTest.php
@@ -21,7 +21,7 @@ class UsageTest extends FileManagedUnitTestBase {
    */
   public function testGetUsage() {
     $file = $this->createFile();
-    db_insert('file_usage')
+    \Drupal::database()->insert('file_usage')
       ->fields([
         'fid' => $file->id(),
         'module' => 'testing',
@@ -30,7 +30,7 @@ public function testGetUsage() {
         'count' => 1,
       ])
       ->execute();
-    db_insert('file_usage')
+    \Drupal::database()->insert('file_usage')
       ->fields([
         'fid' => $file->id(),
         'module' => 'testing',
@@ -104,7 +104,7 @@ public function doTestRemoveUsage() {
     $file = $this->createFile();
     $file->setPermanent();
     $file_usage = $this->container->get('file.usage');
-    db_insert('file_usage')
+    \Drupal::database()->insert('file_usage')
       ->fields([
         'fid' => $file->id(),
         'module' => 'testing',
diff --git a/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php b/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php
index 5aebaf43a1..7bffc6da74 100644
--- a/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php
+++ b/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php
@@ -67,14 +67,14 @@ public function testHandlers() {
     $account->save();
     \Drupal::currentUser()->setAccount($account);
 
-    db_insert('history')
+    \Drupal::database()->insert('history')
       ->fields([
         'uid' => $account->id(),
         'nid' => $nodes[0]->id(),
         'timestamp' => REQUEST_TIME - 100,
       ])->execute();
 
-    db_insert('history')
+    \Drupal::database()->insert('history')
       ->fields([
         'uid' => $account->id(),
         'nid' => $nodes[1]->id(),
diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php b/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php
index 1a5debf44a..8c31c2446c 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateBase.php
@@ -280,7 +280,7 @@ protected function setCurrentTranslations() {
     ];
     foreach ($data as $file) {
       $file = array_merge($default, $file);
-      db_insert('locale_file')->fields($file)->execute();
+      \Drupal::database()->insert('locale_file')->fields($file)->execute();
     }
   }
 
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index b0a87d889a..e43cf793ce 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -51,7 +51,7 @@
  *   'grant_update' => 0,
  *   'grant_delete' => 0,
  * );
- * db_insert('node_access')->fields($record)->execute();
+ * \Drupal::database()->insert('node_access')->fields($record)->execute();
  * @endcode
  * And then in its hook_node_grants() implementation, it would need to return:
  * @code
diff --git a/core/modules/node/node.install b/core/modules/node/node.install
index 9b0cda8e56..f57b0fa748 100644
--- a/core/modules/node/node.install
+++ b/core/modules/node/node.install
@@ -134,7 +134,7 @@ function node_install() {
   }
 
   // Populate the node access table.
-  db_insert('node_access')
+  \Drupal::database()->insert('node_access')
     ->fields([
       'nid' => 0,
       'gid' => 0,
diff --git a/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php b/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
index fa2116ab87..5a94f3a672 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
@@ -92,7 +92,7 @@ public function testCacheContext() {
       'grant_update' => 0,
       'grant_delete' => 0,
     ];
-    db_insert('node_access')->fields($record)->execute();
+    \Drupal::database()->insert('node_access')->fields($record)->execute();
 
     // Put user accessUser (uid 0) in the realm.
     \Drupal::state()->set('node_access_test.no_access_uid', 0);
diff --git a/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php b/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php
index 362a27fc48..40571b2976 100644
--- a/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php
+++ b/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php
@@ -151,7 +151,7 @@ public function testNodeQueryAlterOverride() {
       'grant_update' => 0,
       'grant_delete' => 0,
     ];
-    db_insert('node_access')->fields($record)->execute();
+    \Drupal::database()->insert('node_access')->fields($record)->execute();
 
     // Test that the noAccessUser still doesn't have the 'view'
     // privilege after adding the node_access record.
diff --git a/core/modules/path/path.api.php b/core/modules/path/path.api.php
index 6a69f355d9..76204c615a 100644
--- a/core/modules/path/path.api.php
+++ b/core/modules/path/path.api.php
@@ -20,7 +20,7 @@
  * @see \Drupal\Core\Path\AliasStorageInterface::save()
  */
 function hook_path_insert($path) {
-  db_insert('mytable')
+  \Drupal::database()->insert('mytable')
     ->fields([
       'alias' => $path['alias'],
       'pid' => $path['pid'],
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index c7707fd51c..01dcada8eb 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -537,7 +537,7 @@ function search_index($type, $sid, $langcode, $text) {
   search_index_clear($type, $sid, $langcode);
 
   // Insert cleaned up data into dataset
-  db_insert('search_dataset')
+  \Drupal::database()->insert('search_dataset')
     ->fields([
       'sid' => $sid,
       'langcode' => $langcode,
diff --git a/core/modules/search/tests/src/Functional/SearchRankingTest.php b/core/modules/search/tests/src/Functional/SearchRankingTest.php
index 4fafad1956..0db5a980b2 100644
--- a/core/modules/search/tests/src/Functional/SearchRankingTest.php
+++ b/core/modules/search/tests/src/Functional/SearchRankingTest.php
@@ -104,7 +104,7 @@ public function testRankings() {
     // to the Statistics module. So instead go ahead and manually update the
     // counter for this node.
     $nid = $nodes['views'][1]->id();
-    db_insert('node_counter')
+    \Drupal::database()->insert('node_counter')
       ->fields(['totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid])
       ->execute();
 
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 0814d882d7..780491c497 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -138,7 +138,7 @@ function simpletest_run_tests($test_list) {
     unset($test_list['phpunit']);
   }
 
-  $test_id = db_insert('simpletest_test_id')
+  $test_id = Database::getConnection()->insert('simpletest_test_id')
     ->useDefaults(['test_id'])
     ->execute();
 
diff --git a/core/modules/system/tests/modules/module_test/module_test.install b/core/modules/system/tests/modules/module_test/module_test.install
index b76b7936f5..30dda21a1f 100644
--- a/core/modules/system/tests/modules/module_test/module_test.install
+++ b/core/modules/system/tests/modules/module_test/module_test.install
@@ -29,7 +29,7 @@ function module_test_schema() {
  */
 function module_test_install() {
   $schema = drupal_get_module_schema('module_test', 'module_test');
-  db_insert('module_test')
+  \Drupal::database()->insert('module_test')
     ->fields([
       'data' => $schema['fields']['data']['type'],
     ])
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index dadefecabc..e46bc2f074 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -69,7 +69,7 @@ function tracker_cron() {
         ->execute();
 
       // Insert the node-level data.
-      db_insert('tracker_node')
+      \Drupal::database()->insert('tracker_node')
         ->fields([
           'nid' => $nid,
           'published' => (int) $node->isPublished(),
@@ -78,7 +78,7 @@ function tracker_cron() {
         ->execute();
 
       // Insert the user-level data for the node's author.
-      db_insert('tracker_user')
+      \Drupal::database()->insert('tracker_user')
         ->fields([
           'nid' => $nid,
           'published' => (int) $node->isPublished(),
@@ -101,7 +101,7 @@ function tracker_cron() {
         ->groupBy('uid')
         ->execute();
       if ($result) {
-        $query = db_insert('tracker_user');
+        $query = \Drupal::database()->insert('tracker_user');
         foreach ($result as $row) {
           $query->fields([
             'uid' => $row['uid'],
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 823c08da67..8dcf2cc80c 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -155,7 +155,7 @@ function hook_user_login($account) {
  *   The user object on which the operation was just performed.
  */
 function hook_user_logout($account) {
-  db_insert('logouts')
+  \Drupal::database()->insert('logouts')
     ->fields([
       'uid' => $account->id(),
       'time' => time(),
diff --git a/core/modules/views/src/Tests/ViewKernelTestBase.php b/core/modules/views/src/Tests/ViewKernelTestBase.php
index 5a23285918..e683992b24 100644
--- a/core/modules/views/src/Tests/ViewKernelTestBase.php
+++ b/core/modules/views/src/Tests/ViewKernelTestBase.php
@@ -71,7 +71,7 @@ protected function setUpFixtures() {
 
     // Load the test dataset.
     $data_set = $this->dataSet();
-    $query = db_insert('views_test_data')
+    $query = \Drupal::database()->insert('views_test_data')
       ->fields(array_keys($data_set[0]));
     foreach ($data_set as $record) {
       $query->values($record);
diff --git a/core/modules/views/src/Tests/ViewTestBase.php b/core/modules/views/src/Tests/ViewTestBase.php
index e1e5190f59..56e966599b 100644
--- a/core/modules/views/src/Tests/ViewTestBase.php
+++ b/core/modules/views/src/Tests/ViewTestBase.php
@@ -57,7 +57,7 @@ protected function enableViewsTestModule() {
 
     // Load the test dataset.
     $data_set = $this->dataSet();
-    $query = db_insert('views_test_data')
+    $query = \Drupal::database()->insert('views_test_data')
       ->fields(array_keys($data_set[0]));
     foreach ($data_set as $record) {
       $query->values($record);
diff --git a/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php b/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php
index 5f1e642aa1..3c94107dbe 100644
--- a/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php
@@ -115,7 +115,7 @@ public function testNumericFieldVisible() {
     // Adds a new datapoint in the views_test_data table to have a person with
     // an age of zero.
     $data_set = $this->dataSet();
-    $query = db_insert('views_test_data')
+    $query = \Drupal::database()->insert('views_test_data')
       ->fields(array_keys($data_set[0]));
     $query->values([
       'name' => 'James McCartney',
diff --git a/core/modules/views/tests/src/Functional/ViewTestBase.php b/core/modules/views/tests/src/Functional/ViewTestBase.php
index 10bc5d48bc..a0ae5f7eff 100644
--- a/core/modules/views/tests/src/Functional/ViewTestBase.php
+++ b/core/modules/views/tests/src/Functional/ViewTestBase.php
@@ -55,7 +55,7 @@ protected function enableViewsTestModule() {
 
     // Load the test dataset.
     $data_set = $this->dataSet();
-    $query = db_insert('views_test_data')
+    $query = \Drupal::database()->insert('views_test_data')
       ->fields(array_keys($data_set[0]));
     foreach ($data_set as $record) {
       $query->values($record);
diff --git a/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php b/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php
index caa479b4a1..1c5795add9 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php
@@ -88,7 +88,7 @@ public function testTimeResultCaching() {
       'age' => 29,
       'job' => 'Banjo',
     ];
-    db_insert('views_test_data')->fields($record)->execute();
+    \Drupal::database()->insert('views_test_data')->fields($record)->execute();
 
     // The result should be the same as before, because of the caching. (Note
     // that views_test_data records don't have associated cache tags, and hence
@@ -242,7 +242,7 @@ public function testNoneResultCaching() {
       'age' => 29,
       'job' => 'Banjo',
     ];
-    db_insert('views_test_data')->fields($record)->execute();
+    \Drupal::database()->insert('views_test_data')->fields($record)->execute();
 
     // The Result changes, because the view is not cached.
     $view = Views::getView('test_cache');
diff --git a/core/scripts/dump-database-d6.sh b/core/scripts/dump-database-d6.sh
index d0a89d7b1c..4679a1988b 100644
--- a/core/scripts/dump-database-d6.sh
+++ b/core/scripts/dump-database-d6.sh
@@ -90,7 +90,7 @@
 
   // Dump the values if there are some.
   if ($insert) {
-    $output .= "db_insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n";
+    $output .= "\Drupal::database()->insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n";
     $output .= $insert;
     $output .= "->execute();\n";
   }
diff --git a/core/scripts/dump-database-d7.sh b/core/scripts/dump-database-d7.sh
index 4689672cb3..033b58135b 100644
--- a/core/scripts/dump-database-d7.sh
+++ b/core/scripts/dump-database-d7.sh
@@ -80,7 +80,7 @@
 
   // Dump the values if there are some.
   if ($insert) {
-    $output .= "db_insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n";
+    $output .= "\Drupal::database()->insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n";
     $output .= $insert;
     $output .= "->execute();\n";
   }
diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh
index 8b591f42b0..4836b7c504 100644
--- a/core/scripts/generate-d7-content.sh
+++ b/core/scripts/generate-d7-content.sh
@@ -45,7 +45,7 @@
 drupal_cron_run();
 
 // Create six users
-$query = db_insert('users')->fields(array('uid', 'name', 'pass', 'mail', 'status', 'created', 'access'));
+$query = \Drupal::database()->insert('users')->fields(array('uid', 'name', 'pass', 'mail', 'status', 'created', 'access'));
 for ($i = 0; $i < 6; $i++) {
   $name = "test user $i";
   $pass = md5("test PassW0rd $i !(.)");
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
index 0aecc72b8f..01581fcc92 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
@@ -30,7 +30,7 @@ protected function read($name) {
   }
 
   protected function insert($name, $data) {
-    db_insert('config')->fields(['name' => $name, 'data' => $data])->execute();
+    \Drupal::database()->insert('config')->fields(['name' => $name, 'data' => $data])->execute();
   }
 
   protected function update($name, $data) {
diff --git a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
index 837b8ea036..ec12d05945 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
@@ -76,7 +76,7 @@ public function testConcatWsFields() {
    * Tests escaping of LIKE wildcards.
    */
   public function testLikeEscape() {
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields([
         'name' => 'Ring_',
       ])
@@ -102,7 +102,7 @@ public function testLikeEscape() {
    * Tests a LIKE query containing a backslash.
    */
   public function testLikeBackslash() {
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields(['name'])
       ->values([
         'name' => 'abcde\f',
diff --git a/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php b/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
index 37b876c8f8..1a2e90073a 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
@@ -15,7 +15,7 @@ class CaseSensitivityTest extends DatabaseTestBase {
   public function testCaseSensitiveInsert() {
     $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
 
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields([
         // A record already exists with name 'John'.
         'name' => 'john',
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
index b5963cf420..13ef94e4cb 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
@@ -15,7 +15,7 @@ class InsertDefaultsTest extends DatabaseTestBase {
    * Tests that we can run a query that uses default values for everything.
    */
   public function testDefaultInsert() {
-    $query = db_insert('test')->useDefaults(['job']);
+    $query = $this->connection->insert('test')->useDefaults(['job']);
     $id = $query->execute();
 
     $schema = drupal_get_module_schema('database_test', 'test');
@@ -31,7 +31,7 @@ public function testDefaultEmptyInsert() {
     $num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
 
     try {
-      db_insert('test')->execute();
+      $this->connection->insert('test')->execute();
       // This is only executed if no exception has been thrown.
       $this->fail('Expected exception NoFieldsException has not been thrown.');
     }
@@ -47,7 +47,7 @@ public function testDefaultEmptyInsert() {
    * Tests that we can insert fields with values and defaults in the same query.
    */
   public function testDefaultInsertWithFields() {
-    $query = db_insert('test')
+    $query = $this->connection->insert('test')
       ->fields(['name' => 'Bob'])
       ->useDefaults(['job']);
     $id = $query->execute();
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php
index e7a3107a87..10984385e2 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php
@@ -15,7 +15,7 @@ class InsertLobTest extends DatabaseTestBase {
   public function testInsertOneBlob() {
     $data = "This is\000a test.";
     $this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
-    $id = db_insert('test_one_blob')
+    $id = $this->connection->insert('test_one_blob')
       ->fields(['blob1' => $data])
       ->execute();
     $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', [':id' => $id])->fetchAssoc();
@@ -26,7 +26,7 @@ public function testInsertOneBlob() {
    * Tests that we can insert multiple blob fields in the same query.
    */
   public function testInsertMultipleBlob() {
-    $id = db_insert('test_two_blobs')
+    $id = $this->connection->insert('test_two_blobs')
       ->fields([
         'blob1' => 'This is',
         'blob2' => 'a test',
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
index d6b0f8dd80..cbc5c9d936 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
@@ -15,7 +15,7 @@ class InsertTest extends DatabaseTestBase {
   public function testSimpleInsert() {
     $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
 
-    $query = db_insert('test');
+    $query = $this->connection->insert('test');
     $query->fields([
       'name' => 'Yoko',
       'age' => '29',
@@ -37,7 +37,7 @@ public function testSimpleInsert() {
   public function testMultiInsert() {
     $num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
 
-    $query = db_insert('test');
+    $query = $this->connection->insert('test');
     $query->fields([
       'name' => 'Larry',
       'age' => '30',
@@ -76,7 +76,7 @@ public function testMultiInsert() {
   public function testRepeatedInsert() {
     $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
 
-    $query = db_insert('test');
+    $query = $this->connection->insert('test');
 
     $query->fields([
       'name' => 'Larry',
@@ -119,7 +119,7 @@ public function testRepeatedInsert() {
   public function testInsertFieldOnlyDefinition() {
     // This is useful for importers, when we want to create a query and define
     // its fields once, then loop over a multi-insert execution.
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields(['name', 'age'])
       ->values(['Larry', '30'])
       ->values(['Curly', '31'])
@@ -137,7 +137,7 @@ public function testInsertFieldOnlyDefinition() {
    * Tests that inserts return the proper auto-increment ID.
    */
   public function testInsertLastInsertID() {
-    $id = db_insert('test')
+    $id = $this->connection->insert('test')
       ->fields([
         'name' => 'Larry',
         'age' => '30',
@@ -165,7 +165,7 @@ public function testInsertSelectFields() {
     // SELECT tp.age AS age, tp.name AS name, tp.job AS job
     // FROM test_people tp
     // WHERE tp.name = 'Meredith'
-    db_insert('test')
+    $this->connection->insert('test')
       ->from($query)
       ->execute();
 
@@ -186,7 +186,7 @@ public function testInsertSelectAll() {
     // SELECT *
     // FROM test_people tp
     // WHERE tp.name = 'Meredith'
-    db_insert('test_people_copy')
+    $this->connection->insert('test_people_copy')
       ->from($query)
       ->execute();
 
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php b/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php
index f6af91fef8..f0885143c8 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php
@@ -18,7 +18,7 @@ class InvalidDataTest extends DatabaseTestBase {
   public function testInsertDuplicateData() {
     // Try to insert multiple records where at least one has bad data.
     try {
-      db_insert('test')
+      $this->connection->insert('test')
         ->fields(['name', 'age', 'job'])
         ->values([
           'name' => 'Elvis',
@@ -75,7 +75,7 @@ public function testInsertDuplicateDataFromSelect() {
     // Insert multiple records in 'test_people' where one has bad data
     // (duplicate key). A 'Meredith' record has already been inserted
     // in ::setUp.
-    db_insert('test_people')
+    $this->connection->insert('test_people')
       ->fields(['name', 'age', 'job'])
       ->values([
         'name' => 'Elvis',
@@ -109,7 +109,7 @@ public function testInsertDuplicateDataFromSelect() {
         ->orderBy('name');
 
       // Try inserting from the subselect.
-      db_insert('test')
+      $this->connection->insert('test')
         ->from($query)
         ->execute();
 
diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
index 76ed2e2987..bfe60b6c0f 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
@@ -100,7 +100,7 @@ public function testConditionOperatorArgumentsSQLInjection() {
     // Attempt SQLi via union query with no unsafe characters.
     $this->enableModules(['user']);
     $this->installEntitySchema('user');
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields(['name' => '123456'])
       ->execute();
     $injection = "= 1 UNION ALL SELECT password FROM user WHERE uid =";
@@ -117,7 +117,7 @@ public function testConditionOperatorArgumentsSQLInjection() {
     }
 
     // Attempt SQLi via union query - uppercase tablename.
-    db_insert('TEST_UPPERCASE')
+    $this->connection->insert('TEST_UPPERCASE')
       ->fields(['name' => 'secrets'])
       ->execute();
     $injection = "IS NOT NULL) UNION ALL SELECT name FROM {TEST_UPPERCASE} -- ";
diff --git a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php
index e4cc8681cf..bb933c62c7 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php
@@ -2,8 +2,6 @@
 
 namespace Drupal\KernelTests\Core\Database;
 
-use Drupal\Core\Database\Database;
-
 /**
  * Regression tests cases for the database layer.
  *
@@ -24,7 +22,8 @@ class RegressionTest extends DatabaseTestBase {
   public function testRegression_310447() {
     // That's a 255 character UTF-8 string.
     $job = str_repeat("é", 255);
-    db_insert('test')
+    $this->connection
+      ->insert('test')
       ->fields([
         'name' => $this->randomMachineName(),
         'age' => 20,
@@ -67,7 +66,7 @@ public function testDBIndexExists() {
    * @expectedDeprecation db_set_active() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\Database::setActiveConnection() instead. See https://www.drupal.org/node/2944084.
    */
   public function testDBIsActive() {
-    $get_active_db = Database::getConnection()->getKey();
+    $get_active_db = $this->connection->getKey();
     $this->assert(db_set_active($get_active_db), 'Database connection is active');
   }
 
@@ -82,4 +81,27 @@ public function testDbDropTable() {
     $this->assertFalse(db_drop_table('temp_test_table'));
   }
 
+  /**
+   * Tests the db_insert() function.
+   *
+   * @group legacy
+   *
+   * @expectedDeprecation db_insert() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\Database::getConnection()->insert() instead. See https://www.drupal.org/node/2989742
+   */
+  public function testDbInsert() {
+    $job = str_repeat("é", 255);
+    db_insert('test')
+      ->fields([
+        'name' => $this->randomMachineName(),
+        'age' => 20,
+        'job' => $job,
+      ])->execute();
+
+    $from_database = $this->connection->select('test');
+    $from_database->fields('job');
+    $from_database->condition('job', $job);
+    $from_database = $from_database->execute()->fetchField();
+    $this->assertSame($job, $from_database, 'The database handles UTF-8 characters cleanly.');
+  }
+
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php
index 58a66289e2..c035d35ea3 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php
@@ -209,7 +209,7 @@ public function testJoinSubquerySelect() {
    */
   public function testExistsSubquerySelect() {
     // Put George into {test_people}.
-    db_insert('test_people')
+    $this->connection->insert('test_people')
       ->fields([
         'name' => 'George',
         'age' => 27,
@@ -239,7 +239,7 @@ public function testExistsSubquerySelect() {
    */
   public function testNotExistsSubquerySelect() {
     // Put George into {test_people}.
-    db_insert('test_people')
+    $this->connection->insert('test_people')
       ->fields([
         'name' => 'George',
         'age' => 27,
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
index 8751a18fe3..a0ac960e79 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
@@ -402,7 +402,7 @@ public function testRandomOrder() {
     // after shuffling it (in other words, nearly impossible).
     $number_of_items = 52;
     while (db_query("SELECT MAX(id) FROM {test}")->fetchField() < $number_of_items) {
-      db_insert('test')->fields(['name' => $this->randomMachineName()])->execute();
+      $this->connection->insert('test')->fields(['name' => $this->randomMachineName()])->execute();
     }
 
     // First select the items in order and make sure we get an ordered list.
diff --git a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
index a07045dd53..7ef25bfc98 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
@@ -57,7 +57,7 @@ protected function transactionOuterLayer($suffix, $rollback = FALSE, $ddl_statem
     $txn = db_transaction();
 
     // Insert a single row into the testing table.
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields([
         'name' => 'David' . $suffix,
         'age' => '24',
@@ -107,7 +107,7 @@ protected function transactionInnerLayer($suffix, $rollback = FALSE, $ddl_statem
     $this->assertTrue($depth < $depth2, 'Transaction depth is has increased with new transaction.');
 
     // Insert a single row into the testing table.
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields([
         'name' => 'Daniel' . $suffix,
         'age' => '19',
@@ -310,7 +310,7 @@ public function testTransactionWithDdlStatement() {
    * Inserts a single row into the testing table.
    */
   protected function insertRow($name) {
-    db_insert('test')
+    $this->connection->insert('test')
       ->fields([
         'name' => $name,
       ])
diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php
index 501f918314..c9f142ed87 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php
@@ -15,7 +15,7 @@ class UpdateLobTest extends DatabaseTestBase {
   public function testUpdateOneBlob() {
     $data = "This is\000a test.";
     $this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
-    $id = db_insert('test_one_blob')
+    $id = $this->connection->insert('test_one_blob')
       ->fields(['blob1' => $data])
       ->execute();
 
@@ -33,7 +33,7 @@ public function testUpdateOneBlob() {
    * Confirms that we can update two blob columns in the same table.
    */
   public function testUpdateMultipleBlob() {
-    $id = db_insert('test_two_blobs')
+    $id = $this->connection->insert('test_two_blobs')
       ->fields([
         'blob1' => 'This is',
         'blob2' => 'a test',
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
index 054eb2d8fe..d8fc6335d4 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
@@ -123,7 +123,7 @@ public function testFieldLoad() {
 
     // Generate values and insert them directly in the storage tables.
     $values = [];
-    $query = db_insert($this->revisionTable)->fields($columns);
+    $query = Database::getConnection()->insert($this->revisionTable)->fields($columns);
     foreach ($revision_ids as $revision_id) {
       // Put one value too many.
       for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) {
@@ -133,7 +133,7 @@ public function testFieldLoad() {
       }
       $query->execute();
     }
-    $query = db_insert($this->table)->fields($columns);
+    $query = Database::getConnection()->insert($this->table)->fields($columns);
     foreach ($values[$revision_id] as $delta => $value) {
       $query->values([$bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value]);
     }
@@ -167,8 +167,8 @@ public function testFieldLoad() {
     // loaded.
     $unavailable_langcode = 'xx';
     $values = [$bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127)];
-    db_insert($this->table)->fields($columns)->values($values)->execute();
-    db_insert($this->revisionTable)->fields($columns)->values($values)->execute();
+    Database::getConnection()->insert($this->table)->fields($columns)->values($values)->execute();
+    Database::getConnection()->insert($this->revisionTable)->fields($columns)->values($values)->execute();
     $entity = $storage->load($entity->id());
     $this->assertFalse(array_key_exists($unavailable_langcode, $entity->{$this->fieldName}));
   }
