ユーザ用ツール

サイト用ツール


database:oracledb9i:backup_restore

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
database:oracledb9i:backup_restore [2023/05/23 15:20] – [論理バックアップとリストア] mikotodatabase:oracledb9i:backup_restore [2023/07/14 16:20] (現在) – [SQLファイルを使う場合] mikoto
行 81: 行 81:
 where owner='user' where owner='user'
 order by object_name; order by object_name;
 +</code>
 +あるいは対象のユーザーにスイッチして確認
 +<code sql>
 +conn user/pass
 +select object_name, object_type
 +from user_objects;
 </code> </code>
  
 +ユーザーのデフォルト表領域を確認するには
 +<code>
 +select tablespace_name from dba_segments where owner = 'schema_name'
 +</code>
 +
 +===== リストア手順 =====
 +まず、オブジェクトなどを初期化するためにスキーマを削除する
 +<code sql>
 +drop user 'user_name' cascade;
 +</code>
 +''cascade''オプションを付与すると、スキーマの削除と共に関連するオブジェクトを削除してくれる。
 +次に、スキーマを再作成する。その際、デフォルトの表領域を設定しておく。またはスキーマの作成後に割り当てる。
 +<code sql>
 +create user username identified by password default tablespace tbs_name;
 +</code>
 +<code sql>
 +alter user username default tablespace tbs_name;
 +</code>
 <code> <code>
 imp userid=username/password@connect_string file=backup_file.dmp full=y ignore=y log=logfile.log imp userid=username/password@connect_string file=backup_file.dmp full=y ignore=y log=logfile.log
行 93: 行 117:
 |ignore|エラーがあっても処理を続行するかどうか。続行(y)/中止(n)| |ignore|エラーがあっても処理を続行するかどうか。続行(y)/中止(n)|
 |log|ログファイルの出力先を指定| |log|ログファイルの出力先を指定|
 +|commit|y/n 指定することでコミットを確定できる。|
 +
 +==== SQLファイルを使う場合 ====
 +<code>
 +sqlplus "sys/change_on_install as sysdba" @/path/to/sqlfile
 +imp userid='system/manage as sysdba' fromuser='FROMUSER' touser='TOUSER' commit=y file=/path/to/dmp log=/path/to/log
 +</code>
 +
 +<file | drop_and_create.sql>
 +DROP USER <user_name> CASCADE;
 +CREATE USER <user_name> IDENTIFIED BY <password> DEFAULT TABLESPACE <tbsp_name>;
 +GRANT UNLIMITED TABLESPACE TO <user_name>;
 +GRANT DBA TO <user_name>;
 +GRANT CONNECT TO <user_name>;
 +GRANT RESOURCE TO <user_name>;
 +QUIT;
 +</file>
  
database/oracledb9i/backup_restore.1684822856.txt.gz · 最終更新: 2023/05/23 15:20 by mikoto