ORA-01732:このビューのデータ操作は不正です

7110 ワード

問題の説明
oracleデータベースにはmaterialized viewsが作成され、バックアップに成功し、リカバリ時に警告が表示されます.
..          “TESTMAVIEW”
IMP-00058:    ORACLE    1732
ORA-01732:              

メモ:リカバリを実行する前にmaterialized viewsが削除されず、データベースのリカバリに失敗しました.materialized viewsを削除し、データベースのリカバリに成功しました.
の原因となる
マテリアライズド・ビューは、テーブルのようにデータを格納し、pl/sqlでオブジェクト・リストを表示すると、作成されたマテリアライズド・ビューがtablesオブジェクト列にあり、drop文でマテリアライズド・ビュー・オブジェクトのエラーを直接削除します.
ORA-12003:   DROP MATERIALIZED VIEW

ps:プログラムによるデータベースバックアップのため、データベースに存在するテーブルや他のオブジェクトを削除し、impコマンドを呼び出してデータベースインポートを行います.
解決策
まずDROP MATERIZED VIEW mv_を呼び出すnameはすべての物体化ビューを削除し、他のテーブルオブジェクトを削除します.
コード#コード#
protected ConnectionConfBuilder connectionConfBuilder;
protected Connection connection;

/**
   * @Title: romveObject
   * @Description:        
   * @param dbType
   * @throws Exception
   * @author zxk
   * @version 1.0
   */
public void romveObject(String dbType) throws Exception {
    //        
    this.connectionConfBuilder = IOCUtils.getBean(ConnectionConfBuilderUtils.getConnectionConfBuilderName(dbType));
    this.connectionConfBuilder.initialize(super.dbConfig);

    //   MATERIALIZED VIEW
    this.dropMaterializedView(2, "MATERIALIZED VIEW");
}

/**
   * @Title: dropMaterializedView
   * @Description:   dropMaterialized View
   * @param count
   * @throws Exception
   * @author zxk
   * @version 1.0
   */
 private void dropMaterializedView(int count, String objectType) throws Exception {
    ResultSet rs = null;
    PreparedStatement pStatement = null;
    PreparedStatement dropStatement = null;
    try {
      this.getConnection(count);
      pStatement = this.connection
          .prepareStatement("select OBJECT_NAME from user_objects where object_type='" + objectType + "'");
      rs = pStatement.executeQuery();
      while (rs.next()) {
        String tt = rs.getString("OBJECT_NAME"); //      
        try {
          String dropsql = "DROP MATERIALIZED VIEW " + tt;
          dropStatement = this.connection.prepareStatement(dropsql);
          dropStatement.executeUpdate();
        } catch (SQLException e1) {
          LOG.error("  [{}]  ", tt, e1);
          if (dropStatement != null) {
            dropStatement.close();
          }
        }
        dropStatement.close();
      }
    } catch (Exception e) {
      throw new Exception("  " + objectType + "  " + "-->" + e.getMessage(), e);
    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pStatement != null) {
          pStatement.close();
        }
      } catch (Exception e) {
        LOG.error("         ");
      }
    }
}

/**
   * @Title: getConnection
   * @Description:    
   * @param count
   * @throws Exception
   * @version 1.0
   */
 private void getConnection(int count) throws Exception {
    try {
      Driver driver = this.connectionConfBuilder.getDriver();
      String url = this.connectionConfBuilder.getUrl().replaceAll("%", "%25");
      Properties info = new Properties();
      info.setProperty("user", connectionConfBuilder.getUserName());
      info.setProperty("password", connectionConfBuilder.getPassword());
      this.connection = driver.connect(url, info);
    } catch (Exception e) {
      count = count - 1;
      if (count <= 0) {
        throw new Exception("         " + e.getMessage(), e);
      }
      //   
      try {
        //   5       
        Thread.sleep(5000);
      } catch (InterruptedException ex) {

      }
      getConnection(count);
    }
  }