使用BTREE的mysql

时间:2011-10-15 08:46:39

标签: mysql

如何解决这个问题?
我的表结构:

CREATE TABLE IF NOT EXISTS `tbl_foster_network` (
  `network_id` int(11) NOT NULL COMMENT 'Network ID',
  `network_name` varchar(64) NOT NULL COMMENT 'Network Name',
  `network_domain` varchar(45) NOT NULL COMMENT 'Network Domain',
  `created_when` datetime NOT NULL COMMENT 'Created When',
  `last_modified_by` int(11) NOT NULL COMMENT 'Last Modified By',
  `last_modified_when` datetime NOT NULL COMMENT 'Last Modified When',
  PRIMARY KEY (`network_id`),
  UNIQUE KEY `network_domain` (`network_id`,`network_name`,`network_domain`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Network';

错误

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Network'' at line 16 

1 个答案:

答案 0 :(得分:1)

索引类型(USING BTREE)必须位于列列表之前:

UNIQUE KEY uq_network_domain USING BTREE (network_id,network_name,network_domain)

来自manual

[CONSTRAINT [symbol]] UNIQUE [INDEX|KEY]
      [index_name] [index_type] (index_col_name,...)
      [index_option] ...

index_type:
    USING {BTREE | HASH}