How to use Excel to operate Oracle

Source: Internet
Author: User

Have you ever thought about a problem? Excel is the most commonly used tool to store data. However, when the number of data items is too large, it may be inconvenient to query. Can you connect Excel with a database to facilitate data use? This article describes how to import data from an Excel table to Oracle. When we import data to Oracle, can we use Excel to update and maintain the data? This article will also tell you a method.

First, we provide an indirect idea:

Using the close relation between SQL Server and Excel, the OpenDataSource method is used in SQL Server to read Excel, and the data is spelled as an oracle-compliant SQL statement.

(OpenDataSource must be manually enabled for SQL server2005. For SQL server2005, choose "configuration tool"> "peripheral application configurator"> "peripheral application configurator"> "Database Engine"> "Impromptu remote query, as shown in)

Run the following code in SQL server:

Note:

1) provide the correct file path and Sheet name;

2) Close the Excel file to be read; otherwise, an error is reported;

3) Make sure that the field corresponding to the to_date function is of the date type in Excel;

Insert and update Orcale in Excel

 
 
  1. SELECT 'Update userinfo set Useducation = '''
  2. + Case when [current educational level] is null then''
  3. ELSE [current education level] END
  4. + Case when [technical level] is null then''
  5. ELSE ''', Usskilllevel = ''' + [technical level] END + ''''
  6. + Case when [Joining Parties] is null then''
  7. ELSE ', Usdangtuantime = to_date (''' + CONVERT (VARCHAR (12), [Joining Parties], 110) + ''', ''mm-dd-yyyy '') 'end
  8. + Case when [inbound working date] is null then''
  9. ELSE ', Usinputtime = to_date (''' + CONVERT (VARCHAR (12), [inbound working date], 110) + ''', ''mm-dd-yyyy '') 'end
  10. + Case when [Date of Birth] is null then''
  11. ELSE ', Usbirthdate = to_date (''' + CONVERT (VARCHAR (12), [Date of Birth], 110) + ''', ''mm-dd-yyyy '') 'End
  12. + 'Where Uscardid = ''' + [ID card number] + ''';'
  13. From opendatasource ('Microsoft. Jet. OLEDB.4.0 ',
  14. 'Data Source = D: \ gongren.xls; Extended Properties = Excel 8.0 ')... [Sheet1 $]
 
 
  1. ----- The execution result is as follows :-----
  2. View sourceprint?
  3. Update userinfo set Useducation = 'medium specialization', Usinputtime = to_date ('12-25-2000 ', 'Mm-dd-yyyy'), Usbirthdate = to_date ('09-06-1976 ', 'Mm-dd-yyyy') where Uscardid = '000000 ';
  4. Update userinfo set Useducation = '', Usskilllevel = 'intermediate work', Usdangtuantime = to_date ('07-11-2000', 'Mm-dd-yyyy '), usinputtime = to_date ('07-01-2003 ', 'Mm-dd-yyyy'), Usbirthdate = to_date ('08-21-1979 ', 'Mm-dd-yyyy ') where Uscardid = '20140901 ';
  5. Update userinfo set Useducation = '', Usskilllevel = 'Senior employee', Usdangtuantime = to_date ('07-03-2001 ', 'Mm-dd-yyyy '), usinputtime = to_date ('01-01-2005 ', 'Mm-dd-yyyy'), Usbirthdate = to_date ('10-26-1980 ', 'Mm-dd-yyyy ') where Uscardid = '20140901 ';

Execute the above Code in pl/SQL.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.