Friday, July 2, 2010

add unique key and show full table

mysql> show create table rating;
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                                                                                                                                                                                                                                                                                                   |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| rating | CREATE TABLE `rating` (
  `id` int(10) NOT NULL auto_increment,
  `domain_name` varchar(255) default NULL,
  `product_id` int(10) default NULL,
  `user_ip` varchar(15) default NULL,
  `rate` int(1) default '5',
  `comments` text,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `domain_name` (`domain_name`,`product_id`)
) ENGINE=MyISAM AUTO_INCREMENT=369 DEFAULT CHARSET=latin1 |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> alter table rating add UNIQUE (domain_name, product_id);

No comments:

Post a Comment