Answer the question
In order to leave comments, you need to log in
Why can't I drop parent MYSQL table?
To drop the towns table, I first have to drop the citizens. What's the point then in ON DELETE CASCADE?
CREATE TABLE IF NOT EXISTS towns
(
name VARCHAR(24) DEFAULT 0 NOT NULL,
mayor VARCHAR(24) DEFAULT 0 NOT NULL,
`timestamp` BIGINT DEFAULT 0 NOT NULL,
PRIMARY KEY(name)
);
CREATE TABLE IF NOT EXISTS citizens
(
town VARCHAR(24),
name VARCHAR(24) DEFAULT 0 NOT NULL,
uuid CHAR(36) DEFAULT 0 NOT NULL,
PRIMARY KEY(name),
FOREIGN KEY (town) REFERENCES towns(name) ON DELETE CASCADE
);
insert into towns (name, mayor, timestamp) values ('Town', 'Name', 1625428916539);
insert into citizens (town, name, uuid) values ('Town', 'Name', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question