Ejemplo n.º 1
0
  public static String getTableSpace(Connection connection, String dataFile1, String dataFile2)
      throws SQLException {
    String sql = null;
    String result = "";

    switch (connection.vendor()) {
      case Oracle:
        {
          sql =
              "SELECT TO_NCHAR(q.tablespace_name) AS TBS FROM user_ts_quotas q inner join user_tablespaces t on (q.tablespace_name=t.tablespace_name) WHERE (upper(q.tablespace_name) like '%"
                  + dataFile1
                  + "'  ESCAPE '/' or  upper(q.tablespace_name) like '%"
                  + dataFile2
                  + "' ESCAPE '/') AND q.max_bytes<>0";
          break;
        }
      case SqlServer:
        {
          sql =
              "select Convert(nvarchar(max), groupname) as TBS from sysfilegroups where (upper(groupname) like '%"
                  + dataFile1
                  + "' or upper(groupname) like '%"
                  + dataFile2
                  + "') and (status & 8 <> 8)";
          break;
        }
      default:
        {
          return result;
        }
    }

    Cursor cursor = BasicSelect.cursor(connection, sql);
    result = cursor.next() ? cursor.getString(1).get() : "";
    cursor.close();

    if (result.isEmpty()) {
      return result;
    }

    switch (connection.vendor()) {
      case Oracle:
        return " TABLESPACE " + result;
      case SqlServer:
        return " ON " + result;
      default:
        throw new UnknownDatabaseException();
    }
  }
Ejemplo n.º 2
0
 static void dropIndex(Connection conn, String tableName, String indexName) throws SQLException {
   switch (conn.vendor()) {
     case Postgres:
     case Oracle:
       dropIndexOracle(conn, tableName, indexName);
       break;
     case SqlServer:
       dropIndexSQLServer(conn, tableName, indexName);
       break;
     default:
       throw new UnsupportedOperationException();
   }
 }
Ejemplo n.º 3
0
 private static void dropIndexSQLServer(Connection connection, String tableName, String indexName)
     throws SQLException {
   DatabaseVendor vendor = connection.vendor();
   String sql = "drop index " + vendor.quote(tableName) + "." + vendor.quote(indexName);
   Statement.executeUpdate(connection, sql);
 }