Is there an easy way to clone table structure in Oracle?

If I have a table like:

CREATE TABLE FRED
(
recordId number(18) primary key,
firstName varchar2(50)
);

Is there an easy way to clone its structure (not data) into another table with the given name. Basically I want to create a table with exactly the same structure, but a different name so that I can perform some functions on it. I want to do this in code explicitly. Java is preferred, but most other languages ​​should be similar.

+3
source share
2 answers

If you are looking for a way to find the exact DDL to recreate the table, including the storage clause, you can use

select dbms_metadata.get_ddl('TABLE', 'TABLE_NAME', 'SCHEMA_NAME') from dual

as described here .

+12
source

CREATE TABLE tablename AS SELECT * FROM orginaltable WHERE 1 = 2;

: WHERE .

+6

Source: https://habr.com/ru/post/1699088/


All Articles