Teradata rename table if exists -


i'm using teradata. i'd rename table script sql , not using bteq, if specific conditions satisfied.

in particular:

if table_a exists => rename table table_b table_b_old

in sql server:

if object_id('table_a', 'u') null  exec sp_rename 'table_b', 'table_b_old';  

in oracle:

declare         cnt number;         begin              select count(*) cnt sys.user_tables table_name = 'table_a'              if cnt>0                 execute immediate 'rename table table_b table_b_old';             end if;         end;   

how can made teradata,

thanks

fabio

assuming you're on relatively modern version of teradata, can in sql assistant (or bteq):

select count (*) dbc.tablesv tablename = '<your table>' , databasename = '<your db>' having count (*) > 0;  .if activitycount = 1  .goto renametable; .if activitycount <> 1  .quit;  .label renametable  rename table <your table> <your new name; 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -