What setting should I change to make Teradata replace existing tables with CREATE TABLE
query?
Currently, if the table exists, an attemps to CREATE
it results in error. So I have to DROP
the table before CREATing it.
thx
What setting should I change to make Teradata replace existing tables with CREATE TABLE
query?
Currently, if the table exists, an attemps to CREATE
it results in error. So I have to DROP
the table before CREATing it.
thx
REPLACE PROCEDURE DROP_IF_EXISTS(IN table_name VARCHAR(60),IN db_name VARCHAR(60))
BEGIN
IF EXISTS(SELECT 1 FROM dbc.tables WHERE databasename=db_name AND tablename=table_name)
THEN
CALL DBC.SysExecSQL('DROP TABLE ' || db_name ||'.'|| table_name);
END IF;
END;
And in your DDL script:
call drop_if_exists('$your_table_name','$your_db_name')
;
database $your_db_name;
create table $your_table_name ...
;