MySQL ON UPDATE/ON DELETE CASCADE 不是 CASCADE

发布于 2024-12-15 17:56:45 字数 3109 浏览 3 评论 0原文

当我编辑注册表上的 UID 时,客户端表上的parentid 列应该会更改。它不是这样做的。有什么建议吗?

客户

CREATE TABLE `clients` (
    `id` INT(255) NOT NULL AUTO_INCREMENT,
    `fname` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `lname` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `email` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `phone` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `parentid` INT(255) NOT NULL,
    `hphone` VARCHAR(12) NOT NULL COLLATE 'latin1_bin',
    `postal` VARCHAR(10) NOT NULL COLLATE 'latin1_bin',
    `city` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `address` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `province` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `country` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `sms` INT(1) NOT NULL,
    `semail` INT(1) NOT NULL,
    `gender` VARCHAR(6) NOT NULL COLLATE 'latin1_bin',
    `bday` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `bmonth` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    PRIMARY KEY (`id`),
    INDEX `parentid` (`parentid`),
    CONSTRAINT `FK_clients_signup` FOREIGN KEY (`parentid`) REFERENCES `signup` (`UID`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='latin1_bin'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=31751

注册

CREATE TABLE `signup` (
    `UID` INT(255) NOT NULL AUTO_INCREMENT,
    `username` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `hash` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `email` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `fname` VARCHAR(40) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `lname` VARCHAR(40) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `address` TEXT NOT NULL COLLATE 'latin1_bin',
    `city` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `province` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `zip` VARCHAR(30) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `country` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `company` TEXT NOT NULL COLLATE 'latin1_bin',
    `addtime` VARCHAR(20) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `logintime` VARCHAR(20) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `user_ip` VARCHAR(16) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `pwd` VARCHAR(60) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `credits` INT(255) NOT NULL,
    `plan` INT(255) NOT NULL DEFAULT '1',
    `reset` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `expires` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `afid` INT(255) NOT NULL,
    `industryid` INT(255) NOT NULL,
    PRIMARY KEY (`UID`),
    UNIQUE INDEX `email` (`email`),
    UNIQUE INDEX `username` (`username`),
    INDEX `industryid` (`industryid`),
    INDEX `afid` (`afid`),
    INDEX `plan` (`plan`),
    CONSTRAINT `FK_signup_affiliates` FOREIGN KEY (`afid`) REFERENCES `affiliates` (`afid`) ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT `FK_signup_plans` FOREIGN KEY (`plan`) REFERENCES `plans` (`pid`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='latin1_bin'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=27

When I edit UID on the signup table, the parentid column on the clients table is supposed to change. It's not doing that. Any suggestions?

Clients

CREATE TABLE `clients` (
    `id` INT(255) NOT NULL AUTO_INCREMENT,
    `fname` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `lname` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `email` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `phone` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `parentid` INT(255) NOT NULL,
    `hphone` VARCHAR(12) NOT NULL COLLATE 'latin1_bin',
    `postal` VARCHAR(10) NOT NULL COLLATE 'latin1_bin',
    `city` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `address` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `province` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `country` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `sms` INT(1) NOT NULL,
    `semail` INT(1) NOT NULL,
    `gender` VARCHAR(6) NOT NULL COLLATE 'latin1_bin',
    `bday` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `bmonth` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    PRIMARY KEY (`id`),
    INDEX `parentid` (`parentid`),
    CONSTRAINT `FK_clients_signup` FOREIGN KEY (`parentid`) REFERENCES `signup` (`UID`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='latin1_bin'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=31751

Signup

CREATE TABLE `signup` (
    `UID` INT(255) NOT NULL AUTO_INCREMENT,
    `username` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `hash` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `email` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `fname` VARCHAR(40) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `lname` VARCHAR(40) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `address` TEXT NOT NULL COLLATE 'latin1_bin',
    `city` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `province` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `zip` VARCHAR(30) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `country` VARCHAR(80) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `company` TEXT NOT NULL COLLATE 'latin1_bin',
    `addtime` VARCHAR(20) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `logintime` VARCHAR(20) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `user_ip` VARCHAR(16) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `pwd` VARCHAR(60) NOT NULL DEFAULT '' COLLATE 'latin1_bin',
    `credits` INT(255) NOT NULL,
    `plan` INT(255) NOT NULL DEFAULT '1',
    `reset` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `expires` VARCHAR(255) NOT NULL COLLATE 'latin1_bin',
    `afid` INT(255) NOT NULL,
    `industryid` INT(255) NOT NULL,
    PRIMARY KEY (`UID`),
    UNIQUE INDEX `email` (`email`),
    UNIQUE INDEX `username` (`username`),
    INDEX `industryid` (`industryid`),
    INDEX `afid` (`afid`),
    INDEX `plan` (`plan`),
    CONSTRAINT `FK_signup_affiliates` FOREIGN KEY (`afid`) REFERENCES `affiliates` (`afid`) ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT `FK_signup_plans` FOREIGN KEY (`plan`) REFERENCES `plans` (`pid`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='latin1_bin'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=27

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明媚殇 2024-12-22 17:56:45

它可能不会改变,因为您不可能更改注册表上的 UID,因为它是主键,并且自动递增

It's probably not changing because you can't possibly change the UID on the signup table since it's the primary key, and is auto incremented

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文