I have table like
<code>CREATE TABLE inconsistent_objects (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
object_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' ,
inconsistent_object_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' ,
PRIMARY KEY (id)
);
</code>
<code>CREATE TABLE inconsistent_objects (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
object_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' ,
inconsistent_object_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' ,
PRIMARY KEY (id)
);
</code>
CREATE TABLE inconsistent_objects (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
object_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' ,
inconsistent_object_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' ,
PRIMARY KEY (id)
);
How to make the second request fail?
INSERT INTO eapoorg.inconsistent_fees (fee_id, inconsistent_fee_id) VALUES ('001', '002');
INSERT INTO eapoorg.inconsistent_fees (fee_id, inconsistent_fee_id) VALUES ('002', '001');
I tried to create unique index, but it didnt help
ALTER TABLE inconsistent_objects ADD UNIQUE KEY uidx (object_id, inconsistent_object_id);
New contributor
Иван Матюхин is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1