-
Junior Member
Re: Move columns from different tables to one table
There are 2 condition for create table which consist of columns from 2 table
1. Table having common column to join 2 table
2. Table not having common column to join 2 table
If there is a linking column (common column on the basis of which 2 tables can be connected) between 2 table then u can create table like this
create table dept_emp as
select dept.dname, emp.ename
from emp, dept
where emp.deptno = dept.deptno;
If 2 table from which column is to be taken are not having same column
then u need to use joins
--say for example i have 2 table
create table t1 (num1 number, num2 number);
insert into t1 values(1,1);
insert into t1 values(2,2);
insert into t1 values(3,3);
insert into t1 values(4,4);
create table t2 (str1 varchar2(20), str2 varchar2(20));
insert into t2 values('a','a');
insert into t2 values('b','b');
insert into t2 values('c','c');
insert into t2 values('d','d');
-- To create table with data
create table t1_t2 as
select num1,NULL str1 from t1
UNION
select NULL,str1 from t2;
select * from t1_t2;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules