-- Two tables for data copying, the most common copy statement
-- Insert into select and select info from
-- Select info from cannot be used in Oracle for a simple reason
-- Select into is a value assignment statement of PL/SQL language.
-- If used, Oracle throws an ORA-00905: Missing keyword exception
-- But this function can be replaced by create table select.
Create Table
(
Id varchar2 (20 ),
Name varchar2 (20)
)
Create Table B
(
Id varchar2 (20 ),
Name varchar2 (20)
)
Insert into a values ('1', 'A ');
Insert into a values ('2', 'B ');
Insert into a values ('3', 'C ');
Select * from
-- Select * into B from
-- Delete table B first. The new table is created during execution and cannot exist in advance.
Create Table B as select * from
Select * from
Select * from B
-- When the insert into SELECT statement is used, table B must exist in advance.
Insert into B select * from
Summary:
We recommend that you use insert into select to copy data;
When using insert into select, if an ID sequence value is generated for the copy table, you must query the sequence in the SELECT statement and insert the copy table;