Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle SQL creating table as a copy of table
Paweł wrote:
> Good evening everybody (GMT+1)
> Let's say I have a table called 'employees' and I need to create an
> identical table for retired contractors - 'contractors'.
> So what I do is:
> 1) CREATE table contractors AS SELECT * FROM EMPLOYEES;
> 2) TRUNCATE TABLE CONTRACTORS;
>
> This seems to be a severe abuse of system resources cause I copy a
> significant amount of data, just to delete it in the very next line and to
> keep only the structure.
>
> Is there any smarter way to perform this task?
>
> Thank you,
> Paweł Gałecki
It is.
CREATE TABLE contractors AS
SELECDT *
FROM employees
WHERE 1=2
But it is also a violation of normalization to create the second
table in the first place. Reconsider and do this:
ALTER TABLE employees
ADD (contractor_flag VARCHAR2(1));
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace 'x' with 'u' to respond)Received on Sun Apr 17 2005 - 12:54:54 CDT
![]() |
![]() |