Re: Trucate Command
From: Hari (hari_prasad_k_at_hotmail.com)
Date: 05/07/04
- Next message: johndotfoxley_at_laywheelerdotcom: "Codepage mismatch I think"
- Previous message: Vishal Parkar: "RE: Trucate Command"
- In reply to: Vishal Parkar: "RE: Trucate Command"
- Next in thread: Vishal Parkar: "Re: Trucate Command"
- Reply: Vishal Parkar: "Re: Trucate Command"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 7 May 2004 16:54:13 +0530
Hi ,
The best way to deal this will be:-
1. Create a temp (original) table with the same structure
2. Insert into temp select * from real_table where date_col between
start_date and end_date
3. The second step will be fast if you have an idex on date_col
4. Truncate the original table (Truncate table table_name) -- This step will
be very fast , rather than using DELETE from
5. insert into real_table select * from temp
The above 5 steps will spped up your operation.
Thanks
Hari
MCDBA
"Vishal Parkar" <REMOVE_THIS_vgparkar@yahoo.co.in> wrote in message
news:BE30B741-0C70-4D1B-88F5-150CA4D99C92@microsoft.com...
> 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
>
>
>
>
>
- Next message: johndotfoxley_at_laywheelerdotcom: "Codepage mismatch I think"
- Previous message: Vishal Parkar: "RE: Trucate Command"
- In reply to: Vishal Parkar: "RE: Trucate Command"
- Next in thread: Vishal Parkar: "Re: Trucate Command"
- Reply: Vishal Parkar: "Re: Trucate Command"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|