diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
index e033bd5..8c24cb8 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
@@ -168,13 +168,7 @@ protected function createFieldSql($name, $spec) {
 
     // $spec['default'] can be NULL, so we explicitly check for the key here.
     if (array_key_exists('default', $spec)) {
-      if (is_string($spec['default'])) {
-        $spec['default'] = $this->connection->quote($spec['default']);
-      }
-      elseif (!isset($spec['default'])) {
-        $spec['default'] = 'NULL';
-      }
-      $sql .= ' DEFAULT ' . $spec['default'];
+      $sql .= ' DEFAULT ' . $this->escapeDefaultValue($spec['default']);
     }
 
     if (empty($spec['not null']) && !isset($spec['default'])) {
@@ -385,14 +379,7 @@ public function fieldSetDefault($table, $field, $default) {
       throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
     }
 
-    if (!isset($default)) {
-      $default = 'NULL';
-    }
-    else {
-      $default = is_string($default) ? "'$default'" : $default;
-    }
-
-    $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $default);
+    $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $this->escapeDefaultValue($default));
   }
 
   public function fieldSetNoDefault($table, $field) {
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index 63349ad..e219f24 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -206,8 +206,8 @@ protected function createFieldSql($name, $spec) {
         $sql .= ' NULL';
       }
     }
-    if (isset($spec['default'])) {
-      $default = is_string($spec['default']) ? $this->connection->quote($spec['default']) : $spec['default'];
+    if (array_key_exists('default', $spec)) {
+      $default = $this->escapeDefaultValue($spec['default']);
       $sql .= " default $default";
     }
 
@@ -432,12 +432,7 @@ public function fieldSetDefault($table, $field, $default) {
       throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
     }
 
-    if (!isset($default)) {
-      $default = 'NULL';
-    }
-    else {
-      $default = is_string($default) ? $this->connection->quote($default) : $default;
-    }
+    $default = $this->escapeDefaultValue($default);
 
     $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" SET DEFAULT ' . $default);
   }
diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php
index bf7107a..4f8aab1 100644
--- a/core/lib/Drupal/Core/Database/Schema.php
+++ b/core/lib/Drupal/Core/Database/Schema.php
@@ -722,4 +722,21 @@ public function fieldNames($fields) {
   public function prepareComment($comment, $length = NULL) {
     return $this->connection->quote($comment);
   }
+
+  /**
+   * Return an escaped version of its parameter to be used as a default value
+   * on a column.
+   *
+   * @param mixed $value
+   *   The value to be escaped (int, float, null or string).
+   *
+   * @return string|int|float
+   *   The escaped value.
+   */
+  protected function escapeDefaultValue($value) {
+    if (is_null($value)) {
+      return 'NULL';
+    }
+    return is_string($value) ? $this->connection->quote($value) : $value;
+  }
 }
diff --git a/core/modules/system/src/Tests/Database/SchemaTest.php b/core/modules/system/src/Tests/Database/SchemaTest.php
index 27826ad..0692543 100644
--- a/core/modules/system/src/Tests/Database/SchemaTest.php
+++ b/core/modules/system/src/Tests/Database/SchemaTest.php
@@ -292,6 +292,7 @@ function testSchemaAddField() {
         array('not null' => FALSE, 'default' => substr('"thing"', 0, $length)),
         array('not null' => FALSE, 'default' => substr("\"'hing", 0, $length)),
         array('not null' => TRUE, 'initial' => 'd'),
+        array('not null' => FALSE, 'default' => NULL),
         array('not null' => TRUE, 'initial' => 'd', 'default' => '7'),
       );
 
