In Oracle SQL Developer, if you will try to import an XML file using the Import menu option, then you will not find a choice to import as XML. There are only three options exists in Oracle SQL Developer even in the latest version 18.2, and they are CSV, Delimited and the Text format. So if you want to import an XML file, then you need to convert it first into a CSV file. The following are the steps to import an XML file in Oracle SQL developer.
Import an XML File into Oracle Table Using Oracle SQL Developer
- First, convert your XML file to CSV, by clicking on the following link Convert XML to CSV. Paste your XML file contents into the text box of the website, and then you would be able to download the CSV file. The following is the example XML and converted CSV file contents.
<?xml version="1.0" ?> <!DOCTYPE main [ <!ELEMENT main (DATA_RECORD*)> <!ELEMENT DATA_RECORD (EMPLOYEE_ID,FIRST_NAME?,LAST_NAME,EMAIL,PHONE_NUMBER?,HIRE_DATE,JOB_ID,SALARY?,COMMISSION_PCT?,MANAGER_ID?,DEPARTMENT_ID?)+> <!ELEMENT EMPLOYEE_ID (#PCDATA)> <!ELEMENT FIRST_NAME (#PCDATA)> <!ELEMENT LAST_NAME (#PCDATA)> <!ELEMENT EMAIL (#PCDATA)> <!ELEMENT PHONE_NUMBER (#PCDATA)> <!ELEMENT HIRE_DATE (#PCDATA)> <!ELEMENT JOB_ID (#PCDATA)> <!ELEMENT SALARY (#PCDATA)> <!ELEMENT COMMISSION_PCT (#PCDATA)> <!ELEMENT MANAGER_ID (#PCDATA)> <!ELEMENT DEPARTMENT_ID (#PCDATA)> ]> <main> <DATA_RECORD> <EMPLOYEE_ID>151</EMPLOYEE_ID> <FIRST_NAME>David</FIRST_NAME> <LAST_NAME>Bernstein</LAST_NAME> <EMAIL>DBERNSTE</EMAIL> <PHONE_NUMBER>011.44.1344.345268</PHONE_NUMBER> <HIRE_DATE>2005/03/24 00:00:00</HIRE_DATE> <JOB_ID>SA_REP</JOB_ID> <SALARY>9500</SALARY> <COMMISSION_PCT>0.25</COMMISSION_PCT> <MANAGER_ID>145</MANAGER_ID> <DEPARTMENT_ID>80</DEPARTMENT_ID> </DATA_RECORD> </main>
"EMPLOYEE_ID","FIRST_NAME","LAST_NAME","EMAIL","PHONE_NUMBER","HIRE_DATE","JOB_ID","SALARY","COMMISSION_PCT","MANAGER_ID","DEPARTMENT_ID" "151","David","Bernstein","DBERNSTE","011.44.1344.345268","2005/03/24 00:00:00","SA_REP","9500","0.25","145","80"
- When the file is in CSV format, you can import it by using the import option of Oracle SQL Developer. To invoke the Import window, right-click on the table in which you want to import the data and then choose Import Data option.
- In the Import Data window, specify the file in File field, choose Skip Rows 1 because CSV file has a header row. Then click on the Next button and complete all the steps as per your CSV file to import the data.