Zuned Ahmed
Zuned Ahmed

Reputation: 1397

want to copy data from one table to another with added 2 new columns in oracle

i have a query in mysql

insert into a_archive ( select * , "Zuned Ahmed" as archivedBy from B);

The above query executing fine in mysql, this does not support in oracle.

please suggest.

Upvotes: 1

Views: 1311

Answers (1)

RGO
RGO

Reputation: 4737

Please use this one instead:

insert into a_archive 
select b.* , 'Zuned Ahmed' as archivedBy from B b

Explanation:

When using Oracle database:

1- To specify literal strings, single quotes '' are used. Double quotes "" serve a different purpose.

2- If * is specified without being prefixed with an alias, no other column is allowed. Otherwise, * must be prefixed with the table alias.

3- Insert ... Select ... statements follow exactly the same syntax as given above; using braces is not allowed.

Hope this will solve your problem.

Upvotes: 2

Related Questions