简体   繁体   中英

import data from excel to oracle database table

i have excel file which have following column NAME RICE SUGAR TEA.i want to import all data into my oracle database please see image below. EXCEL文件数据格式

ORACLE 数据库表结果

Assuming your data is in the range A2:D5 then you can put the formula below into E3 and copy it across the range E3:G5 :

="INSERT INTO table_name ( name, item, quantity ) VALUES ( '" & $A3 & "', '" & B$2 & "', " & B3 & ");"

Then just copy the generated SQL statements and run them in Oracle.

You could also import the data using SQL Developer and then use a query with UNPIVOT to transform columns to rows but for this small a volume of data I would not bother.

Something like:

SELECT name, item, quantity
FROM   your_imported_table
UNPIVOT ( quantity FOR item IN ( RICE, TEA, SUGAR ) )

Why you want to import data from excel to Oracle. Create external table using excel and use it. It is best way to use new feature of Oracle. You can join both table for running report or queries. If you change excel (or dump more data in excel sheet) then no need to create again external table because it automatically takes effect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM