Andreas K. wrote:
> 
> In response to Ivan Sergio Borgonovo :
> > I just noticed something I found "unexpected".
> > 
> > CREATE TABLE LIKE let you specify DEFAULT and Co.
> > CREATE TABLE AS doesn't.
> > 
> > Is there a one step way to clone a table?
> 
> with or without data?
> 
> create table new_table (like old_table)
> create table new_table as select * from old_table

In addition:

CREATE TABLE new_table AS SELECT * FROM old_table LIMIT 0; -- also gets you a 
clone w/ no data

In 8.3 the (LIKE ...) construct allows for creation of indexes; in earlier 
versions I think they have to be done manually if they are desired. I think 
though that populating the table w/ indexes from a LIKE command would need an 
extra step to load data [which seems odd, seems it much faster usually to load 
data and then create indexes, etc.].

HTH,

Greg Williamson
Senior DBA
DigitalGlobe

Confidentiality Notice: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information and must be protected in accordance with those 
provisions. Any unauthorized review, use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please contact the sender by 
reply e-mail and destroy all copies of the original message.

(My corporate masters made me say this.)


Reply via email to