SQL create table use %type at column

Based on your updated requirements, to create a table based on the types in these two tables:

create table t1 (col1 number, col2 varchar2(2), col3 date);
create table t2 (col1 varchar2(10 char));

You can just join them together, with a filter that always evaluates to false as Orangecrush suggested:

create table tb tablespace users as
select t1.col1 as col1, t1.col2 as col2, t1.col3 as col3,
    t1.col3 as col4, t2.col1 as col5, cast(null as varchar2(12 byte)) as col6
from t1
cross join t2
where null is not null;

Normally a cross join would be unwelcome, but the optimizer is clever enough to realise that the filter means it doesn't need to actually hit the tables at all. You can use a normal inner join if there are fields you can join on though, of course.

desc tb

Name Null Type              
---- ---- ----------------- 
COL1      NUMBER            
COL2      VARCHAR2(2)       
COL3      DATE              
COL4      DATE               -- new column with same type as t1.col3
COL5      VARCHAR2(10 CHAR)  -- column from other table
COL6      VARCHAR2(12)       -- new column with fixed type

You could create the table with:

CREATE TABLE TBTestBackup AS 
SELECT colum1, column2, column2
FROM user.TBTest

Based on your edit: You can change the select statement to anything you like. Join the two tables and select 3 columns from one table and 2 from the other one


You can use the statement to create the backup.

CREATE TABLE TBTestBackup AS SELECT * FROM ORIGINAL_TABLE_NAME WHERE 1=2;

This is assuming that you do not want the data in the backup table. If you do want the data as well, just remove the WHERE condition from the above statement.