Windows でエクスポート前にスキーマの行数を確認する

データベースのエクスポートを開始する前に、スキーマの行数を確認します。確認したデータベースの行数をエクスポート完了後の行数と比較します。
  1. [SQL] > [コマンド プロンプト]で以下を入力します。
    sqlplus protect/<パスワード>@protect
    [接続しました]
    メッセージが表示されます。
  2. 以下のコマンドを入力し、PL または SQL 関数を作成して行数を確認します。
    create or replace function
    row_count (p_tablename in varchar2)
    return number
    as
    l_count number;
    begin execute immediate
    'select count(*)
    from ' || p_tablename
    into l_count;
    return l_count;
    end;
    /
  3. 次のクエリーを実行してスキーマの各テーブルの行数を確認します。
    spool rowCount_before_export.txt
    select table_name, row_count(table_name) num_of_rows from user_tables;
    spool off
    rowCount_before_export.txt
    ファイルが実行ディレクトリに生成されます。
  4. 今後使用できるように、
    rowCount_before_export.txt
    ファイルを保存します。