CREATE TABLE object_ids ( id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, object_type ENUM('event', ...) NOT NULL) ENGINE=InnoDB;CREATE TABLE events ( id INT UNSIGNED NOT NULL PRIMARY KEY, ... ConSTRAINT FOREIGN KEY (id) REFERENCES object_ids (id)) ENGINE=InnoDB;INSERT INTO object_ids(object_type) VALUES ('event');SET @id = LAST_INSERT_ID();INSERT INTO events (id, ...) VALUES (@id, ...);
显然,您将为
events其他表复制表的结构。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)