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);
    }
  }
Beispiel #2
0
  private void visit(Table table, Column column) {
    append(NEWLINE).append(TAB);
    if (table.getTableType() == Table.Type.TemporaryTable
        && column.isAutoIncremented()
        && column.getNullType() == NullType.No_Nulls
        && column.getJavaType() == DataTypeManager.DefaultDataClasses.INTEGER) {
      append(SQLStringVisitor.escapeSinglePart(column.getName()));
      append(SPACE);
      append(SERIAL);
    } else {
      appendColumn(column, true, true);

      if (column.isAutoIncremented()) {
        append(SPACE).append(AUTO_INCREMENT);
      }
    }

    appendDefault(column);

    // options
    appendColumnOptions(column);
  }