I would like to know how to insert data from Excel to Oracle meaning lets say i have a worksheet full of data and i want to insert them all into Oracle database.
Many Oracle IDEs offer this feature.
Oracle SQL Developer:
I talk about these features here.
Try creating Insert query in Excel(if data is not that huge):
like :
in AA1 cell write : 'INSERT INTO <TABLE> VALUES('
then respective values from different cells(i.e. 'A1,'+'B1,'...+')')
it will create Insert scripts in excel. Just copy the scripts and execute.
these are sample queries, plz write your own queries according to your requirement for INSERT STATEMENT.
You can use sql loader, but if you want a more robust solution (especially if the data will be modified directly in the spreadsheet) then look into external tables in Oracle. You can build a database table directly from the spreadsheet, the code looks like this:
CREATE TABLE YOUR_SCHEMA.YOUR_TABLE
(
ACCT_NO VARCHAR2(15 BYTE),
PRODUCT_TYPE VARCHAR2(50 BYTE),
ORGINATION_DATE VARCHAR2(20 BYTE),
MATURITY_DATE VARCHAR2(20 BYTE),
FIXED_PERIOD_START_DATE VARCHAR2(30 BYTE),
FIXED_PERIOD_END_DATE VARCHAR2(30 BYTE),
ORIGINAL_LOAN_AMOUNT NUMBER,
CURRENT_BALANCE NUMBER
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY YOUR_DIRECTORY
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
LOGFILE YOUR_DIRECTORY:'your_log.log'
BADFILE YOUR_DIRECTORY:'your_bad.bad'
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL )
LOCATION (YOUR_DIRECTORY:'your_file.csv')
)
Note that anything with the word "your" in it above must be changed to whatever you want to name your files and directories. Also note that "YOUR_DIRECTORY" is an actual database object you must create:
CREATE OR REPLACE DIRECTORY YOUR_DIRECTORY AS 'C:\workspaces\test\XL2ExternalTables'
convert your excel file format to .csv format with using save as option
Save below content in a file with .ctl extension in the D drive under folder_name folder. Before running this .ctl make sure that table should be present in your schema with the distinct column names not like in your posted image. And the column name should be match with names of .ctl file(sc_id,
sal, etc). And the datatypes of your columns should be match with the data present in a .csv file. And also make sure that your table
should be empty
otherwise you should use truncate
or append
options in your .ctl file.
LOAD DATA
INFILE 'D:\folder_name\csvfile_name.CSV'
BADFILE 'D:\folder_name\csvfile_name.BAD'
DISCARDFILE 'D:\folder_name\csvfile_name.log'
logfile 'D:\folder_name\csvfile_name.DSC'
iNTO TABLE schema_name.table_name
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(
sc_id,
sal,
sc_cd1,
coll,
sc_cd2,
bill_mas,
sc_cd3,
wk_sal,
check_bill_month,
check_sale_wk
)
Run your .ctl file in sql plus with use of below commands
sqlldr schema_name/password@databasename control=your control file path.
If any error occurs while loading data into table those will logged into .log file. For learn more about sqlloader Refer http://docs.oracle.com/cd/B10501_01/server.920/a96652/ch05.htm
Please refer for the answer. https://community.oracle.com/thread/2166713?start=0
I am just copying the approach what worked for me from above link
In Oracle sql developer go to Tables --> select import data ---> select your excel or csv file --> it will display the column --> import the data into a table.