6.9.2.5 プロパティ・グラフ・ビューの削除
PGQLを使用してプロパティ・グラフ・ビューを削除できます。DROP PROPERTY GRAPH文がコールされると、プロパティ・グラフ・ビューのすべてのメタデータ表が削除されます。
JShellを使用したプロパティ・グラフ・ビューの削除
- 次のようにJShellを起動してデータベースを操作します。
./bin/opg4j --no_connect
-
次のコマンドを実行して、プロパティ・グラフ・ビューを削除します。
opg4j> var jdbcUrl="jdbc:oracle:thin:@<host_name>:<port>/<db_service>" opg4j> var conn = DriverManager.getConnection(jdbcUrl,"<username>","<password>") opg4j> var pgqlConn = PgqlConnection.getConnection(conn) opg4j> var pgqlStmt = pgqlConn.createStatement() //create a PGQL Statement opg4j> pgqlStmt.execute("DROP PROPERTY GRAPH <pgview>") $9 ==> false
Javaを使用したプロパティ・グラフ・ビューの削除
次の例に、プロパティ・グラフ・ビューを削除する方法を示します。
import java.sql.Connection;
import java.sql.Statement;
import oracle.pg.rdbms.pgql.PgqlConnection;
import oracle.pg.rdbms.pgql.PgqlStatement;
import oracle.ucp.jdbc.PoolDataSourceFactory;
import oracle.ucp.jdbc.PoolDataSource;
/**
* This example shows how to drop a property graph view.
*/
public class DropPgView
{
public static void main(String[] args) throws Exception
{
int idx=0;
String host = args[idx++];
String port = args[idx++];
String sid = args[idx++];
String user = args[idx++];
String password = args[idx++];
String pgview = args[idx++];
Connection conn = null;
PgqlStatement pgqlStmt = null;
try {
//Get a jdbc connection
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
pds.setURL("jdbc:oracle:thin:@"+host+":"+port +"/"+sid);
pds.setUser(user);
pds.setPassword(password);
conn = pds.getConnection();
conn.setAutoCommit(false);
// Get a PGQL connection
PgqlConnection pgqlConn = PgqlConnection.getConnection(conn);
// Create PGQL Statement
pgqlStmt = pgqlConn.createStatement();
String query = "DROP PROPERTY GRAPH " +pgview;
pgqlStmt.execute(query);
}
finally {
// close the statement
if (pgqlStmt != null) {
pgqlStmt.close();
}
// close the connection
if (conn != null) {
conn.close();
}
}
}
}
親トピック: プロパティ・グラフ・ビューに対するPGQL問合せの実行