【问题标题】:Creating a relationship diagram from a script从脚本创建关系图
【发布时间】:2020-12-02 15:45:04
【问题描述】:

我有一个很长的脚本,它经过大量计算,我想跟踪它们的来源列。例如下面示例中表 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', '1', 'One hundred angels can dance on the head of a pin'),
  ('1', '2', 'The earth is flat and rests on a bull\'s horn'),
  ('1', '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);

【问题讨论】:

    标签: sql diagram


    【解决方案1】:

    市场上很少有产品可以做到这一点: https://dbmstools.com/categories/data-dictionary-tools/redshift

    【讨论】:

      猜你喜欢
      • 2016-07-31
      • 1970-01-01
      • 2016-09-30
      • 2020-12-26
      • 1970-01-01
      • 2012-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多