diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
index e033bd5..d27f61a 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
@@ -137,11 +137,11 @@ protected function createTableSql($name, $table) {
   protected function createFieldSql($name, $spec) {
     $sql = "`" . $name . "` " . $spec['mysql_type'];
 
-    if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT'))) {
+    if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT', 'VARBINARY', 'BINARY'))) {
       if (isset($spec['length'])) {
         $sql .= '(' . $spec['length'] . ')';
       }
-      if (!empty($spec['binary'])) {
+      if (!empty($spec['binary']) && !in_array($spec['mysql_type'], array('VARBINARY', 'BINARY'))) {
         $sql .= ' BINARY';
       }
     }
@@ -227,6 +227,9 @@ public function getFieldTypeMap() {
       'varchar:normal'  => 'VARCHAR',
       'char:normal'     => 'CHAR',
 
+      'varbinary:normal'  => 'VARBINARY',
+      'binary:normal'     => 'BINARY',
+
       'text:tiny'       => 'TINYTEXT',
       'text:small'      => 'TINYTEXT',
       'text:medium'     => 'MEDIUMTEXT',
@@ -389,7 +392,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..c27763a 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";
     }
 
@@ -273,6 +273,9 @@ function getFieldTypeMap() {
       'varchar:normal' => 'varchar',
       'char:normal' => 'character',
 
+      'varbinary:normal' => 'bytea',
+      'binary:normal' => 'bytea',
+
       'text:tiny' => 'text',
       'text:small' => 'text',
       'text:medium' => 'text',
@@ -432,12 +435,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 +629,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/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
index dc09d86..2699ba5 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
@@ -204,6 +204,9 @@ public function getFieldTypeMap() {
       'varchar:normal'  => 'VARCHAR',
       'char:normal'     => 'CHAR',
 
+      'varbinary:normal'  => 'BLOB',
+      'binary:normal'     => 'BLOB',
+
       'text:tiny'       => 'TEXT',
       'text:small'      => 'TEXT',
       'text:medium'     => 'TEXT',
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..47b8220 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php
@@ -348,6 +348,46 @@ function testSchemaAddField() {
         }
       }
     }
+
+    // Test binary types
+    foreach (array('binary', 'varbinary') as $bintype) {
+      $base_field_spec = array(
+         'type' => $bintype,
+      );
+      $variations = array();
+      foreach (array(NULL, 2, 50) as $length) {
+        if ($bintype == 'varbinary' && empty($length)) {
+          $length = 1;
+        }
+        foreach (array(TRUE, FALSE) as $binary) {
+          $variation = array(
+             'length' => $length,
+             'binary' => $binary,
+          );
+          $field_spec = $variation + $base_field_spec;
+          $this->assertFieldAdditionRemoval($field_spec);
+        }
+      }
+    }
+
+    $field_spec['default'] = hex2bin('002701FF7F808100020304B4');
+    $table_name = 'test_table_' . ($this->counter++);
+    $table_spec = array(
+      'fields' => array(
+        'id' => $field_spec,
+      ),
+    );
+    db_create_table($table_name, $table_spec);
+    $this->pass("Table $table_name created.");
+    $this->assertTrue($this->tryInsert($table_name), 'Insert with binary default succeeded.');
+
+    db_field_set_default($table_name, 'id', '');
+    $this->pass("Table $table_name set default on id to empty string.");
+    db_field_set_no_default($table_name, 'id');
+    $this->pass("Table $table_name remove default on id.");
+
+    // Clean-up.
+    db_drop_table($table_name);
   }
 
   /**
