diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
index e033bd5..65dbce7 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
@@ -389,7 +389,7 @@ public function fieldSetDefault($table, $field, $default) {
       $default = 'NULL';
     }
     else {
-      $default = is_string($default) ? "'$default'" : $default;
+      $default = is_string($default) ? $this->connection->quote($default) : $default;
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $default);
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index 63349ad..d621c9c 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -207,7 +207,7 @@ protected function createFieldSql($name, $spec) {
       }
     }
     if (isset($spec['default'])) {
-      $default = is_string($spec['default']) ? $this->connection->quote($spec['default']) : $spec['default'];
+      $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);
   }
@@ -631,6 +626,13 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array
     }
   }
 
+  protected function _escapeDefaultValue($value) {
+    if (is_null($value)) {
+      return 'NULL';
+    }
+    return is_string($value) ? $this->connection->quote($value) : $value;
+  }
+
   protected function _createIndexSql($table, $name, $fields) {
     $query = 'CREATE INDEX "' . $this->prefixNonTable($table, $name, 'idx') . '" ON {' . $table . '} (';
     $query .= $this->_createKeySql($fields) . ')';
diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php
index 27826ad..0692543 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php
+++ b/core/modules/system/lib/Drupal/system/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'),
       );
 
