9.30.2010

Different Insert Options

Q: How to Insert all/filtered data from Table1 to Table2?

select count(*) from INDIVIDUAL1;
DROP TABLE INDIVIDUAL2;
create table INDIVIDUAL2 as select * from INDIVIDUAL1 where 1=2; --create table without data (use a invalid condition)

INSERT INTO INDIVIDUAL2 SELECT * FROM INDIVIDUAL1;
COMMIT;
select count(*) from INDIVIDUAL2;

Q: How to Insert all/filtered data from Table2 to Table1, where id will be different?
SQL> show user
USER is "schema1"
SQL> insert into Table1(id,file_name,content,field_name)
(select SEQUENCE.NEXTVAL, file_name, content, NOTES_FIELD_NAME from schema2.table2);