How do I make an exact copy of a current table

Database
Enthusiast

How do I make an exact copy of a current table

Any Ideas?

Can I just
Create Table 1 as
(Select * from Table 2)
6 REPLIES
Senior Apprentice

Re: How do I make an exact copy of a current table

Definition plus data?
create table newtab as oldtab with data;

Or just the definition?
...with no data;

check the manuals for details...

Dieter
Enthusiast

Re: How do I make an exact copy of a current table

You can also try out this

Create table a as ;
Which will be the exact replica of your old table.
Enthusiast

Re: How do I make an exact copy of a current table

Sorry

rewritting the syntax

Create table a as old_table_name

sushant
Enthusiast

Re: How do I make an exact copy of a current table

The exact syntax is as below:
create table product_1 as product with data;

Re: How do I make an exact copy of a current table

To copy the table in teradata with all stats and data , can use

create table product_1 as product with data and stats;

Enthusiast

Re: How do I make an exact copy of a current table

There are two ways to approach this. 

If you are about to create the table copy, you should go with the syntax mentioned above:

Create Table DatabaseName.Table_Copy as DatabaseName.Table With Data And Stats;

If however the table copy is created with data and you want to copy the STATS afterwards, in TD 14 and above, you can use the following syntax:

Collect Stats DatabaseName.Table_Copy From DatabaseName.Table;

It is to be noted that the table definitions (Table_Copy and Table) should be the same