Export and Import csv files from Oracle database tables

Source: Internet
Author: User

The database is Oracle 9i

1. Export a csv file

This is very simple. You can use the pl/SQL tool. First, select the table to be exported, right-click Query data, and in the window that appears on the left, select Export Query Restls and select the file type to Export. Generally, the csv format is exported.

2. Import csv files

In the analogy database, the t_province Field 1: province Field 2: city

CSV file storage path: f: \ test.csv column must be consistent with the database

You also need to write a test. ctl file with the following content:

Load data

Infile 'f: \ city .csv'

Into table "T_PROVINCE"

Fields terminated ','

(Province, city)

Then under cmd, enter: sqlldr userid = clevergirl/clevergirl@ORCL_192.168.128.129 control = f: test. ctl and press Enter.

3. Notes

At first, I wrote sqlldr control = f: \ test. ctl log = f: test. log.

SQL * Loader-704: Internal error: ulconnect: OCIServerAttach [0]

ORA-12560: TNS: protocol adapter error.

I checked it online and said it was related to the environment variable. It can be modified.

Then I am afraid that the permissions are not enough, so log on directly with the sys User: sqlldr userid = sys/sys@ORCL_192.168.128.129 control = f: test. ctl

Reported: SQL * Loader-128: unable to start session

ORA-28009: connection to sys shoshould be as sysdba or sysoper

After the above is changed to the correct one, another

SQL * Loader-941: An error occurred while describing the table "t_province ".

ORA-04043: the object "t_province" does not exist

The problem with this error lies in the ctl file, where the table name must be capitalized before OK.

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.