Requires Free Membership to View
Use the data dictionary view DBA_TAB_COLUMNS. Write a procedure that queries for OWNER, TABLE_NAME and COLUMN_NAME (ordered by OWNER, TABLE_NAME and COLUMN_ID). The proc should loop through all rows of the query and concatenate the values together to form the first part of the insert statement (INSERT INTO <table> (<column list>) VALUES ). Then, as you loop through and get to the end of one table, you would have an interior loop that would select * from the table you just built the INSERT for and concatenate all the values into the values clause. Once you've got the whole INSERT built, write it out to a file (use UTL_FILE) or some other method of your choosing to save the created statement.
This is just the idea for you to follow; you'll obviously need to work through the actual code yourself.
For More Information
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
This was first published in December 2002
Join the conversationComment
Share
Comments
Results
Contribute to the conversation