Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Tue, 13 Jul 2004 @ 13:01:00 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: If Exists Then ...Else ....
From:   Michael Larkins

Hi Allan:

In Teradata we do not bother to test if something needs to be done, we normally just do it. Then, we can test the outcome of the operation to determine whether or not it worked. As in using BTEQ:

     DROP TABLE my_table;
     .if errorcode = 0 then .goto continuer
     < any SQL or BTEQ code here for DROP not working, including a .QUIT with return-code >
     .label continuer
     < more SQL or BTEQ code here for DROP working >

However, if you are attempting to delete all the rows from the table, DROP TABLE is not what you want to use. In Teradata, it is much faster to DELETE FROM my_table than it is to DROP TABLE my_table. Unlike some databases that over-write the data when you do a DELETE and simply make it inaccessable when you DROP, Teradata makes the data inaccessable when you DELETE. Plus, a DROP must update like 5 Data Dictionary tables to DROP a table.

Hope this helps,

Michael Larkins
Certified Teradata Master

  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016