In a previous post, How to Import from Excel to Oracle with SQL Developer, I covered step-by-step how to import data from Excel to an existing Oracle table. This post shows how to take a spreadsheet and transform it into a new table in your Oracle database.
But first, please permit me just a few seconds as I step up to my bully-pulpit:
Please do not import data to Excel just because you know SQL better than Excel functions and macros.
Everything has a cost. If you can keep your ad-hoc queries local to your machine and your spreadsheet, that’s a win for everyone. However, if you wan to put your data in Oracle anyway, then who am I to argue? So without much further ado, here’s what you need to know to load your data. And I promise – no more preaching, mostly.
Sample Data
For this exercise I’m taking some data from HR.EMPLOYEES and sending it to a new table. I’m purposely querying the data out in a different column order than the original source.
SELECT DEPARTMENT_ID, MANAGER_ID, HIRE_DATE, FIRST_NAME, LAST_NAME, EMAIL, SALARY, COMMISSION_PCT, PHONE_NUMBER, JOB_ID, EMPLOYEE_ID from EMPLOYEES
Obviously if your data is already in a table somewhere, it’s always going to be better to load it to a new table via a Create Table As Select (CTAS.) Even going across a DB_LINK may be more efficient than writing to Excel and then loading it back to Oracle. For this tutorial I’m assuming your data ONLY exists in Excel before getting started.
Step One: Connect to Your Database as the New Table Owner
You can only invoke the ‘Import Data…’ wizard from your connection owner schema. Of course if the table already exists, you can simply load your data by mouse-right-clicking on said table.
Step Two: Find the ‘Table’ Node and Access the Context Menu
Step Three: Select ‘Import Data…’
It says ‘Import,’ but we’ll also be creating a new table for the data to be stored in.
Step Four: Step Through the Wizard
You get to answer a few questions. Don’t like wizards? You could always script out this process yourself using SQL*Loader.
Load the file
Point to your XLS, XLSX, or CSV file.
Preview the data
Depending on the size of your spreadsheet, it may take a few moments to load up the preview dialog. This step exactly mirrors the data preview from my earlier post. However, a few things to note:
- The ‘Header’ tell the tool that there IS a header and not to include the first read row as data
- Skip rows – how many rows to skip. If your header line doesn’t appear until row 5, you’ll want to skip 4 rows
- You can load the data from any worksheet, we’ll default to the first one though

‘Header’ and ‘Skip’ controls are independent controls. Skip tells how many rows to go before we get to the header.
Name Your Table
There are a few options here. You can generate a script to create the table and then populate the table via INSERTs. Use this option if you want to preview or approve what’s going to be happening in your database. You can also tell SQL Developer to only load a specific number of rows.
Choose Columns
This step is important. Your spreadsheet may have 30 columns, but you only want to import 10 of them. Select the 10 columns you want to form the new table. Also, add them to the ‘Selected Columns’ panel in the ORDER you want them created in the new table.
Column(s) Definition
If there’s a wizard you don’t want to blindly click through, this one definitely qualifies. But if you’re asleep at the wheel, PLEASE make sure you’re paying attention when it comes to defining the columns. Two things to be aware of:
- We’re defaulting the columns to strings (VARCHAR2s)
- We’re defaulting the size to the max length of the data previewed
For point #1, we’re looking to have a better ‘guessing’ scheme for upcoming versions. But there’s no bigger problem in applications and data quality today than developers storing dates as strings or numbers. Be sure the datatype for each column is appropriate. If in doubt, consult your data model. If you don’t have a data model, consider taking a step back and creating one. I know, I know, I said I wouldn’t be preaching anymore. Sorry.
For point #2, there might be values that exceed this length. Size the columns appropriately based on your data model and application specifications.
Verify Your Parameters
This step is voluntary, but I recommend you always use it. It will help you catch date columns defined with missing or invalid date formats.
Finish!
SQL Developer will either create the table and load the data, or will will generate the create and insert scripts.






Twitter
RSS
GooglePlus
Facebook
Nov 20, 2012 @ 13:18:36
I am new to Oracle. Googled the topic of “how to import from excel to new oracle table”. Worked like a charm!! Great instructions and displays. I have passed your site on to a few experienced co-workers who appreciated the tip.
Thanks!! I have bookmarked you for future use.
Nov 20, 2012 @ 13:25:34
Thanks Bill! Appreciate the note and appreciate even more you sharing this with your colleagues. If anyone in…Albany?…has any questions about SQL Developer, feel free to drop me a line and I’ll see what I can do!
Jan 03, 2013 @ 13:25:36
Hi Jeff. Is there any limitation on the size of the excel that i can import? we are facing an issue for files greater than 3 MB in size. We have around 1.6 Million records, so was wondering the best way to upload it in the Oracle tables.
Jan 03, 2013 @ 13:30:13
Yes – you’re probably exhausting the memory available to the JVM. This same limitation exists when writing out the XLS files using SQL Developer. You can tell SQL Developer when it starts to grab more memory using this flag – edit your sqldeveloper.conf file -
AddVMOption -XX:MaxPermSize=2048M
This would give you a full 2 GB of memory and might be enough to read in all that data…BUT
But, there’s a better way.
Save your XLS file as a CSV file.
Then use the wizard. And be sure to use the SQL*Loader option vs INSERT. It will be MUCH more efficient in loading the data, and the database will thank you
For our next version of SQL Developer we’re looking to upgrade the component we use for the Excel stuff so the memory bottleneck wont’ be there anymore.
Jan 29, 2013 @ 12:21:02
Jeff, congratulations for your blog, it’s very helpful.
One thing I consider would be useful for next versions, is the wizard auto-discovering field size. I often receive large excel data from customers, and have no idea what should be field size because the data varies a lot.
Though I have a workaround using max and length excel functions at the bottom of the columns, nothing is easier than have nothing to do.
You mentioned a better “guessing” scheme for identifying data type, so if possible please consider my suggestion also.
Thank you.
Feb 21, 2013 @ 04:23:26
Hi,
Data is coming in excel file format for every day.
Example:
abc_19022013.xls
abc_20022013.xls
abc_21022013.xls …. so on.
So I created table and inserting data by using import option in sql developer every day as per blog.
I would like to schedule and automate the insertion process by using sql developer.
Please let me know the solution.
Feb 21, 2013 @ 13:53:58
Check out my post on using SQL Developer to create SQL*Loader runs based off spreadsheets. Once you have that going, consider an OS job that kicks off that script on demand or on schedule.
Mar 27, 2013 @ 20:11:27
Hey Jeff I have a problem: I cant seem to get past the column definition step because of my column names. A pop up box with the message “Validation Failed: The following new table columns have invalid names:” Meanwhile, there is no listing of such faulty names under the message. These are the changes I made to the names from my Excel table (with the original names in parentheses):
:ruoul (REVOLVING UTILIZATION OF UNSECURED LINE)
age (untouched)
numoftdpdnw ( Number Of Time 30-59 Days Past Due Not Worse)
Debt Ratio (lowered the captial letters)
MonthlyIncome (untouched)
numofoclal (Number Of Open Credit Lines And Loans)
numtdl (Number Of Times 90 Days Late)
numrelol (Number Real Estate Loans Or Lines)
numoftimedpdnw (Number Of Time 60-89 Days Past Due Not Worse)
Numofdependents (NumberOfDependents)
Please help! Thanks!
Mar 27, 2013 @ 20:16:00
Osazee,
Can you email your spreadsheet – just the headers and one row of data will suffice. Then I can take a look at it for myself.
Quick glance, the ‘:’ in the first column is probably the issue. Try quoting it if you really want the ‘:’ in your column name. Also, no space either, so Debt Ratio should be either DebtRation or “Debt Ratio”
You’ll be better off w/o using quoted column headers if you can get away with it.
Thanks,
Jeff
jeff.d.smith@oracle.com