@Override protected void readColumns( DatabaseSnapshot snapshot, String schema, DatabaseMetaData databaseMetaData) throws SQLException, DatabaseException { findIntegerColumns(snapshot, schema); super.readColumns(snapshot, schema, databaseMetaData); /* * Code Description: * Finding all 'tablespace' attributes of column's PKs * */ Database database = snapshot.getDatabase(); Statement statement = null; ResultSet rs = null; try { statement = ((JdbcConnection) database.getConnection()).getUnderlyingConnection().createStatement(); // Setting default schema name. Needed for correct statement generation if (schema == null) schema = database.convertRequestedSchemaToSchema(schema); String query = "select ui.tablespace_name TABLESPACE, ucc.table_name TABLE_NAME, ucc.column_name COLUMN_NAME FROM all_indexes ui , all_constraints uc , all_cons_columns ucc where uc.constraint_type = 'P' and ucc.constraint_name = uc.constraint_name and uc.index_name = ui.index_name and uc.owner = '" + schema + "' and ui.table_owner = '" + schema + "' and ucc.owner = '" + schema + "'"; rs = statement.executeQuery(query); while (rs.next()) { Column column = snapshot.getColumn(rs.getString("TABLE_NAME"), rs.getString("COLUMN_NAME")); // setting up tablespace property to column, to configure it's PK-index if (column == null) { continue; // probably a different schema } column.setTablespace(rs.getString("TABLESPACE")); } } finally { if (rs != null) { try { rs.close(); } catch (SQLException ignore) { } } if (statement != null) { try { statement.close(); } catch (SQLException ignore) { } } } }
/** Oracle specific implementation */ @Override protected void getColumnTypeAndDefValue(Column columnInfo, ResultSet rs, Database database) throws SQLException, DatabaseException { super.getColumnTypeAndDefValue(columnInfo, rs, database); // Exclusive setting for oracle INTEGER type // Details: // INTEGER means NUMBER type with 'data_precision IS NULL and scale = 0' if (columnInfo.getDataType() == Types.INTEGER) { columnInfo.setTypeName("INTEGER"); } String columnTypeName = rs.getString("TYPE_NAME"); if ("VARCHAR2".equals(columnTypeName)) { int charOctetLength = rs.getInt("CHAR_OCTET_LENGTH"); int columnSize = rs.getInt("COLUMN_SIZE"); if (columnSize == charOctetLength) { columnInfo.setLengthSemantics(Column.LengthSemantics.BYTE); } else { columnInfo.setLengthSemantics(Column.LengthSemantics.CHAR); } } }