Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to dump table contents as SQL statements?
try the following
spool xx
select 'insert into xx (field1,field2,field3) values
('||field1||','||field2||','||field3||');' from xx;
spool off
after this you have a file called xx.log with the following statement:
insert into xx(field1,field2,field3) values(1,2,3); insert into xx(field1,field2,field3) values(1,2,4); insert into xx(field1,field2,field3) values(1,2,5); insert into xx(field1,field2,field3) values(1,2,6); insert into xx(field1,field2,field3) values(1,2,7);....
This works only with numeric fields.
With char,varchar or datefield you must put the char ' into your values
clause.
Gopal Santhanam wrote:
> Hi,
>
> How do you dump the data contents of a table as a series of sql insert
> statements? I'd like to generate a sql script file that can be later
> loaded into an empty incarnation of the same table.
>
> I know there is such an animal in for MySQL.
>
> Gopal
--
![]() |
![]() |