I am attempting to have my plugin create a new table. I am fairly new to SQL. I have found two different method for creating tables:
Method I
$table_name = $wpdb->prefix . 'cool_table';
$sql = "CREATE TABLE $table_name (
[command to set up columns go here]
) DEFAULT CHARSET=utf8;";
Method II
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";
$table_name = $wpdb->prefix . 'cool_table';
$sql = "CREATE TABLE $table_name (
[command to set up columns go here]
) ENGINE = InnoDB {$charset_collate};";
What is the benefit of setting the default charset vs. setting the ENGINE when creating a new table?
ENGINE
one-- changes the database engine toInnoDB
for the table created. The first creates the table using the server default database engine, which used to beMYISAM
but I heard a rumor that that was changing.