1、表結構
user表
CREATE TABLE `user` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) NOT NULL COMMENT '姓名',
`age` int(11) NOT NULL COMMENT '年齡',
`status` int(11) NOT NULL DEFAULT '0' COMMENT '狀態',
`points` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '積分',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '創建時間',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改時間',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `name` (`name`,`age`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=46823 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
user_test表
CREATE TABLE `user_test` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '創建時間',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改時間',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2、刪除一個表數據
delete ut from user u,user_test ut where u.id=ut.user_id and u.id=298;
3、刪除多個表數據
delete u,ut from user u,user_test ut where u.id=ut.user_id and u.id=298;