# dummy

    Code
      # dummy

# dm_sql()

    Code
      dm_for_filter_df() %>% dm_sql(my_test_con())
    Output
      $pre
      $pre$tf_1
      <SQL> CREATE TEMPORARY TABLE "tf_1" (
        "a" SERIAL,
        "b" TEXT,
        PRIMARY KEY ("a")
      )
      
      $pre$tf_2
      <SQL> CREATE TEMPORARY TABLE "tf_2" (
        "c" TEXT,
        "d" INTEGER,
        "e" TEXT,
        "e1" INTEGER,
        PRIMARY KEY ("c")
      )
      
      $pre$tf_3
      <SQL> CREATE TEMPORARY TABLE "tf_3" (
        "f" TEXT,
        "f1" INTEGER,
        "g" TEXT,
        PRIMARY KEY ("f", "f1")
      )
      
      $pre$tf_4
      <SQL> CREATE TEMPORARY TABLE "tf_4" (
        "h" TEXT,
        "i" TEXT,
        "j" TEXT,
        "j1" INTEGER,
        PRIMARY KEY ("h")
      )
      
      $pre$tf_5
      <SQL> CREATE TEMPORARY TABLE "tf_5" (
        "ww" INTEGER,
        "k" INTEGER,
        "l" TEXT,
        "m" TEXT,
        PRIMARY KEY ("k")
      )
      
      $pre$tf_6
      <SQL> CREATE TEMPORARY TABLE "tf_6" (
        "zz" INTEGER,
        "n" TEXT,
        "o" TEXT,
        PRIMARY KEY ("o")
      )
      
      
      $load
      $load$tf_1
      <SQL> INSERT INTO "tf_1" ("a", "b")
      SELECT CAST("a" AS INTEGER) AS "a", CAST("b" AS TEXT) AS "b"
      FROM (
        VALUES
          (1, 'A'),
          (2, 'B'),
          (3, 'C'),
          (4, 'D'),
          (5, 'E'),
          (6, 'F'),
          (7, 'G'),
          (8, 'H'),
          (9, 'I'),
          (10, 'J')
      ) AS drvd("a", "b")
      
      $load$tf_2
      <SQL> INSERT INTO "tf_2" ("c", "d", "e", "e1")
      SELECT
        CAST("c" AS TEXT) AS "c",
        CAST("d" AS INTEGER) AS "d",
        CAST("e" AS TEXT) AS "e",
        CAST("e1" AS INTEGER) AS "e1"
      FROM (
        VALUES
          ('cat', 7, 'F', 6),
          ('dog', 6, 'E', 5),
          ('elephant', 2, 'D', 4),
          ('lion', 3, 'E', 5),
          ('seal', 4, 'F', 6),
          ('worm', 5, 'G', 7)
      ) AS drvd("c", "d", "e", "e1")
      
      $load$tf_3
      <SQL> INSERT INTO "tf_3" ("f", "f1", "g")
      SELECT
        CAST("f" AS TEXT) AS "f",
        CAST("f1" AS INTEGER) AS "f1",
        CAST("g" AS TEXT) AS "g"
      FROM (
        VALUES
          ('C', 2, 'one'),
          ('C', 3, 'two'),
          ('D', 4, 'three'),
          ('E', 5, 'four'),
          ('F', 6, 'five'),
          ('G', 7, 'six'),
          ('H', 7, 'seven'),
          ('I', 7, 'eight'),
          ('J', 10, 'nine'),
          ('K', 11, 'ten')
      ) AS drvd("f", "f1", "g")
      
      $load$tf_4
      <SQL> INSERT INTO "tf_4" ("h", "i", "j", "j1")
      SELECT
        CAST("h" AS TEXT) AS "h",
        CAST("i" AS TEXT) AS "i",
        CAST("j" AS TEXT) AS "j",
        CAST("j1" AS INTEGER) AS "j1"
      FROM (
        VALUES
          ('a', 'three', 'C', 3),
          ('b', 'four', 'D', 4),
          ('c', 'five', 'E', 5),
          ('d', 'six', 'F', 6),
          ('e', 'seven', 'F', 6)
      ) AS drvd("h", "i", "j", "j1")
      
      $load$tf_5
      <SQL> INSERT INTO "tf_5" ("ww", "k", "l", "m")
      SELECT
        CAST("ww" AS INTEGER) AS "ww",
        CAST("k" AS INTEGER) AS "k",
        CAST("l" AS TEXT) AS "l",
        CAST("m" AS TEXT) AS "m"
      FROM (
        VALUES
          (2, 1, 'b', 'house'),
          (2, 2, 'c', 'tree'),
          (2, 3, 'd', 'streetlamp'),
          (2, 4, 'e', 'streetlamp')
      ) AS drvd("ww", "k", "l", "m")
      
      $load$tf_6
      <SQL> INSERT INTO "tf_6" ("zz", "n", "o")
      SELECT
        CAST("zz" AS INTEGER) AS "zz",
        CAST("n" AS TEXT) AS "n",
        CAST("o" AS TEXT) AS "o"
      FROM (
        VALUES
          (1, 'garden', 'i'),
          (1, 'hill', 'g'),
          (1, 'house', 'e'),
          (1, 'streetlamp', 'h'),
          (1, 'tree', 'f')
      ) AS drvd("zz", "n", "o")
      
      
      $post
      $post$uk
      $post$uk$tf_1
      <SQL> ALTER TABLE "tf_1" ADD UNIQUE ("a")
      
      $post$uk$tf_2
      <SQL> ALTER TABLE "tf_2" ADD UNIQUE ("c")
      
      $post$uk$tf_3
      <SQL> ALTER TABLE "tf_3" ADD UNIQUE ("f", "f1")
      <SQL> ALTER TABLE "tf_3" ADD UNIQUE ("g")
      
      $post$uk$tf_4
      <SQL> ALTER TABLE "tf_4" ADD UNIQUE ("h")
      
      $post$uk$tf_5
      <SQL> ALTER TABLE "tf_5" ADD UNIQUE ("k")
      
      $post$uk$tf_6
      <SQL> ALTER TABLE "tf_6" ADD UNIQUE ("o")
      <SQL> ALTER TABLE "tf_6" ADD UNIQUE ("n")
      
      
      $post$fk
      $post$fk$tf_2
      <SQL> ALTER TABLE "tf_2" ADD FOREIGN KEY ("d") REFERENCES "tf_1" ("a")
      <SQL> ALTER TABLE "tf_2" ADD FOREIGN KEY ("e", "e1") REFERENCES "tf_3" ("f", "f1")
      
      $post$fk$tf_4
      <SQL> ALTER TABLE "tf_4" ADD FOREIGN KEY ("j", "j1") REFERENCES "tf_3" ("f", "f1")
      
      $post$fk$tf_5
      <SQL> ALTER TABLE "tf_5" ADD FOREIGN KEY ("l") REFERENCES "tf_4" ("h") ON DELETE CASCADE
      <SQL> ALTER TABLE "tf_5" ADD FOREIGN KEY ("m") REFERENCES "tf_6" ("n")
      
      
      $post$indexes
      $post$indexes$tf_2
      <SQL> CREATE INDEX tf_2__d ON "tf_2" ("d")
      <SQL> CREATE INDEX tf_2__e_e1 ON "tf_2" ("e", "e1")
      
      $post$indexes$tf_4
      <SQL> CREATE INDEX tf_4__j_j1 ON "tf_4" ("j", "j1")
      
      $post$indexes$tf_5
      <SQL> CREATE INDEX tf_5__l ON "tf_5" ("l")
      <SQL> CREATE INDEX tf_5__m ON "tf_5" ("m")
      
      
      

