diff --git a/data_ui/data_ui.admin.inc b/data_ui/data_ui.admin.inc
index 9e784d4..fd01295 100644
--- a/data_ui/data_ui.admin.inc
+++ b/data_ui/data_ui.admin.inc
@@ -649,6 +649,9 @@ function data_ui_edit_form_submit($form, &$form_state) {
         // Change the primary key only if requested.
         if ($schema['primary key'] != $new_primary_key) {
           $table->changePrimaryKey($new_primary_key);
+          if ( $schema['description'] == 'VIEW' ) {
+            drupal_set_message(t('This is a database view, and so only the pseudo-primary-key has been modified.'));
+          }
         }
 
         // Update meta data.
diff --git a/includes/DataTable.inc b/includes/DataTable.inc
index e131b64..67057ec 100644
--- a/includes/DataTable.inc
+++ b/includes/DataTable.inc
@@ -410,11 +410,13 @@ class DataTable {
       }
     }
 
-    try {
-      db_add_primary_key($this->name, $fields);
-    }
-    catch (DatabaseSchemaObjectExistsException $e) {
-      throw new DataException(t('Error creating primary key.'));
+    if ($schema['description'] != 'VIEW') {
+      try {
+        db_add_primary_key($this->name, $fields);
+      }
+      catch (DatabaseSchemaObjectExistsException $e) {
+        throw new DataException(t('Error creating primary key.'));
+      }
     }
 
     $schema['primary key'] = $fields;
@@ -428,9 +430,11 @@ class DataTable {
    * @throws DataException
    */
   public function dropPrimaryKey() {
-    db_drop_primary_key($this->name);
-
     $schema = $this->table_schema;
+    if ($schema['description'] != 'VIEW') {
+      db_drop_primary_key($this->name);
+    }
+
     $schema['primary key'] = array();
     $this->update(array('table_schema' => $schema));
     drupal_get_schema($this->name, TRUE);
