问题描述
我有一个很长的脚本,需要进行大量的计算,我想跟踪它们的起源列。例如,下面示例中的表z中的“ identifier”和“ concat_var”列。我可以以某种方式“自动”执行此操作并以图形显示吗?
-- borrowed from https://stackoverflow.com/q/7745609/808921
CREATE TABLE IF NOT EXISTS `docs` (
`id` int(6) unsigned NOT NULL,`rev` int(3) unsigned NOT NULL,`content` varchar(200) NOT NULL,PRIMARY KEY (`id`,`rev`)
) DEFAULT CHARSET=utf8;
INSERT INTO `docs` (`id`,`rev`,`content`) VALUES
('1','1','The earth is flat'),('2','One hundred angels can dance on the head of a pin'),('1','2','The earth is flat and rests on a bull\'s horn'),'3','The earth is like a ball.');
CREATE TABLE x (
SELECT * FROM docs WHERE rev = 1);
CREATE TABLE y (
SELECT * FROM docs WHERE rev != 1);
CREATE TABLE z (
SELECT
CONCAT(a.content,' - ',b.content) AS concat_var,a.id AS identifier
FROM
x AS a
INNER JOIN
y AS b
ON
a.id = b.id);