CREATE TABLE IF NOT EXISTS `scores` (
`userID` int(11) NOT NULL,
`sessionID` int(11) NOT NULL,
`points` double NOT NULL DEFAULT '0',
PRIMARY KEY (`userID`,`sessionID`),
KEY `par_ind1` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Run Code Online (Sandbox Code Playgroud)
这条线是什么:
KEY `par_ind1` (`userID`)
Run Code Online (Sandbox Code Playgroud)
做?(userID是另一个表中的主键?)
Mic*_*ski 10
KEY是...的同义词INDEX.除了已经与之共享的组合键之外,这还会创建一个名为par_ind1ont的索引.userIDsessionID
有关完整详细信息,请参阅MySQLCREATE TABLE文档,但相关部分如下:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
{ LIKE old_tbl_name | (LIKE old_tbl_name) }
create_definition:
col_name column_definition
| [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...)
[index_option] ...
/* Key/Index creation */
| {INDEX|KEY} [index_name] [index_type] (index_col_name,...)
[index_option] ...
Run Code Online (Sandbox Code Playgroud)
由于未index_type指定,因此使用默认值.请参阅默认索引类型的CREATE INDEX参考,这些索引类型因表存储引擎而异.对于像这样的InnoDB表,这是一个BTREE索引.
| 归档时间: |
|
| 查看次数: |
7103 次 |
| 最近记录: |