Why navicat writes key instead of foreign key in CREATE TABLE?
CREATE TABLE IF NOT EXISTS `trl_bill` (
`bill_id` int(11) NOT NULL AUTO_INCREMENT,
`fee` double NOT NULL DEFAULT '0',
`begin_date` date NOT NULL,
`end_date` date NOT NULL,
`is_paid` tinyint(4) NOT NULL DEFAULT '0',
`request_id` int(11) NOT NULL,
PRIMARY KEY (`bill_id`),
KEY `requ开发者_运维问答est_id` (`request_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED AUTO_INCREMENT=1 ;
This is my table sql, i use navicat to design my database, why it writes KEY
instead of FOREIGN KEY
?
The KEY
keyword is a synonym for INDEX
in MySQL. You do not have a foreign key constraint specified in that CREATE TABLE
command.
The CREATE TABLE
syntax:
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] ...
| {INDEX|KEY} [index_name] [index_type] (index_col_name,...)
[index_option] ...
| [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY]
[index_name] [index_type] (index_col_name,...)
[index_option] ...
| {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...)
[index_option] ...
| [CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (index_col_name,...) reference_definition
| CHECK (expr)
精彩评论