Beispiel #1
0
  private void visit(Table table) {
    if (this.filter != null && !filter.matcher(table.getName()).matches()) {
      return;
    }

    append(CREATE).append(SPACE);
    if (table.isPhysical()) {
      append(FOREIGN_TABLE);
    } else {
      if (table.getTableType() == Table.Type.TemporaryTable) {
        append(GLOBAL).append(SPACE).append(TEMPORARY).append(SPACE).append(TABLE);
      } else {
        append(VIEW);
      }
    }
    append(SPACE);
    String name = addTableBody(table);

    if (table.getTableType() != Table.Type.TemporaryTable) {
      if (table.isVirtual()) {
        append(NEWLINE)
            .append(SQLConstants.Reserved.AS)
            .append(NEWLINE)
            .append(table.getSelectTransformation());
      }
      append(SQLConstants.Tokens.SEMICOLON);

      if (table.isInsertPlanEnabled()) {
        buildTrigger(name, null, INSERT, table.getInsertPlan());
      }

      if (table.isUpdatePlanEnabled()) {
        buildTrigger(name, null, UPDATE, table.getUpdatePlan());
      }

      if (table.isDeletePlanEnabled()) {
        buildTrigger(name, null, DELETE, table.getDeletePlan());
      }

      for (Trigger tr : table.getTriggers().values()) {
        buildTrigger(name, tr.getName(), tr.getEvent().name(), tr.getPlan());
      }
    } else {
      append(SQLConstants.Tokens.SEMICOLON);
    }
  }