The ORACLE tutorial is: Oracle 9i allows you to easily obtain DDL statements for table creation and index creation. We all know that before 9i, It is very troublesome to obtain statements for creating tables and indexes. We usually use export with rows = no, but its output cannot be used directly due to format issues. Another method is to write complex scripts to query data dictionaries. However, for a slightly complex object, such as IOT and nested tables, it still cannot be found.
It is often used to obtain DDL statements from the data dictionary, especially when the system is upgraded/rebuilt. In Oracle 9i, we can directly investigate DDL statements from the data dictionary by executing dbms_metadata. With this powerful tool, we can obtain DDL statements for a single object or the entire SCHEMA. It is best because it is easy to use.
1. How to obtain a single table and index DDL statements:
Below is the output. We only need to extract the table creation/index statement and add a semicolon to it to run it directly.
2. method for obtaining the entire schema ddl statement:
Note that when our table has external keys (reference constraints), we need to determine the order between reference tables to ensure that the reconstruction is performed in a reasonable order. You can query dba_constraints and dba_cons_columns to determine the order between tables.