此代碼解壓縮來自KohanaJobs應用程序附帶的database.sql文件。MySQL:創建表時,「KEY」代表什麼?
CREATE TABLE IF NOT EXISTS `roles_users` (
`user_id` int(10) unsigned NOT NULL,
`role_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`user_id`,`role_id`),
KEY `fk_role_id` (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `sessions` (
`session_id` varchar(24) NOT NULL,
`last_active` int(10) unsigned NOT NULL,
`contents` text NOT NULL,
PRIMARY KEY (`session_id`),
KEY `last_active` (`last_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
爲什麼只是KEY
已被用於上面?這只是暗示它們被用作FK嗎?
爲什麼顯示寬度10如果你不使用zerofill?爲什麼不把它聲明爲:user_id int unsigned not null?哦,爲什麼反勾號呢? – 2011-01-09 15:33:06
@ f00 - 抱歉沒有得到你的意思? – coder9 2011-01-09 15:50:37
http://pastie.org/1442882 – 2011-01-09 16:23:28