hi friends...
today I am going to show you some interesting and important queries in oracle..
1.how to create table from another schema table without data?
2.how insert data in table from another schema table ?
3.how insert specific columns data in table from another schema table?
here I want to create table name empdup based on scott schema emp table..
so guys please watch these carefully..
1.how to create table from another schema table without data?
syntax:
create table tablename as select * from schema.tablename where 2=1;
Eg:create table empdup as select * from scott.emp where 2=1;
we can above example practically...so as shown in video,we have created table in hari user based scott schema emp table without data...
2.how insert data in table from another schema table ?
syntax:
insert into table_name select * from schema_name.table_name;
Eg: insert into empduplicate select * from scott.emp;
we can see this practically...so we got total rows(14) from scott schema emp table data into hari user's table empduplicate..
3.how insert specific columns data in table from another schema table?
Syntax:
insert into table_name(col1,col1,...) select col1,col2.. from schema_name.table_name;
Eg:
insert into empduplicate empno,ename,job select empno,ename,job from scott.emp;
we can also see this in practically..
first I delete total data before inserted in empduplicate..
after executing this query we got only specifice columns data into empduplicate table...
that's it guys...
thank u...
Please Subscribe n Share My Channel for Update..
/ prasadamudalapalli