RE: Trucate Command

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 05/07/04


Date: Thu, 6 May 2004 19:41:03 -0700

hi garry,

>>Can I use the truncate command???

No, Truncate table command removes all rows from a table.

>>Can I use it to bring the temp_table data back to the original table
with out reprocusions? <<

No, you can not do any kind of recovery using truncate table command. use "truncate table" command to remove all the rows from the table.

What you need is INSERT INTO....SELECT statement. By which you can transfer the rows from both the tables.
The SELECT query in the INSERT statement can be used to add values into a table from one or more other tables.

A typical select... into syntax will look as follows.

1)
INSERT INTO destination_table(col1,col2)
   SELECT col1,col2
   FROM <source_table>
   WHERE .....

2)
once you transfer the rows to the temp table. you can delete the rows from original table using

DELETE FROM table where..... syntax.

3)
To transfer rows back to the original table from temp table you can use same INSERT INTO....SELECT syntax.

-- 
Vishal Parkar
vgparkar@yahoo.co.in | vgparkar@hotmail.com


Relevant Pages

  • Re: how to shrink the .LDF ? -- spanish subtitled
    ... DBCC SHRINKFILE is not a truncate command. ... Commmand to truncate the Log is BACKUP LOG command. ...
    (microsoft.public.sqlserver.setup)
  • Re: [Info-Ingres] commit question
    ... The next block has been turned into a rollback ... hence the next command executed is the rollback and not the commit. ... The situation we had was that the "modify to truncate" command succeeded ...
    (comp.databases.ingres)
  • Re: Trucate Command
    ... Insert into temp select * from real_table where date_col between ... Truncate the original table -- This step will ... you can not do any kind of recovery using truncate table command. ... into syntax will look as follows. ...
    (microsoft.public.sqlserver.mseq)
  • SUMMARY: Question on why ps sometimes truncates the process name and puts it in brackets
    ... Why does the ps output sometimes truncate the process name and put it in ... Thanks to Dr. Blinn for the following thorough answer: ... command, especially if there are a lot of processes on the system). ... because there is a temporary shortage of the in-memory buffer size ...
    (Tru64-UNIX-Managers)
  • Re: Means of trimming files
    ... > presuming it is always just one newline character at the end. ... Well although I can use a bit of perl within php, trying it via the command ... But your suggestion on using 'truncate -s -1 z.php' worked as I would like it. ...
    (freebsd-questions)