I have a ddl script to create some tables but the data is in .ctl files and I never use it before. I did some researches but I didn't quite understand how to use SQLLDR. How it works? Can I use some other way to execute the .ctl file? I'm just using PL/SQL and Oracle 10G
The way you put it, it would go like this:
using DDL script, create all those tables
if CTL files contain data, I presume it is within the BEGINDATA section. Fine, couldn't be better because - as soon as you run the loader, it'll know where to find data to be loaded (it also means that control file uses infile *, right?)
you have to have access to SQL*Loader
if you can connect to the database server, it is there
if you're using your own PC, see whether it is installed
along with the Client software
or, you might even have a database on your PC (XE?)
once you have it (the sqlldr.exe), make sure its directory is contained with the PATH environment variable, or - if not - invoke it by specifying the whole path to it
open command prompt of your operating system
navigate to directory that contains CTL files
run the loader as
sqlldr scott/tiger control=file1.ctl log=file1.log
If everything is OK, data will be loaded. Check log files!
Related
As I don't see a parameter for a directory like impdp, where does imp search for the dump files that are specified by the FILE parameter?
I've searched through the Oracle's documentation for the original import utility and I don't see anything that says where it searches for the dump files.
Original Import Documentation
imp is an operating system utility and is invoked from operating system command prompt. By default, it searches for the file in current directory (the one you're in while running the imp executable).
If you specify the path to the file, then it is obvious.
If you used more recent Data Pump Import, then you'd have to specify the directory parameter which points to a directory, Oracle object that points to a file system directory. It is usually located on the database server. Directory (the Oracle object) is owned by SYS who then grants read and/or write privileges to database users who will be using that directory.
Everything above means that: imp can use dump files locally, while - for the Data Pump utilities - you don't even have to have access to the physical directory; someone else (such as a DBA) might manipulate files, put them into (filesystem) directory so that you could use them.
I have dbf files from my client oracle database. Their admin said that is buckup of database. I am trying to opening those files in different editors like open office, excel, dbf manager and others, but it cannot be done because during this action it always says file has incorrect format, or file has incorrect header.
I read a little and it seems that was wrong backup of database or something. I have 7 dbf files and none of them works.
I just want to open those files and make import to csv/excel to export it to new system with sql database
I wish to import data from excel into oracle table.
But my requirement is I Have multiple excel files and each file contains multiple sheets.
But all have the same structure.
Please let me know the suitable way to perform the same.
Can UTL_FILE utitlity be used to perform this extraction.
I don't know how to do it directly from Excel.
Actually, I do, but manually, using TOAD's "Import table data" option. I also don't know what technique stands behind the scene, can only guess:
- it is first temporarily saved as CSV and then loaded
- Excel files are XML so TOAD manipulates such a data
How would I automate it?
save each worksheet into its own CSV file
manual job for me as well. Maybe someone - who knows Excel far better - can write a VBA script or something like that. On the other hand, maybe it is possible to use such a script to directly insert data into an Oracle table ... no idea, sorry
write a SQL Loader control file
load file-by-file, reusing the same control file
how to automate that? Use SQL Loader command line DATA parameter.
how to change it dynamically? Create a wrapper script (on MS Windows, that would be a .BAT script) which would - in a loop - iterate over all those CSV files and feed SQL Loader with new data in every iteration
SQL Loader+s advantage over UTL_FILE (you mentioned) is that
it works locally (on your own PC; you have to install it, of course (if you don't have it already). It comes along with any Oracle database (even XE, Express Edition), or is contained in Oracle Client software under its Utilities), while
for UTL_FILE you have to speak to your DBA in order to get access to the directory (usually located on the database server) which would be then used by the named package.
I created a directory using SQLPlus console but I cant find it on file system. Here is the command I used:
SQL> create directory secfile as ’/opt/oracle’;
Directory created.
I have looked in my Oracle home directory(C:\Program Files (x86)\Oracle) but there is no 'images' folder.
Where should I look for it?
I'm using Oracle 11g Data Base(installed on my C drive) and I need this directory to store pictures which I will be further storing in the data base. I was following a tutorial about storing pictures on OracleDB in which ’/opt/oracle’ patch were used for that directory.
You have things the wrong way around. You need to create a directory in the operating system, and then create an Oracle directory object using the full path to the operating system directory. The Oracle create directory command only creates a data dictionary object, it does not itself do anything on your server's file system. And you can't use a relative path.
Well, you can create them in either order, but the operating system directory has to have been created by the time you try to use the Oracle one, so to me it makes more sense to create that first.
The CREATE DIRECTORY command does not create a directory on your server's disc. It creates a directory object in your Oracle database which serves as a "pointer" (if you will) to a directory on your disc, and until some code running in your database (for example, some PL/SQL code) tries to use the directory object the database will not know or care if the directory actually exists on the disc. YOU have to create the disc directory, using either Windows Explorer or the Windows command line.
Best of luck.
This should be simple, but what is the correct syntax for an Oracle sqlldr control file in order to specify tab delimited/separated data?
FWIW, I found the file was UTF16 and not UTF8, and was editing fine but would introduce null bytes as Oracle read the control file. Can't even replicate today.
Per this thread, it should be fields terminated by '\t' (don't have an Oracle installation at hand to verify that this is correct).