Testing and creating a table
01/06/2016
![](/sites/default/files/styles/ps_article_image/public/2016-11/7_0.jpg?itok=Ltf5eU2-)
The objective of this snippet is to show if a table exists in the system and to create one if it does not already exist.
$table_name = 'TABLE_NAME';
$table_schema = drupal_get_schema_unprocessed('MODULE_NAME', $table_name);
if (!db_table_exists($table_name)) {
db_create_table($table_name, $table_schema);
}