My goal here is to export all databases with their data into a .sql file using UTL-FILE
which I can run in the future with the help of a plsql script.
So I selected metadata for each tables and saved it to a .sql file but I am having trouble on exporting data as INSERT INTO <table_name> VALUES (...)
;
This is what I came with so far. A cursor for each table:
FOR v_i IN (SELECT OBJECT_NAME FROM USER_OBJECTS WHERE OBJECT_TYPE='TABLE') LOOP
With that cursor I can create a varchar which I can put in .sql file:
INSERT INTO v_i.OBJECT_NAME VALUES( <values> );
My biggest problem is selecting for each row of table the data in a format that would replace values in my INSERT
statement.
Here is where I blocked.How can I do it ?