OracleのDDLコマンドを自動生成できる Oracle データベースでは、既存オブジェクト再作成用の SQL (DDL) を 作成するファンクションが提供されている。 実はコレ、用途によっては利用価値が高いので、目から鱗状態の人も少なくないはず。 作成するには、DBMS_METADATA.GET_DDL ファンクションを使用する。 既存オブジェクトの Create文が欲しいとき テーブルやビューなどのオブジェクトから定義を出力する DBMS_METADATA.GET_DDL。 既存オブジェクト再作成 SQL を出力できるのは、とっても便利だ。 出力フォーマットは CLOB のため、set pages と set long の設定が必要。 SQL コマンド select dbms_metadata.get_ddl('(1)','(2)','(3)') from dual; (1) オブジ