Location of the table space files? - oracle

How can I find the directory in which oracle stores it's table space files?
When I do: select * from dba_data_files; or select * from v$datafile; then I get some paths like that:
+DATA01/fu/datafile/bar_ts01_data.260.264360912
But what means +DATA01? And where is that exactly in the file system?

+DATA01/fu/datafile/bar_ts01_data.260.264360912
Yes this is correct file path. It means you use ASM disk.
After you login to OS with "grid" user [usually Oracle Grid Infrastructure installation user is named like that], run following command to browse files on ASM disk.
export ORACLE_HOME=/u01/app/11.2.0/grid --this is also usual installation dir, may differ on your case
export ORACLE_SID=+ASM
cd $ORACLE_HOME/bin
./asmcmd -p
ASMCMD>ls
+DATA01
+DATA02
ASMCMD>cd +DATA01

In that table, the file_name field should give the full path to the datafile.
Also, try select * from v$datafile; and that view should help as well.

Related

sql loader without .dat extension

Oracle's sqlldr defaults to a .dat extension. That I want to override. I don't like to rename the file. When googled get to know few answers to use . like data='fileName.' which is not working. Share your ideas, please.
Error message is fileName.dat is not found.
Sqlloder has default extension for all input files data,log,control...
data= .dat
log= .log
control = .ctl
bad =.bad
PARFILE = .par
But you have to pass filename without apostrophe and dot
sqlloder pass/user#db control=control data=data
sqloader will add extension. control.ctl data.dat
Nevertheless i do not understand why you do not want to specify extension?
You can't, at least in Unix/Linux environments. In Windows you can use the trailing period trick, specifying either INFILE 'filename.' in the control file or DATA=filename. on the command line. WIndows file name handling allows that; you can for instance do DIR filename. at a command prompt and it will list the file with no extension (as will DIR filename). But you can't do that with *nix, from a shell prompt or anywhere else.
You said you don't want to copy or rename the file. Temporarily renaming it might be the simplest solution, but as you may have a reason not to do that even briefly you could instead create a hard or soft link to the file which does have an extension, and use that link as the target instead. You could wrap that in a shell script that takes the file name argument:
# set variable from correct positional parameter; if you pass in the control
# file name or other options, this might not be $1 so adjust as needed
# if the tmeproary file won't be int he same directory, need to be full path
filename=$1
# optionally check file exists, is readable, etc. but overkill for demo
# can also check temporary file does not already exist - stop or remove
# create soft link somewhere it won't impact any other processes
ln -s ${filename} /tmp/${filename##*/}.dat
# run SQL*Loader with soft link as target
sqlldr user/password#db control=file.ctl data=/tmp/${filename##*/}.dat
# clean up
rm -f /tmp/${filename##*/}.dat
You can then call that as:
./scriptfile.sh /path/to/filename
If you can create the link in the same directory then you only need to pass the file, but if it's somewhere else - which may be necessary depending on why renaming isn't an option, and desirable either way - then you need to pass the full path of the data file so the link works. (If the temporary file will be int he same filesystem you could use a hard link, and you wouldn't have to pass the full path then either, but it's still cleaner to do so).
As you haven't shown your current command line options you may have to adjust that to take into account anything else you currently specify there rather than in the control file, particularly which positional argument is actually the data file path.
I have the same issue. I get a monthly download of reference data used in medical application and the 485 downloaded files don't have file extensions (#2gb). Unless I can load without file extensions I have to copy the files with .dat and load from there.

Creating directory objects in Oracle 11g with relative path

I'm using JDBC to create a directory object in the database.
i.e create or replace directory "dir" as 'c:\temp';
My question is:
I want to pass the path at runtime
Or at least specify path relative to current one. I mean : create or replace "dir" as './../tempdir'
Is there a way to do this or is specifying absolute path the only way out.
From Oracle Doc:
path_name Specify the full path name of the operating system directory
of the server where the files are located.
I think this is because there is no such thing as "current directory". (You are in database, not in command line :) )
You can post a question with your problem and you'll get help from community.

UTL_FILE, UTL_FILE_DIR and DIRECTORY, how do they affect UTL_FILE.FREMOVE?

FREMOVE is failing with an error "ORA-29280: invalid directory path"
It works fine when I add the path to the UTL_FILE_DIR and restart the database.
This is regardless of having the directory as an Oracle directory with both READ and WRITE granted.
When using UTL_FILE you have one of two options:
Option 1: UTL_FILE_DIR must have the directory you want to use in the parameter. If it's not there it will not work. The downside is that anytime you need this parameter changed or added to you need to bounce the database. With this method the first parameter of UTL_FILE.FREMOVE will be passed the actual OS directory.
Option 2: you alternatively use an oracle Directory object. You would use the directory object name (not the actual OS directory) in the first parameter of UTL_FILE.FREMOVE
References:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm
http://www.sc.ehu.es/siwebso/KZCC/Oracle_10g_Documentacion/server.101/b10755/initparams223.htm
What is the syntax you're using for FREMOVE parameter location? For a directory, you pass in the name of the Oracle Directory object, case significant.

How to move a text file using Oracle

I have two questions.
(1) how to make move text file from folder:
C:\Data\inbox\test.txt
to target Folder?
C:\Data\outbox\test.txt
(2) how to make get list of directory files in Folder?
C:\Data\inbox\
Thank you...
Oracle provides a package of utilities for working with files, UTL_FILE. Since 9i this has included the FRENAME() procedure, which works like the unix mv command. We can use it to rename the file and/or its directory. Note that the Oracle os account must have read and write privileges on both directories. Also this procedure uses DIRECTORY objects, rather than explicit paths.
As for getting a list of files in a directory, there is no Oracle built-in. One solution is to use a Java Stored Procedure. Tom Kyte has an example of this. Find it here. There is another way of doing it since 11.1.0.7, which is to use an external table pre-processor file. Adrian Billington wrote a nice article on this. The executed file is platform dependent.
Have a look at UTL_FILE?
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm
Where you say:
2-) Question Two
Folder: C:\Data\inbox\
how to make get directory files list ?
Tom Kyte has a nice solution shown here
begin
UTL_FILE.FCOPY (
'EMPLOYEE' , -- THIS IS A ORACLE DIRECTORY
'EmpInfo.TXT' , --FILE NAME
'PROM_INCR' , -- THIS IS A ORACLE DIRECTORY
'EmpInfo.TXT' ); -- DESTINATION FILE
end;
try this

in windows SAS, how to read the file loaded recently in particular path

in windows SAS, how to read the file loaded recently in particular path.
as i am accing from a path having lot of files , so it should pick a file having the latest data loaded in that path
If you have non-SAS files in the destination directory, you can pipe a command such as dir <your directory> /od /b to a data as illustrated in this question.
If all the files are SAS datasets, create a libref to the directory and try
proc sql noprint;
select
memname,
crdate
into
:newestdata,
:createdate
from
dictionary.tables
where
libname=upcase("<your libname>")
having
crdate=max(crdate);
quit;
%put &newestdata;
%put &createdate;
Unless there are data sets which have the exact same creation time stamp, the &newestdata and &createdate macro variables should contain the name and creation date of the latest data set.

Resources