0
MySQL的CHAR外鍵的結果我有以下表設置:1215年錯誤
CREATE TABLE USER (
id CHAR(36) NOT NULL,
user_id VARCHAR(200) NOT NULL,
password VARCHAR(200) NOT NULL,
email VARCHAR(500) NOT NULL,
enabled_ind INTEGER(1) NOT NULL,
other_user_oid INTEGER(19),
other_user_pod VARCHAR(10),
last_changed_date TIMESTAMP NOT NULL,
last_changed_by VARCHAR(255) NOT NULL,
created_date TIMESTAMP NOT NULL,
created_by VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY ix_user_id (user_id),
UNIQUE KEY ix_user_email (email),
UNIQUE KEY ix_user_pod (other_user_oid, other_user_pod)
)
ENGINE = InnoDB
CHARACTER SET = utf8
COLLATE = utf8_bin;
CREATE TABLE ROLE (
id CHAR(36) NOT NULL,
name VARCHAR(50) NOT NULL,
last_changed_date TIMESTAMP NOT NULL,
last_changed_by VARCHAR(255) NOT NULL,
created_date TIMESTAMP NOT NULL,
created_by VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY ix_role_name(name)
)
ENGINE = InnoDB
CHARACTER SET = utf8
COLLATE = utf8_bin;
CREATE TABLE USER_ROLES (
user_id CHAR(36) NOT NULL,
role_id CHAR(36) NOT NULL,
last_changed_date TIMESTAMP NOT NULL,
last_changed_by VARCHAR(255) NOT NULL,
created_date TIMESTAMP NOT NULL,
created_by VARCHAR(255) NOT NULL,
INDEX (user_id),
INDEX (role_id),
FOREIGN KEY (user_id)
REFERENCES user (id)
ON UPDATE CASCADE,
FOREIGN KEY (role_id)
REFERENCES role (id)
ON UPDATE CASCADE
)
ENGINE = InnoDB
CHARACTER SET = utf8
COLLATE = utf8_bin;
當我去創建USER_ROLES表,我得到一個「無法添加外鍵約束」的錯誤。我在stackoverflow上發現的大多數類似問題似乎都與字符集和整理有關,但從我所知道的情況來看,我正確地做到了這一點,所以我不太確定問題所在。在這兒。一段時間以來,我一直在嘗試一堆不同的東西,但似乎沒有任何工作。
任何幫助將不勝感激!
奇怪......我想知道爲什麼它不適合我。也許這是一個版本問題。我使用BCrypt散列所有密碼。 – cloudwalker