diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc
index 0326bd5088ff35bc76490d244bababf560600afa..731107be851b4054ad076f2553832e60b4c7f6f6 100644
--- a/includes/database.mysql.inc
+++ b/includes/database.mysql.inc
@@ -364,6 +364,13 @@ function db_unlock_tables() {
   db_query('UNLOCK TABLES');
 }
 
+/**
+ * Check if a table exists.
+ */
+function db_table_exists($table) {
+  return db_num_rows(db_query("SHOW TABLES LIKE '{" . db_escape_table($table) . "}'"));
+}
+
 /**
  * @} End of "ingroup database".
  */
diff --git a/includes/database.mysqli.inc b/includes/database.mysqli.inc
index a843833570dadbf9363d820d4f6c0bd0ce28a13f..f15f7cf01ffdb58e10ac60913201ddebe2500198 100644
--- a/includes/database.mysqli.inc
+++ b/includes/database.mysqli.inc
@@ -366,6 +366,13 @@ function db_unlock_tables() {
   db_query('UNLOCK TABLES');
 }
 
+/**
+ * Check if a table exists.
+ */
+function db_table_exists($table) {
+  return db_num_rows(db_query("SHOW TABLES LIKE '{" . db_escape_table($table) . "}'"));
+}
+
 /**
  * @} End of "ingroup database".
  */
diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc
index bb7ffd1c0ec13ae7cda0efca04a8cd369d6f6bf8..e969f722a21d75a2439d3bd10622d4e910790f49 100644
--- a/includes/database.pgsql.inc
+++ b/includes/database.pgsql.inc
@@ -343,6 +343,13 @@ function db_unlock_tables() {
   db_query('COMMIT');
 }
 
+/**
+ * Check if a table exists.
+ */
+function db_table_exists($table) {
+  return db_num_rows(db_query("SELECT relname FROM pg_class WHERE relname = '{" . db_escape_table($table) . "}'"));
+}
+
 /**
  * Verify if the database is set up correctly.
  */