Is there a better solution to create a database table for a WordPress Plugin? How can I simplify this query? What code improvements could be made in this code? Any ideas would be great.
register_activation_hook(__FILE__, 'my_plugin_create_db');
function my_plugin_create_db() {
global $wpdb;
$name = 'my_table';
$charset_collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . $name;
$sql = "CREATE TABLE $table_name("
. "id int(9) NOT NULL AUTO_INCREMENT,"
. "time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,"
. "views int(9) NOT NULL,"
. "clicks int(9) NOT NULL,"
. "UNIQUE KEY id (id)"
. ")$charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}