"Unload to" question
Posted in 2003
Ed asked whether UNLOAD TO deletes rows from a table, since it wrote the rows to a file but left them in place. Several respondents confirmed UNLOAD TO only copies selected rows to a delimited ASCII file; a separate DELETE FROM <table> [WHERE ...] is needed to remove them. One reply explained the usual archive/purge pattern: UNLOAD the rows you want to keep, save the dbschema, drop and recreate the table, then LOAD the data back — since DELETE alone frees no space for other tables. Clearly resolved.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Migration, Import/Export & Data Conversion
The reason that I was told to use the "Unload To" command is to delete thousands of rows from my table and saving them into a file. Is this the way the "Unload To" command works ? Does the command deletes those rows from the table ? Right now the command is creating my file with those rows but my table still contains those rows. Ed
Hi,
no.
"UNLOAD TO" just does what it implies - it unloads
whatever you select in the SELECT clause to an ASCII file (delimited).
That's all.
If you want the rows deleted (and only deleted but not saved), then
use "DELETE FROM <table> WHERE ... ;" where the WHERE is
optional. If no WHERE clause is given, all rows in the table will be
deleted.
The trick where the unload comes into the picture is when you don't
want to drop the table (in that case just drop it without DELETE,
saves a lot of time and log space), but you want to reclaim space.
The DELETE deletes rows from a table, but the space remains allocated
to the table. It will be re-used for data newly inserted into this same
table,
but the space cannot be used by any other table/index.
To free the space, you have to drop the table. If you still have (some)
rows in the table that you want to keep, then you have to do an
"UNLOAD TO ..." after your "DELETE ...". Then drop the table,
re-create the table (better save it's "dbschema ..." before dropping
it), then load back the data from the unload ("LOAD FROM ... INSERT ...").
That way you've re-organized the table and re-claimed the space freed by
the delete which is now available to any (other) table.
Hope that helps,
Martin
--
Martin Fuerderer
IBM Informix Development Munich
Data Management Solutions
"Gonzalez, E...." <e.gonzal@radium.ncsc.mil>
Sent by: forum.subscriber@iiug.org
04.02.2003 19:21
To: ids@iiug.org
cc:
Subject: "Unload to" question [231]
The reason that I was told to use the "Unload To" command is to delete
thousands of rows from my table and saving them into a file. Is this the
way the "Unload To" command works ? Does the command deletes those rows
from the table ? Right now the command is creating my file with those
rows
but my table still contains those rows.
Ed
The use of the "unload to" command is to put the contents of a table into a file. In addition, if you want to delete the records from the table, you need to use an sql command like "delete from table". Remember that after you have deleted the records, the only way to get them back is loading them from the unloaded file. so, you should be very careful when doing this. -----Original Message----- From: Gonzalez, E.... [mailto:e.gonzal@radium.ncsc.mil] Sent: Tuesday, February 04, 2003 12:22 To: ids@iiug.org Subject: "Unload to" question [231] The reason that I was told to use the "Unload To" command is to delete thousands of rows from my table and saving them into a file. Is this the way the "Unload To" command works ? Does the command deletes those rows from the table ? Right now the command is creating my file with those rows but my table still contains those rows. Ed
Unload command does not delete. It only dumps rows to a file. -----Original Message----- From: forum.subscriber@iiug.org [mailto:forum.subscriber@iiug.org]On Behalf Of Gonzalez, E.... Sent: Tuesday, February 04, 2003 1:22 PM To: ids@iiug.org Subject: "Unload to" question [231] The reason that I was told to use the "Unload To" command is to delete thousands of rows from my table and saving them into a file. Is this the way the "Unload To" command works ? Does the command deletes those rows from the table ? Right now the command is creating my file with those rows but my table still contains those rows. Ed
'Unload to' only unloads the rows to a flat file. It doesn't delete anything from the table. > -----Original Message----- > From: Gonzalez, E.... [mailto:e.gonzal@radium.ncsc.mil] > Sent: Tuesday, February 04, 2003 1:22 PM > To: ids@iiug.org > Subject: "Unload to" question [231] > > > > > The reason that I was told to use the "Unload To" command is to delete > thousands of rows from my table and saving them into a file. > Is this the > way the "Unload To" command works ? Does the command deletes > those rows > from the table ? Right now the command is creating my file > with those rows > but my table still contains those rows. > > > > > Ed > "CONFIDENTIALITY NOTICE: This message originates from WHSmith USA Travel Retail. This email message and all attachments may contain legally privileged and confidential information intended solely for the use of the addressee. If you are not the intended recipient, you should immediately stop reading this message and delete it from the system. Any unauthorized reading, distribution, copying, or other use of this message or its attachments is strictly prohibited. All personal messages express solely the sender's views and not those of WHSmith USA Travel Retail. This message may not be copied or distributed without this disclaimer."
unload doesn't delete the rows from the table...just copies them out. |---------+----------------------------> | | "Gonzalez, E...."| | | <e.gonzal@radium.| | | ncsc.mil> | | | Sent by: | | | forum.subscriber@| | | iiug.org | | | | | | | | | 02/04/2003 11:21 | | | AM | | | | |---------+----------------------------> >------------------------------------------------------------------------------- ----------------------------------------------| | | | To: ids@iiug.org | | cc: | | Subject: "Unload to" question [231] | | | >------------------------------------------------------------------------------- ----------------------------------------------| The reason that I was told to use the "Unload To" command is to delete thousands of rows from my table and saving them into a file. Is this the way the "Unload To" command works ? Does the command deletes those rows from the table ? Right now the command is creating my file with those rows but my table still contains those rows. Ed