Newsgroups: comp.databases.oracle.misc
Subject: Re: ROLLBACK SEGMENTS: Some basic questions
References: 

>1.  Is there a way to have a transaction not use any rollback segment ?
>I am more concerned about performance and data loss is not really a 
>concern.

>2.  I have a rather complicated PL/SQL script that works on a table that
>has 140,000 rows in it.  The script is deleting rows based on a set of rules.
>The process after 30 minutes aborts and reports the following :

>BEGIN
>*
>ERROR at line 1:
>ORA-01562: failed to extend rollback segment number 1
>ORA-01628: max # extents (100) reached for rollback segment R01

>I thought I had taken care of all my rollback segment blues when I created
>the following rollback segment :

>create public rollback segment r01 tablespace RBS 
>storage (initial 500K NEXT 500K OPTIMAL 10M MINEXTENTS 15 MAXEXTENTS 100) ;

>I dropped all the other rollback segments intentionally to help me debug
>this problem.  I am now thinking that maybe I should increase the maxextents
>to 200 or some such number and maybe add another rollback segment with 
>identical settings.  But I am not sure if that is going to solve my problem.

>Any ideas ?

>Atif Khan

-- Note: My answers are interspersed below ... --
aak2@Ra.MsState.Edu (Atif Ahmad Khan) writes:

>create public rollback segment r01 tablespace RBS
>storage (initial 500K NEXT 500K OPTIMAL 10M MINEXTENTS 15 MAXEXTENTS 100)

The reason that your transaction failed is that your INITIAL/NEXT sizes
are too small for what you are trying to do. Since you ran out of extents
(100 maximum), you need more than 500kx100=50M of rollback to complete
your transaction.

Unfortunately, your statement failed and so it is impossible to tell how
much rollback you truly need. The best solution is to recreate the
rollback segment with:

CREATE PUBLIC ROLLBACK SEGMENT R01 TABLESPACE RBS
STORAGE (initial 10M NEXT 5M OPTIMAL 20M MINEXTENTS 3 MAXEXTENTS
100);

If you still wanted MINEXTENTS to be 15, you can decrease the initial and
next accordingly.

Run the query again and monitor how much rollback space was used. With
MAXEXTENTS 100, you will have 505M to use. Be sure that your tablespace is
large enough as well.

One final note...if you have an environment where there are both large
transactions/reports (such as the one you describe) AND short
transactions, then make several small rollback segments and one or
more large rollback segment(s) such as the one I described. For the
large transactions/reports, you can say (after COMMIT or ROLLBACK):
SET TRANSACTION USE ROLLBACK SEGMENT RB_LARGE01;

Hope this helps...

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Returning the row with the Max total
-----Original Message-----
From:	Jim Finerfrock [mailto:jfinerfrock@geocomm.com]
Sent:	Wednesday, September 30, 1998 6:54 PM
To:	Ari Kaplan
Subject:	SQL Question

Ari,

How would one return the row with the max total (see below example)?


ID        FISCALYR TYPE   TOTAL
2132901       1999    3   2488569
2132901       2003    5  92068040

Thanks,
Jim

----- Reply --------------------------
SELECT ID, FISCALYR, TYPE, TOTAL
FROM table_name
WHERE TOTAL IN (SELECT MAX(TOTAL)  FROM table_name)
/

Regards,

-Ari Kaplan
www.arikaplan.com

Back to Ari Kaplan's Home Page

Buffer overflow in PL/SQL; avoid writing to Rollback Segments


    Hi Ari,

    First of all, Thank you very much for your help on Oracle database
    related questions.  Your suggestions are really excellent and
    informative.

Thanks!

    Since I'm working in Data warehouse environment, I have to deal with
    large data.  I have couple of problems and hope I could get clarify
    from you.

    1.  Buffer overflow problem in PL/SQL.
         When I use dbms_output.put_line in PL/SQL code, I get this
    `Buffer overflow ` problem when it is outputting more .  To avoid this
    problem. I used dbms_ouput.disable and dbms_output.enable(1000000)  at
    the starting of this code.  Even then, if output data is more (may be
    more than 1000000, obviously), I get the same error.  To avoid this
    problem,  I used dbms_ouput.disable and dbms_output.enable(1000000)
    inside the loop to flush out .  This doesn't seem to help and  I see
    the output at the end of the execution , but not after flushing it
    out.

Yes, there are problems with the buffer overflowing. What I personally do is use
the UTL_FILE package, which writes to an operating system file. You can view the
results AS it is executing, and you can have gigabytes of data.


    2. How to avoid writing into rollback segments.
         Is there any way in Oracle that we can bypass writing into
    Rollback segments ?
    Here, I'm not worrying about data loss. I can re-run if there is any
    problem.

In Oracle8 there are NOLOGGING attributes to objects where the INSERTs, UPDATEs,
and DELETEs, do not use rollback segments / redo logs.


    3.  In  PL/SQL,  when I have a join on big tables , it gives `Snapshot
    too old (rollback segment too small)' . To avoid this problem, I used
    different cursor on each table and pass first cursor information to
    other cursor.

    My question is , Why it uses rollback segment for select statement.
    I'm not doing any update, delete or insert in my statement.
    As per my knowledge, It uses temp segments for sorting and joining
    etc.  Please correct if I'm wrong.


The "snapshot too old" is misleading. Your SELECT statement does not use
rollback segments (you are correct). But what is happening is that other
processes are modifying data while your SELECT statement is executing. If there
are too many changes that occur during the SELECT statement, then Oracle cannot
keep a consistent view of the database and gives the "rollback too small". What
is happening is your SELECT relies on the rollback segment to keep its view of
the data consistent to the point that the SELECT statement started.

    This is my outstanding doubts since long time. Once again thanks a lot
    for your suggestions .

    Prasad
    email : p_gunda@hotmail.com (OR)
            prasada.gunda@hartfordlife.com



Hope this helps, and best of luck to you.

-Ari Kaplan
www.arikaplan.com

Back to Ari Kaplan's Home Page

Finding the optimizer mode for the database
-----Original Message-----
From:	Chalavadi, Durgarao [mailto:ChalavaD@qwest.net]
Sent:	Monday, October 05, 1998 10:11 AM
To:	'ari'
Subject:	

Hi Ari,
I received your mail on friday. Thanks a lot for sending me reply.
How can i know which optimizer is being used by oracle session?
Thanks in advance for your help.

Bi,
Durga

---- Reply -------------
The best way is to do

SELECT * FROM V$PARAMETER WHERE NAME = 'optimizer_mode';

This will tell you the mode for the database. If the value is CHOOSE than it the
database is in Cost-Based. However, if there are no statistics on the tables
that a query is based upon, then it is in RULE mode.

To tell for a particular query, you will need to do an EXPLAIN PLAN on the
query. If you see costs associated with the query, then the query is in
COST-BASED mode. Otherwise it is in RULE-BASED mode.

Don't forget that you can use the RULE hint to force rule-based mode on any
query.

Best regards,

-Ari Kaplan
www.arikaplan.com


Back to Ari Kaplan's Home Page

US7ASCII and Oracle6.0
> Hi Mr.Kaplan,
> 
> I would be thankful to you, if U could tell me how I exp a 7.3 or 7.x 
> database (tables) to 6.0.33 DB.
> 
> I have all methods spec. by oracle.
> ie. run script catexp6.sql and then oracle 7 exp.
> But I am facing problems with character set,
> ie Oracle 6 character set is US7ASCII, whereas 7.x is WEISO...
> Even I have oracle db with US7ASCII character set.
> But no way I could import the data to 6.0
> 
> Thanks in advance
> 
> Padmanabhan
Padmanabhan,

That's a good question. I believe the only way is to change the COMPATIBILITY
parameter in the PFILE file to "6.0.33".
Do this for the 7.x database. Then export and import into the 6.0.33 db.

When it is successfully imported, remove the COMPATIBILITY line in the PFILE.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Temporary segments

Chuck Hamilton (Xchuckh@dvol.com) wrote:
: I'm running oracle 7.3.2 on Irix and hp-ux. I've noticed that somtimes
: temporary segments are left in the temp tablespace long after the sort or
: group-by that created them has finished. Is this normal behaviour? Does
: oracle reuse those segments?
: -- 
: Chuck Hamilton
: Xchuckh@dvol.com
Chuck,

It is perfectly natural for the temporary segments to linger in your
database. They will eventually go away, once the background processes
clean it up. The time it stays out there depends on how large the process
was, and the amount of rollback activity associated with the temporary
segment. As far as I know, they are never re-used.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to get multiple rows via a stored procedure

Price Waterhouse LLP (user@msn.com) wrote:
: Hello,
: 
: I am developing an application in VC++ and accessing the Oracle database
: via ODBC.  I have to access the data via stored procedure.  I created a
: stored procedure in Oracle as:
: Create stored procedure....
: and in the body 
: ()
: is empname employee.name%TYPE;
: Begin
: select name into empname from employee;
: end;
: 
: since this will return multiple records the sqlplus complains and can't
: execute it and if I try to execute it via ODBC, I get the same error
: message.
: 
: Is this possible at all in Oracle. I have to make my application compatible
: with Access and Oracle.  This method does work in Access.  Although Access
: stored procedure are Predefined queries.
: Thanks in advance.
: n_akhtar@msn.com

It is no problem to manipulate several records in PL/SQL. Your code is an
implicit cursor. You need to create an explicit cursor. Follow the example
below:

1  DECLARE
2     EMPNAME EMPLOYEE.NAME%TYPE;
3     CURSOR c_employee IS
4            select name into empname from employee;
5  BEGIN
6     OPEN c_employee;
7     LOOP
8        FETCH c_employee INTO empname;
9        EXIT WHEN c_employee%NOTFOUND;
10          DBMS_OUTPUT.PUT_LINE('The employee name is:'||empname);
11    END LOOP;
12    CLOSE c_employee;
13 END;

Lines 3-4 create an explicit cursor, "c_employee" that will be used to
process the SQL query, one record at a time.
Line 6 "Open"s the cursor for use, and executes the SQL query.
Line 8 "FETCH"es a record into the empname variable.
Line 9 EXITS the loop if there was no more data to be retrieved
Line 10 outputs the info on the record. At this point, you may do what you
will with the data. This example simply prints it to the screen.
Line 11 points to the end of the loop, at which point processing returns
to line 8.
Line 12 closes the cursor

Hope this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Replicating LONGS
> 
> Ari,
> 	Hey, I never heard what you thought about that
> stored procedure I sent you.  Well, I have another
> question for you.  I have a table that consists of two
> fields a varchar2 and a long.  I want to replicate
> this table but I have tryed two methods but I don't seem
> to be able to "insert into..." with a "select from..."
> when a long data type exists.  Do you have any ideas?
> This has to be a process that can be run from a stored
> procedure so my knowledge is limited.
> Any help would be much appreciated, as always.
> 
> Thanks,
> John
> -- 
> 
> **********************************************************
> *  John Holland        (mailto:holland@blairlake.com)    *
> *  Technical Director                                    *
> *  BlairLake New Media     (http://www.blairlake.com)    *
> *  104 West 42nd Street              Tel 816.756.2121    *
> *  Kansas City, MO 64111-2301        Fax 816.756.2992    *
> **********************************************************
> 

As for replicating long, you cannot do it straight out in Oracle7. Oracle8 gives
you LOB packages to handle it.


What you have to do is make a stored procedure (like you plan to), and define
two variables whose datatypes are VARCHAR2 and LONG.
Then, you can open a cursor on the table and FETCH the values into the two
variables.
Insert a new record into the second table, supplying the two variables.

Loop through the cursor until finished.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to detect objects approaching MAXEXTENTS
> Hello,
> 
> I am trying to maintain a database where its tables are constantly
> reaching max extents. This is caused by bad sizing when the database
> was originally created. (Not me, honest). I am using a package which
> allows me to re-organise the troublesome tables. I set the initial
> size to the current size of the table and set the next extent to a
> larger figure. This as you will already know will bring the current
> extent back down to 1.
> 
> Please can you help?  -  I want to write an SQL script that I can run
> every day on the base that will inform me of any table that is
> approaching its max extents. Hopefully this will give me a chance to
> be proactive rather than reactive.
> 
> Do you have any handy hints or SQL script that may help?
> 
> Thankyou,
> 
> Martin.
> 
Martin,

I do have a script that will report any objects that are near the MAXEXTENT
limit. The MAXEXTENT will be 121 by default if the block size is 2K. It will be
249 if the block size is 4K. The previous person may have overwriten the default
for any of the objects.

To find objects that need defragmenting, use the following script:

SELECT SUBSTR(owner||'.'||segment_name,1,50) OBJECT,
       EXTENTS
FROM DBA_SEGMENTS
WHERE EXTENTS > 5
ORDER BY EXTENTS;

Now, to find all objects that are nearing the MAXEXTENTS, you can do the
following (assuming it is 3 extents or less away from MAXEXTENTS):

SELECT SUBSTR(owner||'.'||segment_name,1,50) OBJECT,
       EXTENTS, MAX_EXTENTS
FROM DBA_SEGMENTS
WHERE MAX_EXTENTS - EXTENTS < 4
ORDER BY EXTENTS;


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

OFA, utlbstat/utlestat
> 
> Ari,
> 	Hey Ari, you know I am not a DBA, I am a programmer who
> knows how to write applications that use databases, therefore I
> usually end up designing the database backends.  I like it but...
> I'm not a DBA.  So here is my question.  I am being asked by some
> DBAs about the performance of my database I designed and asking
> some questions I just don't know.  So I found this script on the
> web and ran it and it gave me the output below.  If you have a
> spare moment (if there is such a thing), could you look it over
> and tell me whether it is good or bad?  And, what is OFA, and
> what does it mean to be OFA complient?   If you don't have the
> time, I understand.  You just seem to be the only one I ever get
> a response from.
> 
> Thank you,
> John

OFA means "Oracle Flexible Architecture", and is basically how a directory
structure should be set up so that multiple databases may exist on one server.
For example, all databases should have a bdump, cdump, ufile, pfile directory.
Tablespaces should be spread out on different drives, etc.
I believe there is a white paper on this somewhere on "www.oracle.com".

I have commented below to your utlestat result, cutting to only the important
parts...


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


> Hit Ratio = (logical reads - physical reads) / logical
> reads                    
>             Hit Ratio =
> 90.53%                                                  
>                                                                                 
> If the hit ratio is less than 60%-70%, increase the initialization
> parameter DB_BLOCK_BUFFERS.  ** NOTE:  Increasing this parameter will
> increase the SGA size.

Hit ratio is pretty good. Anything less than 85% should be an indication to
increase the DB_BLOCK_BUFFER size.

> 
>                                             GET HIT            PIN
> HIT          
> NAME                       GETS    GETHITS    RATIO   PINHITS   
> RATIO          
> --------------------  ---------  ---------  -------  -------- 
> -------          
> SQL AREA                  16957      16343      .96     36192     
> .96          
> TABLE/PROCEDURE            2128       1867      .88      3007     
> .90          
> BODY                                           1.00              
> 1.00          
> TRIGGER                      26         18      .69        27     
> .26          
> INDEX                        21                 .00        21     
> .00          
> CLUSTER                      27         12      .44        15     
> .33          
> OBJECT                                         1.00              
> 1.00          
> PIPE                                           1.00              
> 1.00          

The CLUSTER, TRIGGER, and INDEX hits could be improved above, but since they
were hit only 21-27 times, it is statistically meaningless. For example, the
SQL AREA was hit 16957 times (much more significant statistically than 27). So,
you are good in the above result...

> free memory                                      
> 10,844                        

Memory looks low, increase the SHARED_POOL_SIZE parameter in your init.ora file
(by about 5 megs), shut down the database, and start again.

Aside from that, everything looks good!

> 
> **********************************************************
> *  John Holland        (mailto:holland@blairlake.com)    *
> *  Technical Director                                    *
> *  BlairLake New Media     (http://www.blairlake.com)    *
> *  104 West 42nd Street              Tel 816.756.2121    *
> *  Kansas City, MO 64111-2301        Fax 816.756.2992    *
> **********************************************************
> 

Back to Ari Kaplan's Home Page

Selecting constraints from the dictionary

Chuck Hamilton (chuckh@dvol.com) wrote:
: Is there a way to select all of the constraints on a table except the
: not null ones? The problem I'm encountering is that if I try to say
: 
: SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'MYTABLE'
: AND SEARCH_CONDITION NOT LIKE '%IS NOT NULL'
: 
: I get an error stating basically that SEARCH_CONDITION is a LONG
: datatype.
: 
: If I try to join USER_CONSTRAINTS, USER_CONS_COLUMNS, and
: USER_TAB_COLUMNS to see if USER_TAB_COLUMNS.NULLABLE <> 'N', then it
: excludes ALL constraints on the not null columns, not just the NOT
: NULL constraints (i.e. there could be a not null constraint *and* a
: check constraint on a column).
: --
: Chuck Hamilton
: chuckh@dvol.com
: 
Chuck,

You cannot do string comparisons on LONG columns in SQL. You have to use
PL/SQL. I wrote a script for you to do your request:

DECLARE
constraint_text long;
c_name varchar2(100);
c_type varchar2(100);
c_owner varchar2(100);
c_table_name varchar2(100);
cursor CONSTRAINTS is SELECT table_name, owner, search_condition,
                             constraint_name, constraint_type
                      FROM dba_constraints;
BEGIN
OPEN CONSTRAINTS;
LOOP
   FETCH CONSTRAINTS
         INTO c_owner, c_table_name, constraint_text, c_name, c_type;
   exit when CONSTRAINTS%NOTFOUND;
   IF instr(upper(constraint_text),'IS NOT NULL') = 0 or
      constraint_text is null THEN
           dbms_output.put_line ('Table Name =
'||c_owner||'.'||c_table_name);
           dbms_output.put_line ('Constraint Name = '||c_name);
           dbms_output.put_line ('Constraint Name = '||c_name);
           dbms_output.put_line ('Constraint Type = '||c_type);
           dbms_output.put_line ('Search Condition = '||constraint_text);
   END IF;
END LOOP;
CLOSE CONSTRAINTS;
END;
/

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

: "Therefore the Lord Himself will give you a sign:
: Behold, a virgin will be with child, and bear a son,
: and she will call His name Immanuel." (Isa 7:14 NASB)
The correct quote is:

"Therefore the Lord Himself will give you a sign:
Behold, a young woman will be with child, and bear a son,
and she will call His name Immanuel." (Isa 7:14)

The original Hebrew is "septulah" which is young woman, not "betulah"
which is virgin. Check some non-King James bibles or Hebrew bibles and you
will see what I mean. Not to sidetrack the Oracle issue...

Back to Ari Kaplan's Home Page

Instance Startup Parameters

Frank Shams (frank.shams@technet.net) wrote:
: Hi,
: I have the following problem:
: I like to set up a database which is located in another directory then
: %ORACLE_HOME%\DATABASE. When I try to startup the instance via the
: Server Manager with STARTUP MOUNT EXCLUSIVE the following error message
: appears:
: MGR-00310 Unable to open "SYS:ORANW732\DATABASE\INIT%SID%.ORA"
: Where can I specify the necessary parameter to tell the server manager
: where to find the INIT%SID%.ORA according to the oracle instance?
: 
: Thanks in advance...
: Ulrich
: 
Ulrich,

You can use the PFILE parameter:

STARTUP PFILE=/home/oracle/test/initTHESID.ora

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Reducing Buffer Cache Misses

David Turner (turner@vortex.more.net) wrote:
: Suddenly my buffer cache miss rate has jumped from a comfortable
: 5-6% to 65%. We have alot more users and alot more hits. Could
: anyone direct me to information that would help me reduce the 
: buffer cache misses?
: 
: 
: 						Thanks, Dave Turner
Dave,

What you discuss is common. Increase the DB_BLOCK_BUFFERS parameter in
your initSID.ora parameter file. You will have to restart the instance.
You should continually monitor the buffer cache hit ratio as part of your
DBA maintanence routine.

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SQL Quiz

Naren Chintala (naren@att.com) wrote:
: Hi,
: SQL> describe t1;
:  Name                            Null?    Type
:  ------------------------------- -------- ----
:  C1                                       NUMBER
: 
: SQL> select c1 from t1;
: 
:         C1
: ----------
:          1
:          4
:          7
:          8
:          9
:         10
: 
: Question:
: 
: I need to retrieve the missing numbers (2,3,5,6) from t1.
: How can I do this in ONE sql statement? 
: I know that this can be done in PL/SQL.
: 
: Any ideas? 
: Thanks
: Naren
Naren,

The following will work:

  1  select '1' from dual union
  select '2' from dual union 
 select '3' from dual union
 select '4' from dual union
 select '5' from dual union
 select '6' from dual union
 select '7' from dual union
 select '8' from dual union
 select '9' from dual union
 select '10' from dual
 minus select * from t1
/

The result will be 2,3,5,6.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Removing Columns from a Table

> 
> Hi Ari
> 
> I read some of your technical responses and I found some of them very
> helpful.
> I hope you can help me with a problem.
> 
> Is there an easy way to delete empty columns from a table?
> 
> Thanks in advance
> 
> Gaston
In Oracle8, you can issue:

ALTER TABLE table_name DROP COLUMN column_name;

(Thanks to Keith Lewish )

In Oracle7, there is no easy way. The best way is to do the following steps:

Assume you wish to delete the OLD_COLUMN column from the THE_TABLE table:

THE_TABLE
--------
column_a	number
column_b	varchar2(10)
OLD_COLUMN	varchar2(1000)
column_d	number

1) Create a temporary table with all columns except the one you want to delete:
CREATE TABLE temp_table AS
SELECT column_a, column_b, column_d FROM THE_TABLE;

At this point, you will have the TEMP_TABLE that looks like:

TEMP_TABLE
--------
column_a	number
column_b	varchar2(10)
column_d	number

2) DROP TABLE THE_TABLE;

3) RENAME TEMP_TABLE TO THE_TABLE

4) Recreate all triggers, constraints, indexes, grants, statistics on
   THE_TABLE. Also recompile any functions, procedures, packages that depend
   on THE_TABLE.

Easy, huh? ;)


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Oracle8.0 for Windows NT - Newbie Question

MaNdRaKe (mandrakeelmago@hotmail.com) wrote:
: I am running what I consider to be a moderate size database and having a
: lot of trouble
: trying to make it work on ORACLE 8.0 for Windows NT
: The size of the flat files add up to 500M there are 13 tables of varied
: sizes
: from 7 rows to 1.8M rows, the number of columns vary as well
: 
: Can some one tell me What the maximum database size is in ORACLE 8.0 and
: waht teh maximum number of tables is and the maximum number of rolumns in a
: table and max rows per table are?
: 
: I would really apreciate an answer to my newbee questions thnx in advance

The maximum database size is usually limited to the hardware. If you have
unlimited hardware, then the database can be about a petabyte (1000
terabytes). For your 500M application, this is certainly enough.

The maximum number of columns in a table is now 1000.
The maximum number of rows per table is basically unlimited. You can have
billions of rows if not more.


Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Password Expiration Methods

: > We currently use RACF at the mainframe to set password expiration methods.
: >
: > We are about to move our Oracle Databas from the mainframe to AIX (IBM's
: > UNIX). Does anyone know a way or package that forces the end-users to change
: > their password after a certain period?
: >
: > Regards,
: > Reinier Muller
: > Senior System Engineer R&D
: 
: Are you looking for the replacement of RACF at the connect/login time or at the
: application time? The last time I worked with RACF it was only for logging into
: a MVS system.  Going down that path, AIX does have password aging and users can
: be trapped into an application.  Now UNIX passwords and aging are far from the
: depth of RACF but there are products (Tivoli) that could add security to equal
: RACF2.
: 
Reinier,

Within Oracle, this is only possible in Oracle8. You can set periods (30
days, etc) after which the user must change their password. You can do
other security tasks such as ensuring the password is at least 8
characters or has at least one digit, or prevent a user from logging in
for an hour after three unsuccessful attempts.

If anyone reading this is interested to learn more, I will be giving a
speech at the IOUG scheduled now for May 13th in Orlanda, Florida.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Cannot do 'connect internal' to do system shutdown

Newsgroups: comp.databases.oracle
Subject: Re: HELP! Cannot do 'connect internal' to do system shutdown
References: <4k4qf5$e7k@nyx10.cs.du.edu>

jngreene@nyx10.cs.du.edu (Joseph Greene) writes:

>I  am Sys Admin for a company with a few political problems (mostly the 
>DBA dislikes me because I push to get things done). How this applies is 
>the DBA has hidden  all oracle docs and deleted the online ones....nice guy.
>I need to get the automated shutdown running correctly (and the startup too).
>I have the ORACLE_HOME and ORACLE_SID set. I even have the 
>$ORACLE_HOME/bin in my path statement. When I run the auto start script 
>as root I get the message 'ORA-01031: insufficient privileges'. I can get to 
>the oracle dba account as I have to do this manually to shut it down. What 
>permissions/right/privileges do I need to set and how do I set them???

>Thanks in advance.
>Joe Greene

>-- 
>LEGO: TC,MOC+++(>8880) #+>+++ S+++ LS+>++ Hri A>+ M>+ YB72m
>Need more LEGOs... need 8880.....
>Joe Greene jngreene@nyx.cs.du.edu http://nyx10.cs.du.edu:8001/~jngreene

Sorry to hear about your office politics. Anyway, in order to use the
SQL*DBA program to shutdown the database and bring up the database, your
UNIX userid (I am assuming this is UNIX) must be in the same unix group
as the oracle unix user. On most systems this means that your unix userid
must have "dba" as its group.

If not, you will get the "ORA-01031: insufficient privileges" error you 
received.

Another alternative: since you have "root" privilege, just issue an 
"su - oracle", which will set up your environment and log you in as oracle.

Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Export speed too slow
: hi all:
: 	in my company, there are 10mb data to export , but it take me
: about 10 hours to export , does it normal ? or have someway to speed
: up the export speed ? thanks
: 
: oracle 7.1.3 for DG

10 hours is *way* too long to export 10M of data. Some ways to speed it up
are listed below:

1) Specify an export file in a volume directory OTHER than database-related
   volumes.
   Bonus for a separate controller and/or disk
2) Break the export into many parallel exports, each one exporting different
   tables/owners.
3) Increase the buffer size for the export (exp buffer=xxxxx)
4) I am not as familiar with 7.1.3, but if possible use DIRECT=Y mode for
   the direct path execution

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Writing Ampersands to fields
> 
> Ari,
> 	Can you write a string containing Ampersands to
> a field in Oracle?  I don't seem to be able to do it.
> 
> Thanks,
> John
> -- 
John,

Try the following in SQL*Plus:

SET ESCAPE '^'
SELECT 'Here is an ampersand: ^& - cool, huh?'
FROM DUAL;


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Simple SQL Question from a Beginner

mwilson@sundog.larc.nasa.gov wrote:
: 
: Hi Folks, 
: 
: I've downloaded and installed the trial version of the
: Workgroup Server 7.3 on a Solaris 2.6 platform.  I'd
: like to try some simple things out before buying the
: full blown version.  I've been using PostgreSQL and
: have a simple little table that includes some arrays.
: Can anyone tell me how to implement arrays in sqlplus?
: 
: This is what I tried along with the error it gave me:
: 
: SQL> r
:   1  create table brdf (
:   2     mission_date    date,
:   3     igbp            integer,
:   4     gmt             integer[],
:   5     zenith          real[],
:   6     azimuth         real[],
:   7     constraint c1 primary key(mission_date, igbp)
:   8* );
:         gmt             integer[],
:                                *
: ERROR at line 4:
: ORA-00907: missing right parenthesis
: 
: 
: SQL>
: 
: I have also tried using () instead of [] but I am
: given the same error.  Can someone point me in the
: right direction while I head over to a book store to
: find a decent source of info regarding these matters
: (any suggestions for good books?)??
: 
: Thanks!!
: -Mark.
: 
: ---
: Mark Wilson                                                 757-827-4631
: Research Scientist                              m.r.wilson@larc.nasa.gov
: Analytical Services & Materials, Inc.       mwilson@sundog.larc.nasa.gov

Mark,

You were on the right track - use () instead of []. However, with the
INTEGER datatype, you should not include anything, just "INTEGER".
If you need decimal precision, use "NUMBER(10,2)" or "NUMBER". Do not
use "REAL" as a datatype.

For books, there are lots of greaet ones out there. "Oracle8 - A
Beginner's Guide" is good for either 7 or 8. I also have to pitch my own
co-authored book, if you can wait until February - "How-To Oracle8" by
Waite Group Press / Macmillan. It will have many examples, programs,
screen shots, etc.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Index REBUILD vs DROP/CREATE
> 
> Hello Ari,
> 		I am a DBA trainee at Nokia. Am doing my final year 
> 		project on " Coalscing Free Spaces During Index
> 		Recreation". 
> 	
> 		Overhere, we use the DROP index CREATE index syntax.
> 		Am suppose to compare it to the "ALTER index REBUILD"
> 	
> 		My question is:
> 		(1) what is the differnce between these two syntax?.

The REBUILD syntax can be built in parallel, and can use UNRECOVERABLE to avoid
writing to REDO logs. So, it is faster.

The CREATE INDEX syntax needs to have storge parameters set if they differ from
the default for the tablespace. For instance, the TABLESPACE, INITIAL, NEXT,
PCT_FREE, PCT_USED, etc. do not need to be specified with REBUILD but do with
CREATE INDEX.

Also, the CREATE INDEX needs to have column names listed, whereas REBUILD does
not.

> 		(2) which one is faster and more accurate.

REBUILD is faster with the UNRECOVERABLE clause, and if done in parallel.

Both are equal in accuracy.

> 		(3) which one eliminates fragmentation as we recreate
> 		    indexes for the large tables.

They both eliminate fragmentation

> 		(4) could you please expalin the "ALTER index REBUILD
> 		    command for me as I have just started using Oracle.

REBUILD is new for Oracle 7.3. It takes the description and storage parameters
of the original index and creates a new one in its place. The benefit is to
reduce fragmentation of the index due to updates, deletes, and inserts of the
underlying table.

> 	        (5) could you please, explain index recreation to me. 

Please see above.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
> 		Please Mr. Kaplan, help me as I have no means of 
> 		a book explaining it better to me.
> 	
> 		Thank you very much.
> 		Francis
> 		
> 
> 	
> 		
> 
> **********************************************************************
> " The mind of the beginner is empty, free of the habits of the expert,
>   ready to accept, to doubt, and open to all possibilites"	
> ********************************************************************
> Francis Ansah                      E-mail:ansah@shire.ntc.nokia.com        
> Nokia Telecommunications           Tel.:   +358-9-51123881
> P.O.Box 320,00045,Nokia Group      GSM:    +358-40-5324081
> 
> 
> 

Back to Ari Kaplan's Home Page

Connecting to DB from home
> 
> Hello Ari,
> 
> I hope I'm not being forward in asking you for help with my problem as I
> am sure you will be able to help me.
> 
> I am running ORACLE 7.2.2.4 on a Windows NT 3.51 server. How can I take
> ownership of the database from my PC running Windows 95 from my home. I
> dial in from home and can use sqlplus but not SQLDBA72. I would really
> like to be able to do this as it will enable me to rebuild the database
> from home.
> 
> Regards
> 
> 
> MARIUS DE BEER
> marius@atio.co.za
> ORACLE DBA
> ATIO Corporation                     P.O.Box 4467,Rivonia,2128
> Tel   : (27) (011) 235 7280          Fax: (27) (011) 807-3568
> Cell  : (27) (0) 82 776 1737
> ATIO Africa House, Tuscany Office Park, Block H, Coombe Place, Rivonia
> 
Marius,

It is never too forward to ask...

There are two ways that I do DBA work from home:

1) Use the "dial-up networking" option of Windows95 to establish a connection,
   then connect to the same network as the NT server. SQLDBA72 should work.
   You should start using Server Manager, as SQLDBA is no longer supported in
   Oracle7.3.

2) Telnet in to the NT server, and use SQLDBA72 or SVRMGRL to do DBA functions.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 115+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Multiple CPU's help
Mike (71760.1371@COMPUSERVE.COM) wrote:
: > (My prior post had the wrong format for the Compuserve address)
: > We just added two more CPU's to our ORACLE 7.3.3.0.0 server (a  Sun
: > Ultrasparc 4000 running Solaris 2.5) bringing the total up from 2 to 4
: > but have only seen a slight  (16%) improvment in even the most
: > processor
: > intensive PL/SQL blocks.
: >
: > Do we have to make any changes to ORACLE in order to optimize it for
: > the new CPU's...?
: >
: > Does anyone know of a script that can generate some system stats for
: > performance tuning in general..?
: >
: > Thanks for the help.
: >
: > MJ
Mike,

To take advantage of additional CPUs, in your initSID.ora file add the line:

cpu_count=4

This will have Oracle take advantage of your 4 CPUs. Note that versions of
Oracle 7.3 and beyond will automatically detect the number of CPUs. To verify,
issue:

SELECT * FROM V$PARAMETER WHERE NAME LIKE '%cpu%';

As for tuning scripts,
try $ORACLE_HOME/rdbms/admin/utlbstat.sql and
$ORACLE_HOME/rdbms/admin/utlestat.sql. These come with Oracle and will
generate pages of statistics, a description of which is beyond the scope of
this email. The scripts have documentation to guide you further.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->



Back to Ari Kaplan's Home Page

Export Utility
Eddie Brodie (foofoo@kronos.com) wrote:
: I am attempting to issue a simple export on an ORACLE 7.2.3
: 
: instance. I am receiving the following errors
: 
: EXP-00008: ORACLE error 6553 encountered
: ORA-06553: PLS-213: package STANDARD not accessible
: EXP-00222:
: System error message 2
: EXP-00008: ORACLE error 6553 encountered
: ORA-06553: PLS-213: package STANDARD not accessible
: EXP-00000: Export terminated unsuccessfully
: 
: It looks like a script needs to be run, before issuing an export,
: does anyone know the name of the script(s) ?
:  P.S. I did run the 'standard.sql' script as 'internal'
Eddie,

Log in as SYS and execute both $ORACLE_HOME/rdbms/admin/standard.sql and
$ORACLE_HOME/rdbms/admin/dbmsstdx.sql

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Checking the used memory

> 
> Dear Ari Kaplan,
> 
>      I am a Cadet Systems Engineer in a Japanese company in Japan.  I have
> just visited your interesting web page.  I would like to know how to check
> the used memory resource in an Oracle Developer/2000 application.

Greetings from the USA. I haven't been to Japan since 1994 and miss it.
To find the memory usage, if you are on UNIX you can do "top" and
look at SIZE (which is the total) and RES (which is what resides in memory).

In the SQL / Oracle side, you can find out the memory with a few statements:

SELECT * FROM V$SGA;

will show the fixed size and variable size of memory, along with the database
buffers and redo buffers. You may also do:

SELECT * FROM V$SGASTAT;

to give you the size of over 30 portions of memory.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

On Oracle architecture...
Satish Narasimha (satishn@blr.sni.de) wrote:
: hello,
:    I am observing some strange behaviour in oracle can any body help
:  me how it is.
:   I have oracle 7.2 installed on Solaris sparc stations. 
:  1) First questions b'cos power failure my entire machine got
:     rebooted but immediately after the machine coming up i see that
:     sqlplus is still running...
: 
:     I am not able to get the point how is this happening. I have 
:     observer this nearly two to three times. Can anybody help me on 
:     this.

You probably have an auto-start of the database when your Solaris sparc
boots up. This is usually in the /bin/init.d or /sbin/init.d directory.
Look for "dbstart" or "oracle" files.

If you do not want this to happen, you should change your "/etc/oratab"
file and put an "Y" next to the instances you DO want to come up, or a "N"
next to those that you do not.


: 
:  2) After creating the new database and bringing up the database and 
:     running the sql file to create a profile i am getting the
:     error saying that "Table or view doesn't exist" and one more
:     thing is i am not able to start pl/sql can anybody help regarding
:     this.


You cannot start "PL/SQL". I assume that you mean "SQL*Plus". Check your
environment variables, most notably ORACLE_SID, ORACLE_HOME, and PATH. Be
sure that $ORACLE_HOME/bin is in the path, so that the sqlplus executable
will be found.
As for "Table or view doesn't exist", what table is this? Which file did
you run to create the profile? Most scripts DROP the table/view and then
CREATE the table/view. Thus, if it is the first time you run the script,
you will get a "Table/view does not exist" followed by a "Table/View
created."

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->



: 
:    If i get the solutions for both i will be thankful to them.
: 
: 
: From
: satish :satishn@blr.sni.de

Back to Ari Kaplan's Home Page

ORA-00984
Cosmo (Cosmo@Frontier.Com) wrote:
: Hello everybody,
:    I am trying to insert data into a table, keep getting an error message
: that says:
:  error at line ... .
: ORA-00984: column not allowed
: I am fairly new an don't understand why column not allowed. I am using
: Oracle 7 server release 7.2.3.0.0
: Any ideas will greatly appreciated, and sorry for the beginner stuff !
:                        Mahmoud
: 
: Here is the definition of the table which is a part of several tables in my
: schema.
: create table consultant
: (
:  cid            NUMBER(5)
: ,cname          VARCHAR2(15)
: ,cssn           NUMBER(9)  PRIMARY KEY
: ,cphone         NUMBER(10)
: ,chrate         NUMBER(5)
: ,pname          VARCHAR2(15)
: ,hours          NUMBER(10)
: , FOREIGN KEY(cid) REFERENCES address(cid)
: )

The lines above should read
,hours         NUMBER(10
) FOREIGN KEY(cid) REFERENCES address(cid)

The table was created improperly.
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->




: Here are part of the insertion sql*plus commands:
: accept  ssn number -
: prompt "enter consultant social security number(required): "
: accept  consid number -
: prompt "enter consultant id number: "
: accept  name char -
: prompt "enter consultant name: "
: accept  phone number -
: prompt "enter consultant phone number: "
: accept  rate number -
: prompt "enter consultant hourly rate: "
: accept  prname char -
: prompt "enter project name: "
: accept  whours number -
: prompt "enter hours worked: "
: insert into client(cid) values(&consid);
: insert into consultant(cid,cname,cssn,cphone,chrate,pname,hours)
:                  values(&consid,&name,&ssn,&phone,&rate,&prname,&whours) ;
: 
: 
: 
: 
: 

Back to Ari Kaplan's Home Page

dbms_output.put_line
Maija-Leena Kangasmäki (maija-leena.kangasmaki@tietogroup.com) wrote:
: I want to display some numbers with dbms_output.put_line but I don't
: know how to show them nicely in columns like this:
: 
: col1    col2
:    1     100
:   10      20
:  100       1
:  200     300
: 
: Regards, 
: Maija-Leena Kangasmäki
: _______________________________________
: TT-Valtionpalvelut / TT Government Service
: maija-leena.kangasmaki@tietogroup.com
Maija-Leena,

It's not pretty, but it works:

DBMS_OUTPUT.PUT_LINE('col1      col2');
DBMS_OUTPUT.PUT_LINE(lpad(to_char(col1),4)||lpad(to_char(col2),10));

The second line converts col1 and col2 to a string, then pads them with
left-spaces to fit four characters and ten characters.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

rollback segs prob. 7.3.2.3 -> 7.3.3.0
Dave Brady (brady@fas.harvard.edu) wrote:
: I've just done this upgrade (on Digital UNIX 4.0B), and now I
: can't open the database:
: 
:   ORA-01682: rollback segment (2) has unlimited extents
: 
: I had created this database with unlimited extents on the rollback segments,
: as I wanted something with which I could experiment.
: 
: The Oracle7 Server Messages book does not list this error, so
: I have no clue as to how to correct it.
: 
: Any help would be appreciated!
: -- 
: 
: Dave Brady                    FAS Computer Services
: Sr UNIX Sys Admin/Programmer  Harvard University
: brady@fas.harvard.edu         LL1A Science Center
: Phone: (617) 495-1273         1 Oxford Street
: FAX:   (617) 495-1210         Cambridge, MA 02138
I will quote my Oracle documentation, which will solve your proble:

01682, 00000, "rollback segment (%s) has unlimited extents"
// *Cause:  A rollback segment with unlimited extents was found and
init.ora
//          parameter unlimited_rollback_segments was set to FALSE
// *Action: set unlimited_rollback_segments to TRUE and restart the 
database.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Creating a second instance
Lisa Lewis (lmg@isdsa.pgh.wec.com) wrote:
: Hi all,
: 
: I have to create a second Oracle instance.  My platform is Unix and I am
: running Oracle 7.3.2.  My background is NT and I'm a little shaky working
: with unix.  Could someone please tell me if the following steps are correct
: for creating a second instance.  Am I leaving steps out?  Are there concerns
: that I should have or things to look out for?
: 
: (1)  Set the environment variables ORACLE_SID to the new instance name.
: (2)  Create the new instance using oradim73.exe
: (3)  Connect internal
: (4)  startup the instance using the new initxxx.ora file w/NOMOUNT
: (5)  create the new database ... etc ...

Lisa,

You will have to first make directories, if you want to be OFA compliant.
I strongly recommend this, especially if you plan on having more than one
instance on your server, which you indicated you do. To do this :

* Make $ORACLE_BASE/admin/$ORACLE_SID/bdump,
       $ORACLE_BASE/admin/$ORACLE_SID/cdump,
       $ORACLE_BASE/admin/$ORACLE_SID/udump,
       $ORACLE_BASE/admin/$ORACLE_SID/pfile directories, owned by
       the "oracle" userid and the "dba" group.
* Create an init.ora file, called "init$ORACLE_SID.ora" in the pfile
  directory. Oracle supplies sample files, or you can use the one from the
  other instance, and change the file to reflect the new $ORACLE_SID.
* Make a "soft link" in the $ORACLE_HOME/dbs directory. Since you not a
  UNIX type, you can issue the following commands:

cd $ORACLE_HOME/dbs
ln -s $ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora init$ORACLE_SID.ora

* Create the volumes for your data files, owned by "oracle"/"dba".
* Connect to SERVER MANAGER:

svrmgrl
> CONNECT INTERNAL;
connected.
> CREATE DATABASE ....
  
* Update your /etc/oratab file (see below)
* If using SQL*Net, update your listener (vi
$ORACLE_HOME/network/admin/listener.ora) and add the instance. Then,
restart the listener:

lsnrctl stop
lsnrctl start


: Also, what do I have to do to ensure that this
instance will be
: automatically started on reboot.  ( I didn't set up the first instance and I
: am not a UNIX person).
: 

You need to modify your /etc/oratab file. It should contain a list of all
instances, followed by the Oracle home and a Y/N. Set the value to Y if
you want to bring up the database automatically during a reboot.

Also, you need to put Oracle's dbshut and sbstart in the proper
directories. This will depend on your UNIX environment.

Usually, K100oracle or dbshut goes in the /sbin/rc1.d directory, and
S9000oracle or dbstart goes in the /sbin/rc2.d directory.

Good luck!!!!
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


: Thanks for any help! : 
: Lisa
: 
: 

Back to Ari Kaplan's Home Page

Is it possible to pass args. to a sql script?
Casper Thrane (ct@benau.dk) wrote:
: Hi
: 
: I have a sql-script in a file which i execute from sql-plus, but is it
: possible to pass arguments when I execute this script?
: -- 
: Casper Thrane
: Systemdeveloper
: Benau A/S
Casper,

To pass parameters to a SQL-Script, simply separate them with a space. For
example:

SQL> @script.sql parameter1 parameter2 parameter3

In the SQL-Script, refer the the parameters as &1, &2, and &3.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 125+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-1555: Snapshot Too Old

> 
> I got the following error:
> 
>  ORA-01555: snapshot too old (rollback segment too small) : errno -1555:
> 
> 	I have 10 rollback segments, each identical in design 
>         (initail 128K, next 128K, optimal 256K)
> 	And I have 2 rbs tablespaces, the first 50M, the next 100M.
> 	What do I need to increase?
> 		
> 		Thanks in advance,
> 			Christine
Christine,

You need to increase either the INITIAL, NEXT, or both. What is happening is
one process, attached to one rollback segment, took too much data for
one rollback segment to keep the process's view of the data in a consistent mode.

So, drop all rollback segments and recreate. For starters, try:

INITIAL 1M
NEXT 1M
OPTIMAL 2M
MINEXTENTS 2


Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Finding which users hog the system

> 
> Hi,
> 
> This is J. Haleem from Dubai.  You might have seen me in your Feedback
> form.  
> 
> Well.  My problem is.
> 
> Sudenly the server performance become sloooow.  I would like find which
> user occupy more space.  
> 
> Warm Wishes,
> J. Haleem
> 
Hi J. Haleem,

Greetings from Chicago, Illinois, America!

There are tons of things to look at when performance is slow.

- If you are in UNIX, type "top". This will tell you which processes are
  using the most CPU power.
- If you have cost-based optimizer mode on, make sure that the statistics on
  the tables have been recently calculated.
-  Use "explain plan" on any one query that is slow
-  Look at where your datafiles and redo logs are on the physical drives. If
   possible, spread them over several controllers and/or drives in the OFA
   architecture.
-  Look at your hit ratio, and if necessary increase the db_block_buffer
   init.ora parameter

These are just a few of the things you can check. If you need clarification
on any of these, I recommend reading "Oracle Tuning" by O'Reilly and Associates.

Best of luck.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Converting LONG to VARCHAR2

Laura Bellini (laura.bellini@compaq.com]) wrote:
: Is there any conversion function or method to convert a Long variable type
: into a varchar2? (varchar can be v. large...2500+).
: 
: thx.
: Laura Bellini
: laura_bellini@compaq.com

Laura,

You cannot do string functions on LONG columns with regular SQL. You will
have to use PL/SQL. First, if you expect values to be more than 2000
characters, then you have two choices:
1) Switch to Oracle8, where the varchar2 fields can have 4000
characters. Oracle7 has a 2000 limit.
2) Stay in Oracle7 and break the LONG field into two varchar2(2000)
fields.

The only way to convert LONG columns is in PL/SQL. Look at the following
example, which determines the length of the LONG field:

SET SERVEROUTPUT ON SIZE 10000;
DECLARE
long_var LONG;
BEGIN
SELECT text_column INTO long_var
FROM table_with_long
WHERE rownum < 2;
DBMS_OUTPUT.PUT_LINE('The length is '||LENGTH(long_var));
END;
/


Basically, you define a variable as the LONG type, then SELECT the column
INTO the variable. Finally, it is output to the user. SET SERVEROUTPUT ON
SIZE 10000 allows spooling from the PUT_LINE to go to the screen.

You can use a similar method to select the LONG into a varchar field. The
following example puts the first 2000 characters into TABLE_B, which for
our purposes has one column, TEXT_FIELD:

DECLARE
long_var LONG;
var_var  VARCHAR2(2000);
BEGIN
   SELECT text_column INTO long_var
   FROM table_with_long
   WHERE rownum < 2;
   var_var := substr(long_var,1,2000);
   INSERT INTO table_b
   VALUES (var_var);
END;
/

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Defining Default Column Values
> 
> Dear Ari,
> 
> I wish you a marry x-mas and a very happy new year - 1999.
> 
> I know that You are busy with other works, if time permits and possible,
> please clarify my doubt.
> 
> I have a situation here. I want to fill up one of the columns of my table
> with sequence number from the sequence. I have not defined it as a primary
> key or unique key. When  I create a table with default clause for that
> column, oracle is giving syntax error saying that pseudo columns or
> reference to functions or procedures not allowed here. Is there any other
> way to accomplish this task. Or Oracle 8 will allow.
> 
> Simply, How can I include dynamic values in the default clause of create
> table command.
> 
> Please reply back to the same mail id.
> 
> Yours
> Palani.
> 
Palani,

I do not remember if I have previously answered your question. If not,
then happy new year.

I do not know of any way to include a default value for an Oracle table. What
I personally do is add a BEFORE TRIGGER on the table. Then, I check if the
new.COLUMN_NAME is not null. If it is NULL, then I set the column to whatever
default value I choose, such as a sequence number (SEQUENCE_NAME.nextval).

Hope this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Finding Numerals Within a String Field
> 
> Hi Ari,
> 
> I need your help in coming up with a solution for the following problem -
> 
> A table has a varchar2 column of width - 250. This comment column can be 
> used to store the social security number along with the user comments. I 
> need to determine if a column value has the SSN included. The user 
> entered comments will not contain any numerical information. I was 
> planning to determine the position of occurence of the first number and 
> then use substr to obtain the SSN, but was unable to come up with a SQL 
> statement which could do the job. 			
> 
> Thanks in anticipation
> Shrikant R Sawant
> 
> GE Corporate Research and Development 
> Schenectady, Albany NY
Shrikant,

Based on your note that no numerical information will be entered except for the
SSN, here is a solution:

SELECT ltrim(rtrim(translate(upper(SSN_COLUMN),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'                          ')))
FROM TABLE_NAME;

* The "upper" function converts the column to upper-case, which simplifies the
  "translate" function from repeating each alphabetical character in both upper
  and lower case.
* The "translate" command replaces all alphabetical characters with a space. If
  there will be other characters, such as !@#$%^+=,. and so on, add them to the
  translate function.
* The "ltrim" and "rtrim" commands will remove the spaces created by the
  "translate" function.

Hope that this helps!

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant



-------------------------------------------------------------------------------
(Note: Shrikant came up with another solution; Ari...)

Hi Ari,
Thanks for your prompt response. I took inspiration from your solution
and attempted to make it more generic so as to ensure that alphabetic (
upper as well lower ) and alphanumeric characters are taken care of with
minimal amount of hard-coding.

I came up with the following SQL statement -

SELECT SUBSTR(, INSTR( (TRANSLATE(,
'012345678', '999999999')), '9',1,1), 9 )
FROM table_name;

Translate will convert all numeric characters to 9 and instr will give me
the location of the first 9 ( effectively the location of the first 
numeric ). A substr can then be used to extract the 9 SSN digits starting
from the position reported by instr.

I believe that the above SQL should work for any combination of user
entered comments.

Thought that I would share the modified SQL with you.

Thanks again !

Regards,
Shrikant R Sawant

GE Corporate Research and Development
Schenectady, Albany NY
-------------------------------------------------------------------------------
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Using the TRUNCATE Command
> 
> Hai,
>      This is Regarding TRUNCATE.=20
> 
> I have the table =C9MP' with 15 records.
> 
> How do I delete the the Records alone using 'TRUNCATE' Command.
> 
> Thanks
> 
> fazal
> 
Fazal,

The syntax is:

TRUNCATE TABLE table_name;

Note that this is much quicker than the DELETE command below:

DELETE FROM table_name;

It is quicker because Oracle simply resets a high-water mark and frees up
newly freed extents. It does not use REDO functionality, and no triggers are
fired (if there are any for BEFORE/AFTER DELETE).

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Ensuring that the database does not hang due to archive volume filling
> 
> Dear sir,
> we work on a 24x7 system (called CMO) with a 7.3 Oracle database.
> The DB backup is performed through a commercial platform (Sun Solstice
> Backup)
> installed on CMO server; so scheduling, tape management etc are
> customized
> using the Backup platform.
> In field, when the CMO will be delivered, the CMO system should work
> with
> a generic system administrator, but a DBA is not in site, so it is not
> possible to monitor the DB as soon as a problem arises.
> The problem I have to solve is related to archived redo area saturation.
> Redos are backed up four times a day and a full DB backup is performed
> twice
> a week (the DB size is about 30GB).
> If for any problem the archived redo area becomes full, the DB hangs up.
> I must avoid this situation; and as the system is often unattended, I
> need 
> an automatic management of this situation.
> Redo backup can fail (for example, tape is switched off or there are no
> write
> permissions on tapes or ...) so the redo area is not cleaned up.
> The question is:
> how can I guarantee that the DB (in ARCHIVELOG mode, of course)
> works in any situation in automatic mode, with or without backups ?
> Keep in mind that the backup is considered only an optional feature, and
> the CMO system must work also without it, though DB is configured to
> work with.
> I don't know if you can provide me the solution (I hope yes); in any
> case
> I wish you address me to literature where a problem like this is
> treated.
> Best regards.
> 
> -- Andrea Sciessere
> -- Etnoteam S.p.A. - Solutions from ICT
> -- asciessere@etnoteam.it
> 
Andrea,

What you are experiencing is typical of many sites. As you noted, when the
archive redo log directory is filled up, the database hangs. One solution is
to automatically remove old archived redo logs after you copy them to tape.

The best solution is to ensure that you have enough disk space to hold all
archived redo logs for a few days, in the event that you have problems with
your tape devices.

If you want to ensure that your database will never hang, set up an automated
process (such as a cron job) to check the archive directory and remove the
oldest files if the directory is getting full. This can be done in many ways.
I like to use a cron job to set off a UNIX script. Some of these scripts can
be found in Oracle Press's "Oracle Backup and Recovery" books.

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

MaxExtents and Block Size
> 
> I searched your web page for an answer but couldn't find it.  I have read
> in a number of places that the hard-coded limit for number of extents is
> 249 if block size is 4k and 505 is blocksize is 8k.  However, I see, in
> our database, examples where the number of extents have exceeded this
> limit.  For example, our database is 4k blocksize but I find extents over
> 300.  What am I missing?
> 
> Thanks.
> 
> Glenn Wiens 
> Celeritas Technologies, LLC
> wiens@celeritas.net
> gwiens@dtc.net
> 
Glenn,

The limit that you describe is the default limit. In Oracle 7.3 and versions
above, you can specify MAXEXTENTS UNLIMITED which is just that - unlimited.
Unless you specify UNLIMITED, then you will still be bound by the numbers
you list above (121 extents for a 2K block size as well).

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Bringing Rollback Segs Online After Startup
> 
> How can I ensure that my rollback segments come back online after a server =
> (NT4) re-boot. I have
> looked in all the books but can find no reference to the problem.
> 
> Many thanks
> 
> Robin Coode
> 
Robin,

You must list each rollback segment in your initSID.ora file, such as the
following line:

rollback_segments               = (r01,r02,r03,r04) 

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Applying Redo Logs Twice
> 
> Dear Ari,
> 
> I have small doubt in Oracle Recovery.
> 
> What will happen if I apply archived redo log files to data files twice 
> at the same time during database recovery. Will there be any problem of 
> data duplication ?
> 
> Please send me the answer at your earlist.
> 
> Thanks and Regards,
> 
> Prashant 
> 

There will be NO problem of duplication with archived redo logs. Oracle keeps
track of which redo logs have been applied already. If you try to re-apply the
same log file, Oracle will just skip through it.

You will need to be careful if you import twice, with IGNORE=Y. Oracle will load
data in every time you issue such an import.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

select and update by row number
logicprobe@bbs.kis.net (Steve Crowe) writes:

>Hello,

>I am taking a CMIS course on databases. I am tring to update and query
>my database by row number. I have a table with 12,410 records in it. I
>need to query the 1st,  the 6,205th, and the 12,410th rows. I tried
>using RowNum in a where clause, but no dice. I also am thinking about
>using RowID, but I am not sure how to go about this.

Thanks for any help,
>Steve Crowe
>logicprobe@bbs.kis.net

Steve,

Using the ROWID would be too complicated for what you wish to do. ROWID 
uses codes for block id's and other "internal" numbering schemes.

Now, you need to determine what order the rows should be returned. That 
is - what is the significance of being the 6,205th row. Is it an 
alphabetical listing, etc? Without specifying an ORDER BY clause, it does 
not make much sense for the 6,205 and last rows...they will be returned 
arbitrarily and may differ from query to query (without an ORDER BY clause)

Try something on the lines of:

SELECT * FROM table_name
WHERE ROWNUM=1 or ROWNUM=6205 or ROWNUM=12410
ORDER BY ordering_column;

Best of luck!

-Ari Kaplan
Independent Oracle DBA Consultant


<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do you read REDO logs?
> 
> Hello Ari,
> 
> I just saw your web site and was most impressed with all your answers to
> Oracle questions.  I am new to Oracle and am having trouble locating
> information on a way to read the Oracle REDO log from a program.  Is there
> an API documented somewhere?  I need to do this for Oracle7 right now and
> Oracle8 in the near future.
> 
> Any help would be appreciated.
> 
> -Mike Stevens
> mike.stevens@mci2000.com
> 

If you issue the command:

alter session set events 'immediate trace name redohdr level 10';

then a dump of the complete log header is sent to your ../udump directory.
I am glad you like my web page. I plan on doing many changes in the near
future.

-Ari


Back to Ari Kaplan's Home Page

Archive Log performance
Haris Kusumo (ikusumo@elixir.com.au) wrote:
: Hi,
: 
: I am running oracle ver 7.2.2.x database on IBM RS/6K 970.
: I just enable archivelog on for backup and recovery purposes, so
: when the system crash I can recover it up to the last archivelog.
: 
: but for some reason, after archivelog is enable the system seems to be
: very slow...
: does the archivelog generally use a lot of system resources?
: 
: is there a way to set it so it doesn't uses alot of system resource?
: 
: I though the information written to the archivelog is
: update/delete/insert not select. am I right ?
: 
: I appreciated if you could e-mail me the reply to
: 	haris_kusumo@modusmedia.com or
: 	hkusumo@elixir.com.au
: 
: since I can't get access to new at work.
: 
: Thanks in advance
: - Haris -
Archivelog does not use up much resources. Your slower performance could
be due two three things:
1) You are putting your archive directory on the same drive as your redo
logs. This will be bad for performance, and should be put on a separate
drive, hopefully on a low-activity device.

2) Your redo log files are sized too small, and this is causing frequent
redo log switches. Increasing the size of all redo logs will improve this

3) Your archive volume's disk has filled up. If this is the case, your
database will more than slow down - it will effectively stop (except for
SELECT statements). Be sure to remove old archive logs daily,and monitor
your free space on the device with archive log files.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 132+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

7.3.2 init.ora parameters
 sarah.walsh@lmco.com wrote:
: I was surprised to learn that the default value for the parameter,
: COMPATIBLE is not the current release.  We are installing Oracle
: for the first time, we have release 7.3.2, are there any other
: parameters that must be set so we get the benefits of the release
: we purchased?  Is there a list of all the possible parameters and
: an example of setting each one?
: 
: -------------------==== Posted via Deja News ====-----------------------
:       http://www.dejanews.com/     Search, Read, Post to Usenet
Sarah,

Since there are several hundred parameters, I will not attempt to explain
them all in this email. There are many books that explain most of the
important ones. I recommend "Oracle Performance Tuning" by O'Reilly. I
would recommend the book I am co-authoring "Oracle8 How-To" by
Macmillan/Waite Group,
but it won't be out until a few weeks.

To see all parameters, and an example of each, go into Server Manager
(svrmgrl), issue CONNECT INTERNAL, and then issue SHOW PARAMETERS.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 132+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

INDEXFILE with exports
> 
> Hello Ari,
> 
>      Our backup of the ORACLE users are taken through export utility, 
> with INDEXES=N option. This fastens the export process and also the 
> importing of data becomes easy whenever required. We then create the 
> indexes on the objects of the table. We have written a pl/sql code for 
> spooling the indexes of each user and submitted it as a job. This script 
> will create a spool file with the 'create index ....' statements, along 
> with all the other parameters for that index. The problem is , where 
> should we look for the parameter about  if the index created with 
> 'ASCENDING' / 'DESCENDING' option ?
> 
> Regards,
> 
> S.Rammya &
> T.R.Satheesh
> DBA - Sundaram Finance Limited, Madras
> 

Greetings from the USA,


An easier method is to do "exp full=y INDEXFILE=cr_indexes.log".
The INDEXFILE will spool all CREATE INDEX statements (with storage parameters
and everything else) to the cr_indexes.log file. Note that Primary Keys are not
included.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 132+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Shutdown immediate problem
Marius Dreyer (dreyerm@iafrica.com) wrote:
: Hi everyone !
: 
: Has any ever done a shutdown immediate which did not shut down at all ?
: I know that if there is a long running transaction, it will take a while to
: rollback, but what if there is none ?
: Running 7.3.3 on Sun Solaris 2.51. 
: 
: Thanks in advance
: Marius
: 
: /* Africa is not for sissies */

Marius,

If someone is in the login process, then "shutdown immediate" will not
work, and will hang. Eventually, you will see a trace file saying "waiting
for logins to complete". For example, try issuing sqlplus, but when it
prompts you for a username/password, do not enter anything. Open another
window and try "shutdown immediate". You will see that Oracle will not
shut down.

You will either have to shutdown abort, or have a program kill all oracle
connections and then to a shutdown immediate.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 132+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Where does the data go during an import?
On Fri, 15 Jan 1999, Imel Rautenbach wrote:

> Hi.
>
> I am doing a import of large tables (500K to 2M records.)
> While the table is being imported I cannot see any datafiles grow.
> where does it load the data before it shows the no_of_recs in the import
> screen?
>
> Many Thanks
> Imel
>           
Imel,

The data is loaded into the ROLLBACK segment and not into the table. Right
before the index is created, Oracle implicitly COMMITs the data. At this
point, it is applied to the datafile.

If you don't want this to happen, you can use COMMIT=Y during your import.
Depending on how your rollback segments are configured, you can also
dramatically improve the time needed to import your data.

Best regards,  


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->  

Back to Ari Kaplan's Home Page

Finding the Database name
> 
> Dear Sir,
>           I have just installed Personal Oracle 8.0 for Windows 95 on my 
> system and just begun using it. How do you figure out what is the 
> Database Name ? Is there any way in Sql*Plus to repeat the last command 
> or do you have to type it all over again ?
> 
>                              Thanks !
> 
Hi,

First, you can find out the database name with the following query:

SELECT * FROM V$DATABASE;

To repeat the command in SQL*PLUS, type a slash (/) on a blank line and
hit return. SQL*PLUS has a nice little command-line editor to edit and
review your SQL commands. Type "l" and hit return to view your last command.
There are many ways to modify your commands...check out your manual for more
info on this.

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 230+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

1) Syntax for Hot Backups ; 2) SQLNET.LOG question
On Sat, 9 Jan 1999, Chan LL wrote:

> Hi,
>
> Need your advice about following questions:
>
> 1) For Oracle 7.1, if the hot-back job was not completed
>    successfully, the last last statment od the job is:
>
>    alter tablespace TBLSPC1 begin backup
>
>    Before shutdown the database, we need to issue the command        
>    "alter tablespace TBLSPC1 begin backup"  to end the backup
>    before shutdown the database. If not, will receive a message
>    "media need to recovery" after restart the database.

It should be "ALTER TABLESPACE TBLSPC1 END BACKUP" to end the backup
phase. Aside from that, you will need to do media recovery if the database
were shut down when any of the tablespaces are in "backup" mode. I do not
see any way around this.

>
>    Is there any way to restart the database without doing media
>    recovery to restart the database if this incidance happen?
>
> 2) I encounter problem to connect my PC to database server,
>    normally what is the cause of the problem? What is the log
>    file on the server can help trace for the problem beside
>    of the listener.log, sqlnet?      

The server may not have information on why the PC could not connect. Look
for a file called "SQLNET.LOG" on the PC that should have more
information.

>
> 3) If there is problem with the network layer of the server,
>    can this cause the connectivity problem? Can the problem
>    be solved without rebooting the server? What is the name
>    of the log files to trace the network problem of the server?
>    (Digital Open VMS with DECNET)

For this question, I would suggest either contacting Oracle support (if
you have it), or posting
your question on the internet (comp.databases.oracle.misc). You can also post
it on the newsgroup via "www.dejanews.com".  

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->    

Back to Ari Kaplan's Home Page

Generating CREATE INDEX commands through Export/Import
On Wed, 30 Dec 1998, Samir Mathur wrote:

> Hi Ari,
>
> I need to generate an Alter table script to add foreign keys for all the
> tables in a schema. Kinda struggling with it!! Have made a script for
> the primary keys though -- kindly help!!!
>
> set heading off
> set linesize 100
> set pagesize 1000
> set termout off  
> set echo off
> set feedback off
>
>  spool d:\tsql\gen_prim1.sql
>  select decode(POSITION,1,'ALTER TABLE '||a.TABLE_NAME||
>       ' ADD (constraint '||a.CONSTRAINT_NAME||' PRIMARY KEY ( ')||
>             decode(position,d.pos,column_name||'));',column_name||',')
>  from user_cons_columns a , user_constraints b,
>  (SELECT MAX(POSITION) pos ,table_name tab FROM user_cons_columns X
> WHERE CONSTRAINT_NAME IN (SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS Y
> WHERE Y.CONSTRAINT_TYPE='P'
> AND Y.TABLE_NAME=X.TABLE_NAME)
> group by table_name) d
>  where a.CONSTRAINT_NAME = b.CONSTRAINT_NAME
>  and a.TABLE_NAME = b.TABLE_NAME
>  and a.TABLE_NAME = d.tab
>  and a.OWNER   = b.OWNER          
>  and b.CONSTRAINT_TYPE = 'P'
>  order by a.table_name, A.CONSTRAINT_NAME, a.position;
>
>
> spool off
> set termout on
> set echo on
> set feedback on
>
> Would appreciate a prompt reply!!!
> Thanks...
> Warm regards,
>
Samir,

Glad that you like my page. I have not had time to look at your SQL that
much. I do have a quick suggestion. If you export your schema (no need to    
export the data), and then import it using the INDEXFILE option, you will
get all of your CREATE INDEX syntax. I use this a lot and hope that you
will too.

Export the data:

exp userid=username/password file=expdat.dmp rows=n owner=OWNER_NAME

This will create the expdat.dmp file with no data. To generate the CREATE
INDEX statements, do:

imp userid=username/password file=expdat.dmp full=y indexfile=FILE_NAME

The FILENAME will now have all CREATE INDEX statements that you need!

Best regards,    
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 245+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Re: "ORA-01555 snapshot too old and ORA-1658 unable to create
Newsgroups: comp.databases.oracle.misc
Subject: Re: "ORA-01555 snapshot too old and ORA-01658 unable to create
References: <32ade686.2955303@News.scruznet.com>

rhaven@santacruz.com (Richard C Haven) writes:
>We are getting these errors:
>01555: snapshot is too old; rollback segment number 4 with name "R03"
>too small
>01658: unable to create INITIAL extant for segment
>during SQL operations.
>Any ideas what causes this and workarounds?
>TIA

Richard,

For the ORA-1555, it appears that your rollback segment "R03" is too
small. You will need to use larger rollback segments. Drop and recreate
with a larger INITIAL and NEXT extents. Also, unless you specifically used
"R03" for the failed transaction, there is a good chance that your other
rollback segments are too small. Consider increasing the size of all
rollback segments.

For the ORA-1658, you could not create the object (table, index, etc.)
because it was too large for the amount of free "contiguous" space in the
tablespace. You can do one of two things:
1) Try recreating the object, but specify a smaller INITIAL size. This may
work for the short term, but it could leave you with a tablespace almost
completely filled. If the object grew in size, you run the risk of not
being able to get a new extent.
2) Add a datafile to your tablespace with sufficient room to fit your
object in.

Based on the two above errors, I would recommend reviewing all object
sizes and tablespace sizes. You may have made them too small.

Best of luck.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-01555 snapshot too old and ORA-01658 unable to create

Newsgroups: comp.databases.oracle.misc
Subject: Re: "ORA-01555 snapshot too old and ORA-01658 unable to create
References: <32ade686.2955303@News.scruznet.com>

rhaven@santacruz.com (Richard C Haven) writes:
>We are getting these errors:
>01555: snapshot is too old; rollback segment number 4 with name "R03"
>too small
>01658: unable to create INITIAL extant for segment
>during SQL operations.
>Any ideas what causes this and workarounds?
>TIA

Richard,

For the ORA-1555, it appears that your rollback segment "R03" is too
small. You will need to use larger rollback segments. Drop and recreate
with a larger INITIAL and NEXT extents. Also, unless you specifically used
"R03" for the failed transaction, there is a good chance that your other
rollback segments are too small. Consider increasing the size of all
rollback segments.

For the ORA-1658, you could not create the object (table, index, etc.)
because it was too large for the amount of free "contiguous" space in the
tablespace. You can do one of two things:
1) Try recreating the object, but specify a smaller INITIAL size. This may
work for the short term, but it could leave you with a tablespace almost
completely filled. If the object grew in size, you run the risk of not
being able to get a new extent.
2) Add a datafile to your tablespace with sufficient room to fit your
object in.

Based on the two above errors, I would recommend reviewing all object
sizes and tablespace sizes. You may have made them too small.

Best of luck.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Re: Rollback segments
Newsgroups: comp.databases.oracle.misc,comp.databases.oracle.server,comp.databases.oracle.tools
Subject: Re: Rollback segments
References: <01bbe786$9e7014c0$79b597ce@orion.sgi.net.sgi.net>

"Kochis"  writes:

>Trying to delete all the data from a table (6000 records)
>I recieved the following:
>Ora - 1562: Failed to extend rollback segments (Id=1)
>Ora - 1682: Max # extents (121) reached for rollback segment add_rb
>Did I run out of extents and I need to increase max?
>Did I run out of space in the rollback segment? (same as above?)
>Also,
>I have three rollback segments created and online.  Oracle always seems to
>use the first one i created?  Should I point it to a different one?
>thanks in advance for any help
>newbie
>djkochis@sgi.net

Your INITIAL and NEXT of the rollback segment "add_rb" is too small for
what you need to do. The ORA-1682 that you received tells you that the
OS-Dependent maximum number of extents (121 for your db_block_size) was
reached. You cannot increase this number past the 121 mark.

What you can do is drop and recreate the rollback segment with a much
larger INITIAL and NEXT (100 times the size should be fair). You will then
need to monitor the rollback segments again to see if the new size is
sufficient. You don't know at this point at which record of the 6000 it
failed, and you may one day need to delete more than 6000 records.

As for your second question, Oracle should pick different rollback
segments after each commit or rollback. Double-check that you are
specifying the rollback names in the init.ora/config.ora file, and that
the rollback segments are on-line. Aside from that, the user/application
would have had to specificly set the transaction to use the same rollback
segment each time in order to get the effects you described above.

Hope this helps....

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

How many cpu's does Oracle recognize?
> 
> Hi,
> 
> I have been reading through all the queries on your page at interaccess.
> 
> I have a query :
> 
> I have a multi-processor system. I need to determine how many CPUs are
> being used by oracle. How do i set the number of CPUs in the init files ?
> 
> Please reply.
> 
> Warm regards,
> ren
> 
Ren,

To find out how many CPUs your database is using, query the V$PARAMETER view:

SELECT name, value, isdefault
FROM v$parameter
WHERE name = 'cpu_count';

If you wish to change the value, add a line like the following to your
init.ora file:

cpu_count=8


Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 235+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Determining max concurrent users

Anastasio (alexi_anastasio@usa.net) wrote:
: We are using Oracle 7 on Unix and would like to see what the highest
: number of concurrent users has been. On an earlier version (PC platform)
: there was an entry in one of the log files that included a "High water
: mark" that would tell you that number. The only reference I can find to
: that "mark" now is for dataloading.
: Any suggestions?
: Thank you,
: alexi_anastasio@usa.net
The following script will show the current logons, cumulative logons
(the number of users that connected since the database started), and
highwater mark (highest number of simultaneous users since the database
started):

SELECT rpad(c.name||':',11)||
       rpad(' current logons='||(to_number(b.sessions_current)-1),20)||
       'cumulative logons='||rpad(substr(a.value,1,10),10)||
       'highwater mark='||b.sessions_highwater Information
FROM v\$sysstat a, v\$license b, v\$database c
WHERE a.name = 'logons cumulative'

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 132+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Memory & Oracle
 John Papadomichelakis
(michelos@freemail.gr) wrote:
: This is a multi-part message in MIME format.
: --------------A27FB5D79A0A911A0731C9B2
: Content-Type: text/plain; charset=iso-8859-7
: Content-Transfer-Encoding: 7bit
: 
: Hi..
: 
: We have an HPUX (HP 9000)systerm with 128MB that will support about 50
: or more users.
: 
: I believe that currently the database's startup parameters are for SMALL
: size.
: Are there some special parameters I can add to have better performance?
: I notice that changing the shared pool size from the default to a much
: bigger number, I had over 25% increase of speed in some queries.
: 
: Can I do anything more than that?
: 
: --
: 
: Papadomichelakis John
: "Unite for Java! - http://www.javalobby.org"
: __________________________________________________
: email : michelos@freemail.gr
: TEL   : 30 31 758 429,       30 31 709 796
: __________________________________________________
: 
: 
John,

There are too many parameters to go over in an email. I would suggest
reading
"Oracle Performance Tuning" by O'Reilly for Oracle7 databases. If you can
wait a few weeks, two books I co-authored will be coming out with advice
on this subject ("Oracle8 How-To" and "Special Edition: Oracle8").
Until then, it depends alot on your database as to which parameters to
adjust. Some of the more important ones are:

* db_block_buffers (how much data to buffer in memory to avoid going to
disk often). This is in increments of what your db_block_size is set to.
* shared_pool_size (you already tuned this)
* log_buffer
* cpu_count (must have 7.3; determines how many cpus on the box to use)

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 132+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-600
> 
> Dear Kaplan:
> 
> i am running oracle 6 on sco unix v3.2.4.2. today i
> encountered an error as :
>  oracle error 600 encountered 
>  interal error [4147] [17] [16]
> Now I can't access my application database.
> Hope you could give me a help . I am anxious to get
> your reply.Thanks a lot.
> 
> yours 
> phlip
> 

The ORA-600 is an internal error, and I cannot pinpoint it since there are
thousands of possibilities. What you should do is look in the trace directories
and the alert log. There may be accompanying error messages with the Orac-600.

Try starting the database. It may have just crashed, but still is in good shape.

If all else fails, call Oracle support - the [4147] [17] [16] are pointers that
will tell Oracle support which executable and line caused the crash.

Good luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 132+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

When was a table last had a record deleted/updated/inserted
> 
> Hi,
> In looking to an answer to my question I came across your web site.  It has
> a wealth of information in it that will really come in handy.  However, I
> did not find an answer to my question, maybe you can help. 
>    Do you know if there is a timestamp associated with a table each time
> there is a change such as delete, update, insert.
> I would like to know if the data in a table has changed since the last time
> I accessed it.
> My e-mail address is   TFelty@cpssys.com
> 
>   Thanks for the help!!!!!!!!!!    --Tracy
> 
Tracy,

Glad that you like my website and I hope you get more info from it. As for your
question, there is no way to determine the last update/insert/delete on a table
by default. What you have to do is use the AUDIT features of Oracle. It is
easy to understand and use. Basically, you can set an event such as an INSERT
to a particular table, and then information is added to an AUDIT TRAIL. The
AUDIT TRAIL can be either a table in Oracle or on the file system.

Information such as the timestamp and the user that issued the command is kept.
You can also add a trigger to the table (BEFORE INSERT, BEFORE UPDATE, etc.) to
make your own "auditing" functionality.

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 235+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Re: ANALYZE %
Newsgroups: comp.databases.oracle.misc
Subject: Re: ANALYZE %
References: <59h4fc$j3c@chaos.dac.neu.edu>

jglickma@lynx.dac.neu.edu (jon glickman) writes:

>Does anybody understand why I am seeing no change in the ALL_TABLES,
>DBA_TABLES... for the analyze sample 70 percent option of 
>when I query these tables for small databases.

-------(Parts of script cut by Ari Kaplan)------

>select 'analyze table '||owner||'.'||table_name||' estimate statistics
>sample 80 percent;'
>from sys.dba_tables
>where table_name like upper('&vname') and owner like upper ('&vowner');
>Any suggestions?
>					jglickma@lynx.neu.edu

Jon,

The statistics in the ALL_TABLES/DBA_TABLES (and other) views will NOT
change if the data in the table does not change. If you do
not UPDATE, DELETE, INSERT, etc., then no matter what percent you sample,
the evaluated statistics will not change.

However, if you do change the contents of the table (say by deleting 50%
of all records), then many statistics will change (NUM_ROWS for starters).

Hope this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Finding the total rows in the database
> 
> Hi Ari, would you please give me the solution of the following:-
> 
> 	- How can we calculate the total number of rows in oracle database and in
> this 	  way get size of database?
> 
> Thanks
> 
> 
There are three ways that come to mind to find the number of rows in the
database:

1) Use the ANALYZE built-in package to estimate or compute statistics for
   all users, then issue

   SELECT SUM(NUM_ROWS) FROM ALL_TABLES;

2) Export the database with FULL=Y. The output of the export will display the
   number of records for each table. You will manually add the numbers.

3) SELECT COUNT(*) from all tables. Since there could be a large number of
   tables, you can write a script to dynamically create another script:

   set header off
   set feedback off
   spool count_it.sql
   SELECT 'SELECT COUNT(*) FROM '||owner||'.'||table_name||';'
   FROM ALL_TABLES;
   spool off

Now, you have a script, "count_it.sql" that contains multiple SELECT COUNT(*)
statements. Run count_it.sql and add up the totals.

The above three methods are good to find the number of records. Since there
is overhead, such as free space within a block, and since each table has
differing data and column types, the number of records does not always give
an indication of the size of the data. To do this, type:

SELECT COUNT(distinct substr(rowid,1,8)) FROM table_name;

This will give the number of physical database blocks that the table data
occupies. Usually a database block is 2k, 4k or 8k. You should be able to
get the block size by looking at your initSID.ora file or configSID.ora file.
Do the above script for all tables.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Determining and changing ROLLBACK sizes
> 
> Hi Ari,
> 
> 
> Happy X'MAS and HAPPY NEW YEAR.
> 
> Please guide me how to determine the size of ROLLBACK SEGMENTS after 
> creation of database.
> 
> How will you change the size of ROLLBACK SEGMENTS according to 
> Application requirements.
> 
> Send me e-mail at your earlist.
> 
> Please help me . My DBA is on holiday.
> 
> 
> Regards
> 
> 
> PRASHANT SHINDGIKAR
> 
The size of the rollback segments depend mainly on if you are in a 
DSS environment (such as Data Warehousing) or OLTP (data entry, etc.).
If you are doing quick, short transactions, then the rollbacks should
be small (128k or so). Otherwise, it should be as large as required.
If you have a large batch update, for example, you should have large
rollback segments (10M - 200M or more).


If there is a mixed environment (short transactions along with some
larger batch processes), then have many small rollbacks and one large.
In the batch process ,you can say "ALTER SESSION USE ROLLBACK SEGMENT rblarge;"
to dedicate a specific rollback segment (until the next commit or rollback
statement).

Be sure to specify the rollback segments in the initSID.ora file so they will be
online when the database is shut down and restarted.

Also try to have at least one rollback segment for every four concurrent
transactions within the database; if there will be 100 users updating things
simultaneously, then have 25 rollback segments.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Re: URGENT: more extents needed!
>I know this is a basic question, but the database is complaining that it
>can't allocate extents while a user trys to update.  How do I do this? 
>I am using Oracle 6 for Netware, and we need more extents asap!
>Thanks!
>john
>============================================================
> John M. Duska                  |  Senior Systems Analyst
> mailto:duska@srfs.pitt.edu     |  Information Resources
> http://www.pitt.edu/~pauj4m    |  University of Pittsburgh
>============================================================

Your tablespace is not large enough to contain the table the user is
using.
What you will need to do is add more space to the tablespace:

ALTER TABLESPACE tablespace_name ADD DATAFILE 'path/filename' SIZE xx;

Substitute the tablespace_name, path, filename, and xx above with the read
values you are using. Size is specified in K or M (5M, 200K, etc).

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->



Back to Ari Kaplan's Home Page

How to learn SQL and PL/SQL

> 
> 
> Hello Mr Kaplan
> 
> 
> I am an Analyst Programmer experienced in C, Visual Basic and Foxpro. I =
> wish to learn Oracle SQL & PL/SQL. There are lots of good books out =
> there but I think it is important to be able to practice the coding. =
> Could you suggest any sources of software which would be of use to me. I =
> have a 486DX33 with 4MB of RAM with Ms Dos v 6 & Windows 3.1 (can =
> upgrade if necessary).
> 
> Any advice would be greatly appreciated.

There are FREE trial versions of Oracle that are available on www.oracle.com.
These are "Personal Oracle" which offers a full-fledged database. You may
need to get WindowsNT or Windows95 for this to work. It may also require more
than 4M memory. I would recommend getting a new Pentium with 16M+ and
Windows95/NT. They run for $1200 or so these days. Anyway, try it on your computer
first.  Personal Oracle comes with SQL and PL/SQL capabilities.

> 
> Many thanks
> 
> Graham C Bales
> 

You are welcome.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Becoming Oracle Certified

> 
> Hello Ari,
> 
> I enjoyed your Web site!  I was wondering if you might have a moment to 
> offer some free advice.  I have just graduated with a MS in MIS and 
> work at a small software company as a QA Engineer.  We develop and 
> application in Smalltalk and C++ that is the front end to an Oracle 
> database where we store our information and configuration info.  I 
> really love working with Oracle and we periodically have an Oracle 
> consultant in to help us do installations on various platforms, and 
> tuning, etc.  Myself and a developer are responsible for most of the 
> Oracle maintenance here also.  
> 
> My question is this:  How can I become Oracle certified (my company 
> will not spring or sanction this as we may be abandoning Oracle) and 
> what advice do you have for an Oracle DBA wannabe?  I am just beginning 
> in the field and would like to know from an expert what route will best 
> take me where I want to go.
> 
> Thanks very much for your time and for any advice!
> Cheers,
> Stacy Gray
> 
> 
> Stacygra@execpc.com
Hi Stacy....

Getting Oracle certified is a difficult process. I know skilled people that
failed the test. It usually requires 1-2 years of varied Oracle experience.

For sample tests, see Oracle Press's "Advanced Oracle Tuning" book, which has
about 150 test questions and answers. Other options are to download Personal
Oracle from the internet (www.oracle.com) so you can get experience installing
and using Oracle at your home.

Of course, I would recommend getting my books, especially "Oracle8 How-To" which
is coming out this week. There are dozens of easy-to-follow examples and
explanations from beginners to experts.

Two other ways to learn are to sign up for training, and/or go to Oracle
conferences. There is one coming up in May (Orlando - International Oracle Week)
and in September (San Francisco - Oracle Openworld). There are speeches,
technical sessions, training, and personal networking. Also, you can usually
take the certification test on-site.

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Toolkit II problem with Server Manager

> 
> Hi Ari,
> 
> Well, I am on a unix box  having Oracle 7.3 and I need to run server   
> manager. I heard that you should run exceed to get servermanager run. I   
> did execute exceed. By running server manager as given bellow it gives   
> this message. The name of the unix box is cobra.
> 
> cobra:/export/home/bpoikayil> svrmgrm   
>                                       
> 
> TK2-04097: Oracle Toolkit II's connection to the window system was   
> refused
> 
> note : I have logged into Unix through windows 95, desktop.
> Any help or hints are welcome
> 
> Thanks in advance for the same ...
> 
> Bijilal Poikayil
> ADP Claims Solutions Group.
> San Ramon

First, you must "telnet" directly onto the UNIX server. Do not logon to one
server, telnet into another, then run server manager.

Then, you must have the UNIX environment variable DISPLAY set. In my setting,
it is the IP address (of the PC), followed by a :0.0

For example, I do:

export DISPLAY=207.208.45.70:0.0

Then, Server Manager will work. You can also do Server Manager in line mode
with "svrmgrl".

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to rebuild indexes quickly
> 
> Hell Ari,
> 	  MERRY CHRISTMAS AND HAPPY NEW YEAR. THANKS ALOT FOR ALL
> 	  THE HELP I HAVE RECIEVED FROM YOU.
> 
> 	  PLEASE, COULD YOU HELP ME WITH A SCRIPT WHICH 
> 		CREATES AND DROP INDEXSES AND THEN USES THE ALTER INDEX
> 		REBUILD COMMAND TO REBUILD THE INDEX.
> 
> 	PLEASE, IS IT POSSIBLE THAT YOU CAN 
> 		ALTER INDEX ( CHANGE STORAGE PARAMETERS)
> 		THEN USE REBUILD INDEX. DOES IT WORK?
> 
> 	I NEED YOUR LAST HELP BEFORE THE YEAR ENDS.
> 	
> 	YOUR STUDENT
> 	FRANCIS	
> **********************************************************************
> " Graduate Life: It's not just a job. It's an indenture."	
> ********************************************************************
> Francis Ansah                      E-mail:ansah@shire.ntc.nokia.com        
> Nokia Telecommunications           Tel.:   +358-9-51123881
> P.O.Box 320,00045,Nokia Group      GSM:    040-5324081
> 

You can always alter a table or index and change the storage parameters.
The one exception is the INITIAL extent. To change the INITIAL extent
you will have to drop and recreate the object. Sample syntax for the alter
index command follows:

ALTER INDEX index_name STORAGE (next 20M pctincrease 0);

The  REBUILD command should be used on indexes for which the table had
many updates/insets/deletes. The syntax is:

ALTER INDEX index_name REBUILD;

Some other statements that can help you:

SELECT * FROM USER_INDEXES WHERE INDEX_NAME = 'index_name';

This will give you the storage parameters for the index.

SELECT * FROM USER_IND_COLUMNS WHERE INDEX_NAME = 'index_name';

The above will give you the columns on which the index is based.

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Renaming a database
> 
> Hi Ari,
> 
> 	I wish you a Happy New Year.
> 
> 	Could you give me a reply on What are the steps I have
> to do to rename an existing Oracle 7.3.2 database on HP-UX 10.20
> system?
> 
> Thanks in advance.
> 
> Girish
> 
> 
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> 
It's a lot of work. There are a few methods:

1) Create the new database with new files, export the old database, import
into the new database, then delete the old database
2) Issue "ALTER SYSTEM BACKUP CONTROLFILE TO TRACE", then modify the trace
file that is generated in the ../udump directory. Change the name of the
database there. Shut down the database. Set the ORACLE_SID environment
variable to the new SID name. Move all datafiles to new directories per OFA
compliance. Modify the trace file again to reflect the file locations, and
run the script.
3) Be sure to modify all sdcripts that point to the old SID, and change the
GLOBAL name so that Oracle's networking software can properly determine the
database when making connections.

Please read the documentation on the CREATE CONTROLFILE command, as I cannot
take responsibility for anything bad that may happen.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Re: SQL*Net message from SQL*Plus
Newsgroups: comp.databases.oracle.tools
Subject: Re: SQL*Net message from SQL*Plus
References: <32e78ae4.991750053@news.iglobal.net>

gressett@iglobal.net (David Gressett) writes:

>I can't connect to my  Oracle 7.1 server with my SQL*Plus 3.1; I get
>an error code ORA-06108;  The CD-ROM documentation has nothing that
>explains what this means.

According to my documentation,

06108, 00000, "NETTCP: connect to host failed"
// *Cause:  Connection attempt to remote host has failed. Probably means
//          that the SQL*Net TCP/IP server on the remote host is not up,
//          or the host itself is not up (check the latter by targeting
//          it with Telnet).
// *Action: Start the SQL*Net TCP/IP server process on the remote host.

Make sure you are pointing to the correct SID and make sure that SQL*Net is
up on the remote host.

Hope this helps...


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Re: Help ! problems with temp file
>Hello,

>I try to realize a query on my oracle base.
>This query is made of 4 joins concerning about 10 000 tuples.
>The answer is about 10 tuples.
>Unfortunately, I receive the following answer :

>"ORA-01658: unable to create INITIAL extent for segment in tablespace
>TEMP"

>I feel quite uncomfortable, as it wasn't happening in the beginning
>of the day...

>I have been testing some proC programs, and sometimes I had to kill
>them. Could it have polluted the temp file?

>Is there anyway to clean it or enlarge it?

>I must tell you that our DBA is on holidays...

>All help Welcome!!!!

>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>~ Matthieu EXBRAYAT	   |						~
>~ LISI - INSA Lyon	   | e-mail : exbrayat@lisiflory.insa-lyon.fr	
>~ 69621 Villeurbanne Cedex | 					
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Newsgroups: comp.databases.oracle.server
Subject: Re: Help ! problems with temp file
References: <32ECD18A.41C67EA6@lisiflory.insa-lyon.fr>

Matthieu,

What is happening is Oracle cannot handle processing the SQL statement in
memory (the size defined by the SORT_AREA_SIZE initialization parameter),so
it is using the TEMP tablespace. Oracle will create a temporary object
similar in theory to swapping for an operating system, and then clean in
up when finished with the SQL.

What is happening to you is that Oracle cannot find space in your TEMP
tablespace to even begin writing the temporary segment. This could be  
fixed with two methods.

Look at the default INITIAL EXTENT storage option for your TEMP
tablespace:

select initial_extent, next_extent, tablespace_name from user_tablespaces
where tabelspace_name = 'TEMP';

The above will tell you the INITIAL and NEXT for the temporary segments
that Oracle will need to create. Next you need to find out how much free
space is left:

select sum(bytes) from dba_free_space where tablespace_name = 'TEMP';

The problem you are having is that the INITIAL is more than the free
space.

Two options:
1) Reduce the size of the INITIAL (and possibly NEXT) for the tablespace:

alter tablespace temp default storage (INITIAL 1M NEXT 1M);

Please substitute "1M" for something smaller than the free space found
above...maybe 20% of the free space. Choose this option initially and see
if your problem is resolved. If not, try...

2) Increase the size of the tablespace:

alter tablespace TEMP add datafile '/disk1/oracle/temp_02.dbf' size 200M;

You will need to see what size is appropriate and what directory to put
the file in. A good size if you can fit it on disk  is the size of the
previous TEMP tablespace. The path and name in the above statement needs
to be changed to whatever the standard at your site is.

Good luck....

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For more Oracle tips, visit my Web Page:                      <->
<-> www.arikaplan.com                                             <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Adding Users
Newsgroups: comp.databases.oracle.misc
Subject: Re: Adding Users
References: <32ED346D.2781E494@cc.uq.oz.au>

Priya Tantry  writes:

>What is the best way of adding users to Oracle in bulk on Unix?

>Priya

Priya,

The answer to this question will depend on what type of privileges you wish
to assign to the users. If you want to categorize the users, use ROLES. This
way, you assign all privileges once to the role, then simply assign the users
you add to those roles.

To add users in bulk, I usually write a SQL script that allows the passing of
a parameter, such as:
____________________________________________________________________
create user &username identified by &passwd;
grant connect to &&username;
{follow with all other appropriate grants here}
____________________________________________________________________

You can then run the script and type in the username and password...

Hope this helps.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SQL Statement
Newsgroups: comp.databases.oracle.misc
Subject: Re: SQL Statement
References: <32EE4489.39E7@UWOADMIN.UWO.CA>

>Can anyone tell me why this is happening and what can be done to rectify
>this problem...

>I've got the following SQL...

>SELECT TABLE_A.COL_1, TABLE_A.COL_2, TABLE_A.COL_3
>FROM   DATABASE.TABLE_A
>WHERE  TABLE_A.COL_4 = 'VAR_1' AND
>       TABLE_A.COL_1 IN
>	    (SELECT /*+ INDEX(TABLE_B.INDEX_1) */ TABLE_B.COL_1
>	     FROM DATABASE.TABLE_B
>	     WHERE TABLE_B.COL_2 = 'VAR_2' AND
>		   TABLE_B.COL_3 = 'VAR_3' AND
>		   TABLE_B.COL_4 >= SYSDATE);

>Both Table_A and Table_B are 100,000+ rows!

>When I execute this, it works just fine up to a point!  If the
>sub-select returns less then ~8000 rows, the primary select excutes very
>quickly.  However, if the sub-select returns more than ~8000 rows, the
>primary select goes into a sweep.  The DBA's don't know why this is
>happening!  Is there something at the ORACLE side that needs to be set
>(eg. buffer sizes?, temp space?, indexes?).  I've also noticed that if I
>execute the sub-select on its own and return less than ~8000 rows and
>then re-execute right after, the results come back instantly.  However,
>if the sub-select returns more then ~8000 rows and I re-execute it, it
>takes the same amount of time as the original select (ie. the original
>results are not held in the buffer).

>Any ideas???

>Thanks!

>Paul Ferrie
>Advancement Services
>The University of Western Ontario
>DASPAF@UWOADMIN.UWO.CA

Paul Ferrie,
There are a few things you could check...first, if you are using the cost-based
optimizer, be sure that the statistics are current:

ANALYZE TABLE TABLE_A COMPUTE STATISTICS;

Next, check the "Hit Ratio" of your database block buffers. Issue the following:

select round(100*(a.value + b.value - c.value) /
       (a.value + b.value))
from   sys.v_$sysstat a,
       sys.v_$sysstat b,
       sys.v_$sysstat c
where  a.statistic# = 37 and
       b.statistic# = 38 and
       c.statistic# = 39;

This will tell you the hit ratio: if it is below 80% you should increase your
"db_block_buffers" initialization parameter. The amount of which to increase is
not within the scope of this email, but basically keep increasing it until your
hit ratio improves.

The reason that you were having improved performance the second time you execute
the statement is that the records are cached into memory, which is much quicker
than reading from disk.

Also, the query performance would rely on what columns TABLE_B.INDEX_1 
comprises. You may also want to place an index on TABLE_A.COL_1 to avoid a
full-table scan of TABLE_A. This will depend on the uniqueness and skew of
the data within that column, but based on what you've indicated I feel the
index will help.

Good luck to you,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Sequences are skipping numbers...
On Fri, 29 Jan 1999, amit p wrote:
> Dear Ari,
>
> Are Oracle sequences perfect i.e do they generate unique numbers in
> perfect order all the time ??.In our system most of our primary keys are
> based on sequences and it looks like all numbers generated are unique
> but not necessarily in right order.It tends to skip them
> sometimes .Is it a bug in oracle sequences,does it have any patch?.
> The version we use is 7.3.3 on HP-UX 10.20
> Pls let me know If you now anything about it, I would be extremely
> grateful to you
>
> Thanks,
> Amit
 
Amit,
 
What you are most likely experiencing is the normal behavior of sequences.
In order to ensure that there is no chance that a sequence provides the
same number to different sessions, Oracle caches the sequence values and
distributes them to all referring sessions. So, if two users are inserting
records into the table and one issues a ROLLBACK, the records containing
the sequence numbers are not inserted into the table. This results in
"missing" numbers in your primary key.
 
This should not be a problem, as long as the primary key is unique it will
serve its purpose.
 
Best regards,
 
-Ari Kaplan
Independent Oracle DBA Consultant
 
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 250+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Primary Key design

> 
> 
>      Mr. Kaplan,
> 
>      I am starting to work on Oracle and recently got into a discussion
>      about indexing in Oracle and I have a question.
> 
>      Is it advisable to add an "artificial" column of unique sequential
>      numbers and make that a primary key when the table already has a
>      unique column of "real" data that could instead be the primary key?
> 
>      Thank you.
>      JH

It is advisable if you feel that the "real" data will ever have a chance
of changing. Primary keys should never be based upon columns that may have
the data updated. Aside from that, there is no advantage to using a sequential
number that I can think of.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 150+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Dynamically selecting columns in SQL
On Wed, 27 Jan 1999, Medy Paridho wrote:

> Hi, Ari
> I am getting problem when I need some flexibility variables
>
> for example :
>
>   var1 := name;
>   var2 := age;
>
>   select var1,var2
>   from table
>   where var2 > 20;
>
> that is a simple example but I dont know, How I must coding in Oracle
> programs ?
>
> Please help me
>
>
> Medy
>
It is not so simple. You can either use SQL to generate SQL, or dynamic
SQL.

Using SQL to generate SQL, you can spool to a file and then run the file.
Dynamic SQL is more complicated and you should read a PL/SQL book (it
would take pages of explanation).

You can also use the & in SQL*Plus:

select &var1, &var2 from table where &var2 > 20;

Each time you run the statement you will be prompted to enter values for
var1 and var2.  

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 250+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Import into a non-empty table
> 
> Hello Ari
> Forget the first question of the day. I have find that I need a CTL file.
> My new question is: When I use the SQL*LOADER application the destination
> table must be empty.
> Is it possible that make an import in a non empty table
> 
> 
> Thank you 
> 
> Harold Levasseur  
> [hlevasseur@integrim.com]
> 
Harold,

In your control file, you can specify "INSERT", "APPEND", "REPLACE", or "TRUNCATE".
Insert, the default, will load data only if the table is empty.
Append will add new records.
Replace will delete the records in the table and replace them by loading new
        data, firing any triggers for each record.
Truncate will truncate the table and replace the old data with new data.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

The potential bad effects of moving a table from one tablespace to another
On Fri, 5 Feb 1999, Brian Gallagher wrote:
> Hi Ari,
>
> Firstly i think your resource is really great - thanks.
> i have a question:
> i have to move a table from SYSTEM tablespace to DATA tablespace.
> 1. export TABLE
> 2. drop table
> 3. Change user's account to
>    - remove their quota on SYSTEM
>    - give them a quota on DATA
> 4. import table
>
> Does this have any affect on grants ..... or anything else ? any
> help would be greatly appreciated
>
> thanks a lot and regards
> brian
>
Brian,

Excellent question, which no one has asked me before. Your steps are
almost perfect. Just add a step between 3 and 4 to change the default
tablespace of the user to DATA.

What export/import does is recreate all constraints, indexes, grants, and
statistics for the table.

What it does NOT do is recompile all procedures/views/packages that become
invalid when you drop the table. It also does not recreate all
FK constraints on other tables that were pointing to the dropped table.

To find all invalid objects:

select owner, segment_name, segment_type
from all_segments
where status = 'INVALID'
/

To recompile the invalidated objects:

alter procedure XXX compile;
alter view XXX compile;
alter package XXX compile;

To find all constraints pointing to the table (this must be done before
the table is dropped):

select * from all_constraints
where r_constraint_name in
     (select constraint_name from all_constraints
      where table_name = '***table_name***');

You will have to recreate all constraints by what is returned from the
above query.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 250+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

1. Who dropped a table? 2. What locks are blocking?
>
> Your web site is so usefull for Oracle Professional. Thank you for sharing
> your experties in Oracle.

My pleasure. Thanks for the positive feedback.

>
> I have questions that is bothering me:
>
> 1. Is there a way of finding-out when and by who a table or an object was
> deleted? If you do not have auditing on in Oracle. Since turing auditing on
> might affect the performance?

There is no way in Oracle to do this. As for performance, you can set an
audit just for tables that are deleted. This will not slow down
performance, as no other auditing is performed.

>
> 2. I have seen a lot of scripts to detect locks. But I am still looking for a
> script that can just tell me which locks are causing problems? I know there is
> utility in oracle to detect lock but in order to use that you have to run some
> scripts first. I am not sure how to use this utility.

The script is in $ORACLE_HOME/rdbms/admin, and it is called "utllockt.sql"
All you have to do is run it, and it will give you a "tree" structure of
which sessions are holding locks that are affecting other users.
>
> I would appriciate your help.
> Sarfraz
>
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 250+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Functions becoming invalid
Newsgroups: comp.databases.oracle.misc,comp.databases.oracle.server,comp.databases.oracle.tools
Subject: Re: Functions becoming invalid
References: <01bc13cd$ac8fcd20$2d433a82@hallucigenia> <32f9dde6.1733631@news.planet.net>

>Normally stored procedures and functions become invalid only when they are
>dependent on another object that has been recompiled - this was one of the
>reasons for the introduction of packages, btw.

>If your system is stable and this is happening I would call Oracle support,
>you may have a corruption in your data dictionary.

>Regards,
>jh

>"Glenn Stauffer"  wrote:

>>I administer a system which makes heavy use of stored functions and one in
>>particular is required for several key reporting views.  For some reason,
>>this function becomes invalid periodically and almost always after the
>>database is shutdown for backup and restarted.  Can someone advise me as to
>>why database objects and particularly functions become invalid and what
>>might cause a function to attain this state fairly frequently?
>>
>>Thanks,
>>
>>Glenn Stauffer


Stored functions and procedures can also become invalid when the table(s)
that they depend on get dropped. Check to see if users are dropping and
re-creating tables. Sometimes batch processes or data loading processes
drop and re-create tables. If so, your functions/procedures will become
invalid.

To help you narrow your search, look at the ALL_DEPENDENCIES table to find
out what objects (and their types) depend on the functions that get
invalidated.

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->



Back to Ari Kaplan's Home Page

Oracle Server Manager
Newsgroups: comp.databases.oracle.misc
Subject: Re: Oracle Server Manager
References: <32F9E4B7.FB6@hpbbn.bbn.hp.com>
 Werner Menges
 writes:

>Hi all,

>  I tried to shutdown a running database with the
>  ServerManager svrmgrl (line mode tool) but it
>  was only possible to stop the database with 'shutdown abort'.

>  No other db client had connected the database and it's also
>  impossible to stop with 'shutdown immediate".

>  Our database version is 7.3.2.2.

>  I would appreciate for any help?
>  Thanks in advance.

>Regards
>  Werner

There are only a few reasons why the Oracle database will not "shutdown
immediate". First, if a user is in the process of logging in, the database
will wait for "logins to complete." For example, this will happen if someone
types "sqlplus" and leaves the computer at the "Username:" prompt.

Also, some "zombie" UNIX processes will hold the database up. Otherwise,
you have an Oracle bug and should contact support.

The first thing that you should investigate is for any trace files in the
bdump, cdump, udump directories. The alert_{SID}.log could also have the
reason included.

Good luck to you,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Oracle Error when writing, deleting large amounts of data

Matthew Chappee (matthew@nospam.mattshouse.com) wrote:
: I get the following errors when writing or deleting large amounts of
: data.  It's starting to get really annoying.  What can I do to fix
: this?
: ORA-01562: failed to extend rollback segment number 8
: ORA-01628: max # extents (121) reached for rollback segment RB7
: 
: Thanks,
: Matthew
Matthew,

There are a few things you can try. First, if it is possible in your
situation, commit periodically so that the rollback segments never get
too large.

If this is not feasible for you, then you can either enlarge all of your
rollback segments or create one large rollback segment in addition to your
other rollback segments. If you feel that many processes will benefit from
larger rollbacks, then drop and recreate the segements with a much larger
initial and next storage clause. Be sure to specify OPTIMAL size so that
rollbacks have a chance to shrink back down.

The final option is to have your rollback segments as they are and add a
large rollback segment to be used just for your large inserts and deletes.
You will need at least 121 times the size as your other rollback
segments. To use the rollback segment, before the load/delete you must
specify:

SET TRANSACTION USE ROLLBACK SEGMENT segment_name;

When you do this, Oracle will force your session to use the larger
rollback segment. Every time you do a COMMIT, ROLLBACK, or DDL-statement
you must re-issue the above command.

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

cpu_count
Chris Kirke (cakirke@multiservice.com) wrote:
: any ideas on oracle's  use of the cpu_count init file parameter ??
: if i don't set it, a query of v$parameter shows it still set to 1
: on a multi-processor system.
: 
: SCO Open Server 5.0.4 w/mpx (2 or 4 processors)
: Oracle7 RDBMS V7.3.2.3
: 
: thanks,
: Chris

Chris,

You are correct - Oracle does not automatically detect the number of CPUs
on startup. By default the cpu_count will be 1. If you need to change it,
you must specify it in the init.ora parameter file.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What does flushing the shared pool do?
> 
> What does the following command do, and when should it be use.
> I am running Oracle 7.4 on NT.
> 
> ALTER SYSTEM FLUSH SHARED POOL.
> 
> 
> Thank You Very Much
> 
This will "flush" out, or clear, all SQL statements that are in the
Shared Pool Area. Oracle keeps track of each SQL statement that users execute.
It is stored parsed in memory so that if a SQL statement already has been
executed then Oracle does not need to re-parse it. The exception is if the
shared pool area is not large enough, then the least recently used SQL 
statements (except for pinned packages) will be removed from memory.

By flushing the shared pool, all SQL statements are removed from memory.


-Ari Kaplan
> 
> What does the following command do, and when should it be use.
> I am running Oracle 7.4 on NT.
> 
> ALTER SYSTEM FLUSH SHARED POOL.
> 
> 
> Thank You Very Much
> 

Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

1) Does Unique Constraint Exist? 2) How do you use HOST?
> 
> Dear Ari,
> 
> Thanx for ur replies to misc. questions:
> 
> I have few queries:
> 
> 1. HOST COMMAND:
> ------------------------
> 
> HOST command which works well under Win311 and WinNT does not seem to
> work
> under Win 95.  When issued, it comes out with the message:
> 
> Command not success.
> 
> When we run PLUS33.EXE instead of PLUS33W.exe, it shows:
> 
> Incorrect DOS Version
> Command not success
> 

You need to be sure to use the proper installation CD-Rom. All three usually
are on the same CD and it usually auto-detects the operating system. Try
re-installing SQL*Plus with all windows closed.

> 2. UNIQUE constraint:
> -----------------------
> 
>   How to find whether a unique constraint exists for a given column in a
> table?
> 
> Thanks in advance for ur answers.
> 
> -SrinivasanR
>  Chennai, India.
For unique constraints, type:

SELECT CONSTRAINT_NAME
FROM USER_CONSTRAINTS
WHERE TABLE_NAME=table_name
  AND CONSTRAINT_TYPE IN ('U','P');

This will give you all Unique and Primary keys for the table.

To find their indexes, you can type:

SELECT * FROM USER_IND_COLUMNS WHERE INDEX_NAME = index_name;

Or you can combine the above two:

SELECT * FROM USER_IND_COLUMNS WHERE INDEX_NAME IN
       (SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS
        WHERE TABLE_NAME=table_name AND
              CONSTRAINT_TYPE IN ('U','P') );

Best of luck and namaste...


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Do sequences get generated with an import?
On Tue, 9 Feb 1999, Mandalika Sankar wrote:

> Hi,
>   I would like to know if I do a full export from one database (db1)
>   and do a full import into another database (db2), are the sequences
>   automatically generated on db2? If so, how can I check them? I tried
>   the DUAL table but did not find any useful information in there.
> Thanks in advance,
> Sankar.
>
Sankar,

Yes, the sequences do get generated on db2. To check the sequences, issue:

SELECT * FROM DBA_SEQUENCES;

or

SELECT * FROM ALL_SEQUENCES;

To find the next value of a sequence, issue:

SELECT sequence_name.NEXTVAL from DUAL;

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 250+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SQL*Plus spooling problem
Newsgroups: comp.databases.oracle.server
Subject: Re: SQL*Plus spooling problem
References: <01bc1779$56ebb1e0$bcccbc8c@localhost.stl.prc.com>

"Greg Grooms"  writes:

>I'm spooling data from a select statement to a file in SQL*Plus on an old
>Oracle 5 database (not my database!).  The problem is with too many rows in
>the data file.  The data looks OK, but the select count(*) and the wc on
>the file never match.  Why would Oracle split up each row into multiple
>rows in the file?  

>I have tried:

>	select a, b, c from table1
>	select * from table1
>	select a||b||c from table1

>None work as I expect...1 line per row of data.

>Any ideas?

>Thanks

Greg,

This problem will occur not only in Oracle 5, but in 6 and 7 as well. What
is happening is once your line in the output exceeds 80 characters (the
default), Oracle will chop it into another line, adding a carriage return.
To fix this, set the linesize larger. For example,

SET LINESIZE 120

Do this in SQL*Plus before the select statement. Simply make the linesize
as large as you need.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

REDO log shifts are blocking for DB updates !!!
Subject: Re: REDO log shifts are blocking for DB updates !!!
Newsgroups: comp.databases.oracle.server,comp.databases.oracle.tools
References: <3300699E.3C39@nera.no>

In comp.databases.oracle.server you write:

>Hi !

>We are currently implementing a 'time critical' system where all
>accesses towards the DB must be guaranteed a response time less or equal
>to 150 milliseconds. 
>The transactions consists of both select and select for update
>statements.

>THE PROBLEM !!!
>Since transaction also contains updates, the REDO log file fills up and
>are switches on regular basis. During the switch the update statements
>are stalled/delayed for the same amount of time as it takes to switch
>REDO log file. Why ?????

>On average an update takes 25 milliseconds, but during the REDO log
>shift it is delayed for 3 SECONDS!!!!


>This has to be a 'classical' problem in 'this' database 'community' ?? 

>Are there any ways of configuring the instance (init.ora) such that LGWR
>will continue writing wile DBWR and CKPT completes there tasks during
>the REDO log shift?


>HW/SW CNFIGURATION:
>Running Oracle Server 7.3.2.2
>AlphaServer 4100 (2 CPUs), 1 GB RAM, 6 x 2.1 GB disks
>OpenVMS 7.1


>WHAT ALREADY HAS BEEN TESTED OUT!!!
>-Different sizes of REDO log files.
>-Multithreaded REDO log files.
>-The ALERT log does not contain any incomplete CHECKPOINT messages, 
>indicating that CHECKPOINTS are accumulated up, until the REDO log   
>shift.
>-Most init.ora parameters has been tested out. such as:
>  -db_block_buffers
>  -shared_pool_size,
>  -log_checkpoint_interval, 
>  -log_checkpoint_timeout, 
>  -log_checkpoint_to_alert=YES,
>  -db_block_checkpoint_batch,
>  -db_file_simultaneous_writes,
>  -log_buffers.

>-REDO log size has been tested out for the range 25K -> 10 MB, and we
>are currently 'stuck' on 3 MB.

>An attached WORD file will show the delay graphically. Both axis are in
>milliseconds.

>Any hints will be appreciated,


>Kjell R.

Kjell,

I have experienced the same behavior as what you describe. What you need
to do is make sure that all of your redo logs and archive directory are on
separate devices.

Otherwise, when there is a redo switch, the archiver process copies the
previously active redo log to the archive directory WHILE the new active
redo log is being used. If they are on the same device, you will have
major performance problems during each switch.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Am I running out of extents (fragmentation)?
Newsgroups: comp.databases.oracle.server
Subject: Re: Am I running out of extents (fragmentation)?
References: <32F79EE3.713E@mda.ca> <3300B6A7.748E@impsat1.com.ar>

Claudio Roca  writes:

>Simon Goland wrote:
>> 
>> Two tablespaces are giving problems to a user who cannot create more
>> tables. I ran the following query
>> 

>> Looking at the 'Free extents' I concluded that there is quite a bit of
>> fragmentation. So the solution is to do an export, drop the tablespaces,
>> recreate and import. Am I right? Is there anything else I should check
>> prior to this operation? It is somewhat strange to me because the
>> datafiles for these tablespaces are big - 2GB and 900MB (in the order
>> they appear above), and I don't think there is a lot of data in yet.
>> Maybe I should also modify some storage parameters for the tablespaces?
>> 
>> Thanks,
>> --
>> [ Simon Goland       B-)>     sg@mda.ca ]
>> [   Without action there is no change   ]
>If your datafiles are very big i would suggest you not to drop the
>tablespace but export the tables and drop them, then import them and the
>tablespace wil have one contiguous block of free space.
>I think there's no need to drop the tablespace.
>Hope this will help you.

Claudio,

If you have Oracle 7.3, you can eliminate free space fragmentation on the
fly, while users are using the database! You can type:

alter tablespace XXX coalesce;

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Getting data from the prior month
On Thu, 4 Feb 1999, Mark VanHorn wrote:
>      I have a question for you.  Suppose I want to run a query at any given
>      time during the current month which only generates activity for any
>      rows that were added (mytable.add_dte)in the prior month.  How would
>      the code look for this?  I can start:
>
>      SELECT *
>      FROM mytable m
>      WHERE m.add_dte ????????prior month?????????;
>
>      I always enjoy looking around your site.
>
>      Thanks,
>      Mark Van Horn
Mark,
       
To find the month value of the field, issue:
SELECT to_char(ADD_DTE,'MM') FROM mytable;

I am sure that there are more compact ways to do this, but to find the
value of the prior month, issue:
SELECT
decode(to_char(sysdate,'MM'),'01','12','02','01','03','02','04','03','05',
       '04','06','05','07','06','08','07','09','08',
       '10','09','11','10','12','11')
FROM mytable;

Now, to do your query (find all records from the previous month), issue:
SELECT * FROM mytable m
WHERE to_char(m.add_dte,'MM') =
decode(to_char(sysdate,'MM'),'01','12','02','01','03','02','04','03','05',
       '04','06','05','07','06','08','07','09','08',
       '10','09','11','10','12','11')

Note that this results in values from the prior month (ie ALL Januarys for
all years). You will have to modify this code for working with the
previous month of the current year (unless it is January, then it is the
December of the previous year). I did not know if that is what you meant.

Best regards,
       
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->   
<-> For 250+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Is Oracle Year2000 (Y2K) compliant?
On Tue, 9 Feb 1999, Jayendra Jadhav wrote:
> Dear Mr. Ari Kaplan ,
>
>  I was surfing through the net for some oracle queries when i came
> accross some of your talks.
>
>  I want some help from you regarding Oracle6. We are having Oracle6
> which is working ON a VOS operating system. VOS is the proprietary OS of
> STRATUS. Now making VOS Y2K compliant is a very heavy caost for us. So
> as a solution for Year 2000 we are thinking of rolling back the date in
> the VOS OS by 4 years. We have confirmed regarding the VOS that it will
> not have any problem due to rollback. We are now very much concerned
> regarding Oracle.With you good experience with Oracle do you think there
> should be any problem with Oracle system or Database.
>
>  Please do write to me.
>
>  With best regards
>
>  Jayendra
>
Jay,

There is a great article (several articles) on this month's (Jan/Feb 1999)
Oracle Magazine. It features all of the Y2K issues. For all information go to


www.oracle.com/year2000

"This site provides all that users need to know about the Y2K-compliance
status of Oracle's products. It contains information on Oracle Database
Server; Oracle development tools, including Designer and Developer; the
complete suite of Oracle Applications; and Oracle's other products".

It goes back to Oracle6.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 250+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Beginner: joining five tables
On Fri, 5 Feb 1999 soty@canada.com wrote:

> Dear Mr. Ari Kaplan: 
>
> I have checked your Oracle web site that is useful for our beginners.  
>
> However, I would like to know how to create a procedure that have to combine
> tables. 
> Example:
>
> tableA 1:2 tableB 1:2 tableD 1:2 tableE
> tableC 1:2 tableE
>
> tableA col1
>        col2 xx
>
> tableB col1
>        col4
>
> tableC col5
>        col6 xx
> 
> tableD col4
>        col7
>
> tableE col5
>        col7
>        col8 xx
> 
> Susan
>
You can make a simple SQL statement by using WHERE clauses in the select.

For your example:

SELECT * FROM tableA, tableB, tableC, tableD, tableE
WHERE tableA.COL1 = tableB.COL1 AND
      tableB.COL4 = tableD.COL4 AND
      tableC.COL5 = tableE.COL5 AND  
      tableD.COL7 = tableE.COL7;

To put this in a procedure, I assume you mean PL/SQL. If so, then you can
declare the above as a cursor.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Copying a database to another server while it is still up
> 
>      Help Help!!
>      
>      
>      A question:
>      
>      I need to copy a database that is up to another server while it is 
>      still up.  The database is in archive mode.  How would I do this?  The 
>      filesystems will be different.  Thanks so much.  Rhonda.
> 
There are three options:

1) Export database A in CONSISTENT=Y mode, ftp the export file to the new
   server. Create the database B, and import objects from the export file
   into database B. This will copy the database up to the point of the export.
2) On database A, type "ALTER DATABASE BACKUP CONTROLFILE TO TRACE;". This
   will make a script in the ../udump directory that will recreate control
   files. Shut down the database, ftp the datafiles to the new server, in the
   new filesystems. Modify the script in the ../udump directory to point to
   the new filesystems. Ftp the file to the new server and run it from
   Server Manager.
   If you don't want to shut down the originaldatabase, then you can mark
   tablespaces for hot backup, ftp the datafiles in the tablespace, and end
   the hot backup for the tablespace. Do this for each tablespace.
3) Create database B on the new server. You can create the objects by saying:
   CREATE table_a AS SELECT * FROM table_a@DATABASE_A;
   This will work as long as there are no LONG columns. Also, it will be
   harder since you'd have to do this for all tables, then copy over the
   indexes, grants, synonyms, procedures, packages, sequences, constraints,
   etc.

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

1) Dynamically creating tables 2) Has a column been indexed ASC or DESC?
> Dear AK,
> 
> Thanx a lot for answering my prev. questions. Now i have two more
> questions;
> 1. How to create tables dynamically based on the given date using
> SQL*Plus/Forms4.5?
>       For eg, if i enter 19-FEB-1998, the name of table to created is
> FEB19_1998 and so on.
> 2.  How to find out whether a column has been indexed in Ascending Order
> or Descending?
> Thanx in advance for ur. help.
> 
> -SrinivasanR
>  Chennai,India.
Namaste from the USA,

1. You will need to use dynamic SQL. This is with the DBMS_SQL package. You
   can create DML statements in any way you want. It's really powerful and
   flexible. You can specify the table name based on SYSDATE if you want this
   way.
2. As for ascending or descending, I do not know what you mean. Indexes are
   stored in a B-Tree fashion. The records can be selected in different orders
   based on the ORDER BY clause. In Oracle8 there are reverse-key indexes which
   store the index using the last byte of the column as the first byte of the
   index, the second-to-last byte of the column as the second byte of the
   index, etc.

**** Thanks to Hari Vesta for the following additions to this tip: *****

It is good thing to user Dynamic SQL. But Forms 4.5 has more power ful 
feature to create tables. Forms has a function called FORMS_DDL which 
takes sql statement as Varchar2 and submitts it to the Database.

Second thing to create indexes ASC or DESC. Oracle allows to created 
indexes in Ascending or descending order what you have to do is to 
specify the ASC or DESC after the column name. The default is ASC.

************************************************************************


Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

1) 7.3.2 on Linux? 2) Does import use extra disk space?
> 
> 
> Hallo Mr. Ari
> I have two question:
> 1.is Oracle Server 7.3.2 works on Linux ?
>   Is it worthing to install Linux on a PC and then
> have   an Oracle db on top of it ? 

Oracle7 is not available on Linux. Oracle8 will be available on Linux towards
the end of the year (1998).  You can get Oracle7 for Windows NT, though.

> 
> 2.Is the full db import using some extra disk space  
> while is working ? Because I have the db export file 
>  but my filesystem is pretty full and I would like to 
> 
No, import only uses the space for the import file (*.dmp). No
extra disk space is needed.

Best of luck.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Reverse-engineering CREATE TABLE with PARTITION commands
 I trying to locate a script for generating create table
 ddl for tables that have partitions.
 I want to generate the ddl for the partitions as well
 as the tables.

 Any suggestions...

 Thanks
-------------------------------------------------------------
Bret,

How have you been? I hope things are well with you.
As for your questions, I do not have any SQL that does this for
partitions. I have not seen such a thing around.

What you CAN do is use the export and import facilities to generate such a
script.

Export the table (or tables):

exp owner=partition_owner userid=username/passwd file=expdat.dmp

Import the table using the INDEXFILE option to generate a script with the
"CREATE" DDL:

imp fromuser=partition_owner indexfile=cr_table.sql file=expdat.dmp
userid=username/passwd show=y

The above will generate a file, "cr_table.sql" with the DDL for creating
indexes, partitions, and tables. Note that you should remove the REM
statements if you want to use the script.

Happy computing!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Cannot connect to Oracle using connect string
> 
> Hi Ari,
> 
> I am a D2K programmer. I am facing following problem.
> I request you to help me to solve the following problem.
> Environment
> -----------
> 
> Unix Server = HP-UX 9000
> ORACLE SOFTWARE = ORACLE 7.3
> 
> Clients = (Windows 95) Forms 4.5
> 
> 
> The problem is as follows.
> 
> If I connect from ORACLE_HOME
>  sqlplus scott/tiger ,
>     then
>     Oracle allows me to connect .
> 
> If I try to connect from other dir, then I can not connect.
> 
> Following Errors are displayed on the screen.
> 
>      ORA- 07320  Shmat error when trying to attach SGA.
>      ORA- 01034  Oracle not available
>      HP-UX ERROR 13    Permission denied.
> 
> 
> If log in as different Unix username and if I give following command
> 
>     $ sqlplus scott/tiger 
> 
> then Oracle allows me to connect.
> 
> Earlier, till yesterday, if I give command without giving connect string 
> , Oracle was allowing me to connect to Oracle on  HP server.
> 
> I am confused. What do you thing has gone wrong.
> 
> Please help me to solve this problem.
> 
> BYE
> PRASHANT

Make sure that the PATH environment variable is set correctly. If that
does not help, then type "env" for both the userid that works and
the usreid that does not. Look at the differences between the two
and see if any have an effect. If that fails, make sure that the Unix
group of the two users are the same; it could be that one user does
not have permissions to the Oracle executables.

When all fails, look at the listener.ora file in $ORACLE_HOME/network/admin.
If the read permissions are not there for world, you will get a similar
permission problem.

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Fixed format output
Newsgroups: comp.databases.oracle.server
Subject: Re: Fixed format output
References: <5f486h$eah@news.more.net>

turner@more.net (David Turner) writes:

>	Does anyone know how to format the output for the 
>dbms_output.put_line. Or possibly another function that will do fixed format
>output. 

>					Thanks David Turner

You can use the RPAD and SUBSTR functions to make a fixed format output.
For example, to ensure that a column XXX is 30 characters:

dbms_output.put_line(rpad(substr(XXX,1,30),30);

The SUBSTR(XXX,1,30) will output up to the first 30 characters.
The RPAD(...,30) will append spaces to make the string 30
characters.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

DB_FILE_MULTIBLOCK_READ_COUNT
Newsgroups: comp.databases.oracle.server
Subject: Re: DB_FILE_MULTIBLOCK_READ_COUNT
References: <3316EAE8.F8@cswv.com>

Dave Costa  writes:

>Is the value of the initialization parameter
>DB_FILE_MULTIBLOCK_READ_COUNT to be specified in OS blocks,
>or in Oracle DB blocks?  I assume the latter, but I'd like to
>find some confirmation, and it isn't clarified in the 
>Administrator's Guide.

It is in Oracle blocks. Usually it is set to 8 for online TP and up to 32
for DSS/Warehousing/batch.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Archiving data onto a second instance
> 
> Hi, I want to archive data by passing table name and date column as parameter
> to 
> new instance from production database  on the same Hard drive with the same 
> tables and column names and then delete the archived data from production 
> database. Oracle 7.3 on nt 4.0.How do i create new instance + any help will be
> appreciatable. 
> 
> email:rkreddy@hotmail.com 
>           rkreddy@aol.com 
> 
> Thanks in advance 
> 
You will first need to set up your second database. Change your ORACLE_SID
and use the "CREATE DATABASE" command, along with all other create statements
to create a second "archive" database.

Make sure that you have your listener configured for both databases. Check
the $ORACLE_HOME/network/admin files for correctness.

You can use dynamic SQL to create a function to INSERT data into the archive
database and DELETE from the production database. You can also do this manually
in SQL. For example, do the following SQL to create the table and insert data
into archive:

CREATE TABLE table1@archive_database AS
SELECT * FROM table1@production_database
WHERE date_column < TO_DATE('01-MAR-95');

Then, you can delete it from production:

DELETE FROM table1@production_database
WHERE date_column < TO_DATE('01-MAR-95');

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Exporting An Oracle Table in ASCII"

Johan Ulff  writes: >Is there anybody who knows how to export a table from ORACLE to an 
>ordinary ASCII file?
>I know there an EXP command i Oracle that writes an archive dump file 
>file in a Oracle format but I don't find any way to use this command to 
>export to an ASCII file instead.
>Is the only way to use embedded SQL from a C or VB program and write the 
>ASCII file?

There is a much simpler way. Using SQL*Plus, you can create an ASCII 
file, delimiting all fields with any character you want.
For example, suppose you want to create a comma-delimited file for the 
following table:
Table BATTER:
name varchar2(30),
hr   varchar2(3),
rbi  varchar2(3),
batting_avg  varchar2(5)
To make the file, write the following script:
-----------------------------------------------------------
set pagesize 0
set pause off
set header off
spool ASCII_FILE
select name||','||hr||','||rbi||','||batting_avg
from BATTER;
spool off
------------------------------------------------------------
Note that the commas will serve as the delimiters, and can be
easily changed to whatever you need. Also, Oracle adds ".lst" to the name
of the spool file unless you specify another extension.
Good luck!
-Ari Kaplan

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> email   :akaplan@interaccess.com                     <->
<-> WEBPAGE :www.arikaplan.com                           <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ora 01534: problems with Rollback Segments
On Thu, 25 Feb 1999, Manish Modi wrote:

> Hi Mr.Kaplan,
> 
> Can you tell me how to fix this kind of errors.
> 
> SVRMGR> connect internal
> Connected to an idle instance.
> SVRMGR> startup
> ORACLE instance started.
> Total System Global Area      36383036 bytes
> Fixed Size                       39808 bytes
> Variable Size                 19795388 bytes
> Database Buffers              16384000 bytes
> Redo Buffers                    163840 bytes
> Database mounted.
> ORA-01534: rollback segment 'R05' doesn't exist
> SVRMGR> quit
> Server Manager complete.
> $ oerr ora 01534
> 01534, 00000, "rollback segment '%s' doesn't exist"
> // *Cause:  During ALTER or DROP ROLLBACK SEGMENT, the specified
> //         rollback segment name is unknown.
> // *Action:  Use the correct rollback segment name.
> 
> 
> How to enter into the oracle and do all the required changes.
> Thanks.
> With Regard,
> Manish Modi.

Manish,What is happening is that you have some rollback segments specified in
your INIT.ORA file that do not exist in the database.

Comment out the line in the INIT.ORA that has "rollback_segments = " in
it. You can comment out a line by putting "#" at the beginning of the
line.

Start up your database. You now need to create the rollback segments that
are specified in the INIT.ORA file, uncomment out the "rollback_segments
=" line and restart the database.
  
This should do it.

-Ari Kaplan   
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <-> 
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->  
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Reporting on contiguous freespace sizes for each tablespace
> Ari,
> 
> I have a very useful script which reports on Spacebound objects. To
> get around
> these spacebound problems, I tend to amend the next extent on the
> object size to be
> equal or below the largest amount of contiguous freespace on the
> tablespace.
> 
> I have many scripts that report on freespace for each tablespace.
> Although these
> are very useful, I really need a report that will give me a list of 
> contiguous freespace sizes
> on each tablespace.
> 
> I have a tool that reports this (at work) , but seeing that I
> sometimes have to work from home, I
> really need a SQL script that can do this.
> 
> Can you help ?
> Thankyou,
> 
> Martin.
Sure. To report the freespace sizes in each tablespace, do the following:

SELECT a.TABLESPACE_NAME, b.FILE_NAME, a.bytes
FROM DBA_FREE_SPACE a, DBA_DATA_FILES b
WHERE a.FILE_ID = b.FILE_ID
ORDER BY a.TABLESPACE_NAME, a.BYTES
/

-or- if you want in megs, do the following:

SELECT a.TABLESPACE_NAME, b.FILE_NAME, a.bytes/1024/1024 "Megs"
FROM DBA_FREE_SPACE a, DBA_DATA_FILES b
WHERE a.FILE_ID = b.FILE_ID
ORDER BY a.TABLESPACE_NAME, a.BYTES
/

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Recovering data with export and archived redo logs
On Tue, 2 Mar 1999, Manish Modi wrote:
> I am taking an import of particular file and i have read that you can
> have a bakup .
> How to turn the archived redo logs on in case you might have disk
> failure and you can recover your data.
>
> Thanks,
> Manish
Manish,

I am not sure what you mean in your first sentence. If you are using the
IMPORT and EXPORT utilities, then you cannot use redo logs to recover your
database to the point of failure. You may only use them to recover up to
the point that the EXPORT was started.

If you wish to turn on archiving, follow the steps below. With archiving
and a good backup scheme, you can recover your database up to the point of
the crash.

* Check the current archiving status of the database:

SQL> select * from v$database;
 
NAME      CREATED              LOG_MODE     CHECKPOINT_CHANGE# ARCHIVE_CHANGE#
--------- -------------------- ------------ ------------------ ----------
MYDB01    10/14/98 10:58:16    NOARCHIVELOG 19041917           19040163

You can see that the database is not in archivelog mode.

* Change the database to archivelog mode:

SQL> ALTER DATABASE ARCHIVELOG;

Database altered.

* Now, shut down the database and modify the init.ora parameter file.
  Add the line:

log_archive_start=TRUE
 
  Also add the format of the log files and the destination directory.
  Sample lines are shown below:

log_archive_dest=?/dbs/arch
log_archive_format=%t_%s.dbf

  The above will put the files in the ~/dbs/arch directory, with the time
  and lognumber in the name of the archived redo log.

* Be sure to monitor and delete old archived redo logs, or the disk may
fill up. If it does, then your database will all but freeze.

Best regards,
  
-Ari Kaplan
Independent Oracle DBA Consultant
 
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

core dump while querying large tables
Newsgroups: comp.databases.oracle.misc
Subject: Re: core dump while querying large tables
References: <01bc27b5$5049a9e0$7c002f96@CV>

"Spatial Knowledge Systems"  writes:

>When I do a select with some clauses on a large table, Oracle generates a
>core dump and the proces is stopped.
>Can anyone explain what the problem is here ? ( I am using Oracle 7 on IRIX
>5.3)

>Manon

Manon,

Look in your bdump, cdump, and udump directories for trace files. Also
check the alert_{SID}.log file. These should contain further information
for you to use in debugging.

If you get a core dump, it sounds likely that there is an ORA-600 internal
error. Perhaps a corrupt data block or db_writer problem. Regardless, the
files described above should give you guidance.

Good luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

UPDATE with multiple tables
> Need help with an UPDATE statement involving multiple tables in Oracle8.
> Here it is:
> UPDATE employees e, address a SET e.division ='North America'
> where e.employee_id = a.employee_id
> and a.country ='USA'
> 
> I am experiencing problems with having multiple tables in the UPDATE clause.
> In my actual query, I have many more tables with aliases in the UPDATE clause
> table-specification.
> 
> Will appreciate any help.
> 
> Thanks.
Vanita,

You can only UPDATE one table. So, you can change your SQL to the following:

UPDATE employees e
SET e.division = 'North America'
WHERE exists
     (SELECT a.employee_id
      FROM address a
      WHERE a.country='USA' AND
            a.employee_id = e.employee_id)
/

This will have the same effect as your SQL, but will work with Oracle.

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Renaming a database on NT 4.0
> 
> How to rename a database 7.3.3.01 on NT 4.0 
> thanks,
> 
1) Issue "alter database backup controlfile to trace"
2) modify the file found in the ../udump directory to reflect the new
   name and directory. Use "rename database" option.
3) change the name and directories of all datafiles for OFA compliance
   (it should have the new database name in it). This part is technically
   not necessary but should be done for naming conventions
4) shutdown the database and BACKUP everything, just in case....
5) run the script from step #2

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Which SQL statements are being executed?
> 
> Hi,
> Can U tell me how do I find out as which OSUSER(Operating system User)
> an SQL statement is being executed in the oracle database.
> 
> I have tried looking into v$session and v$session_connect_info but both
> return multiple OSUSER.
> 
> The situation is like this  ---
> We have one dbuser which is being used by different persons in the
> organization. I want to know exactly who is making the changes in the
> database. That I can do only when I know the OSUSER.
> 
> Thanks for Your time.
> Mayank ( mayankn@mach-usa.com )
> 
Mayank,

You can issue the following query:

SELECT SQL_TEXT
FROM V$SQLAREA
WHERE (ADDRESS, HASH_VALUE) IN
      (SELECT SQL_ADDRESS, SQL_HASH_VALUE
       FROM V$SESSION
       WHERE SID = &sid_number)
/

You will be prompted for the Oracle SID.
You can get user information from the following SQL:

SELECT USERNAME, OSUSER, TERMINAL, SID, SERIAL#,
       PROCESS, PROGRAM
FROM V$SESSION
ORDER BY OSUSER
/

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Table sizing for data warehouse implementation
> 
> We are in the process of creating objects for our data warehouse
> database using Oracle 7.3 on an HP platform.  One of our table sizing
> estimates indicate that the total space needed for two years of data is
> 4.5G.
> 
> What is the largest recommended size to specify in the create table
> storage clause for the inital and next parameters?
> 
> Any help is appreciated.

The HP platform has a 2 gigabyte file limit. This means that your datafiles
cannot exceed 2 gigabytes, and thus your table extents. So, at most you can
have a 2G extent, another 2G extent, and a .5G extent.

However, I prefer to keep my tablespace datafiles 500M, for quickening recovery
times and moving datafiles around drives when needed.

For performance, you should consider using Oracle8's table partitioning for
large tables such as yours.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Storing data in different tables (...or partitions...)
On Fri, 5 Mar 1999, Dhaval Rasania wrote:
>
> Sir,
>
> I am having a great problem . I am using D2K 2.0 as my development tool
> and Oracle 8.0 as back end tool. I am developing Bank accounting
> Reconciliation
> System, I have desinged forms 5.0 modules for all functions in the
> system.
> The problem is that, in the form modules, Forms5.0 allows me to link a
> table
> to the Data Block at design time only, but I want to maintain seperate
> table
> for each month transactions. i.e all Credit Transactions for April
> should be
> entered in a table called CRED_9904, where 9904 is the text item in a
> entry form, based on this text item, I created a table CRED_9904 using
> FORMS_DDL built in, but the problem is that forms gives an error while
> Inserting data in to this table. i.e
>
> Insert into Table_name... where table_name is a string containing
> CRED_9904.
>
> The same problem I encountered while Selecting data.
> Select * from Table_name, here it do not allow a  string of table name.
>
> I request your goodself to assist in this matter.
> Also suggest, is it a right way to manupulate data for each month..?
> If not suggest the best possible way, so that I can maintain
> transactions of
> each month in a seperate table.
>
> Thanks in Advance
> Dhaval C Rasania
> dc_rasania@yahoo.com
> dc_rasania@hotmail.com
>
>
--------------------------------------------------------------------------
Dhaval,

The best way to store different months in different "tables" is to use a
partitioned table. You can define each partition on a different month.
Oracle will automatically store the data in the appropriate partition
based on the month with no change to your forms.

For example, if you insert a record for July 1999, it will get stored in
the July1999 partition. When you select data, Oracle automatically knows
which partition to look at. You just supply the overall table name.

The other plusses are that you can have separate INITAL/NEXT/PCTUSED/etc
storage parameters for each partition. You can bring up and down
partitions at will. You can store partitions on separate tablespaces, and
with different statistics.

The only downside is that you have to create the partition and write the
SQL (which is trickier than a CREATE TABLE, but worth it in your case).

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Is DROP TABLE recorded in the redo logs?
"Julia Cristina Varela de Montoya"  wrote:
> When a table is dropped, is that happening logged in the redo logs so to
> restore to this point in time?  We are on version 7.3.4 by the way.
> 
> Many many thanks.
> 
Julia,

Yes, *ALL* DML and DDL, including DROP TABLE is recorded in the redo logs /
archived redo logs. If you restore to a point in time, this information will be
used to restore the database. So, after restoring, your table that was DROPped
will no longer be there.

Best regards,
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Where are the files associated with my database?
"T. Kao"  wrote:
> I am new to Personal Oracle 8. Can someone tell me where oracle store all
> those data that I entered into a Table, etc. ?  Under what directory is the
> data base data file, control files etc are stored?
> Thanks.
> 
You can use SQL to find where all of your files are:

DATABASE FILES:

select * from dba_data_files;

CONTROL FILES:

select * from v$controlfile;

REDO LOG FILES:

select * from v$logfile;

PARAMETER FILE:

select * from v$parameter where name = 'ifile';

BACKGROUND DUMP FILES:

select * from v$parameter
where name in ('background_dump_dest','core_dump_dest','user_dump_dest');

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 265+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do you query ROLLBACK SEGMENTS? Are there temporary tables? ...
> 
> Hai! Ari Kaplan,
> 
> I am P.R.K.V. SARMA and I work with ORACLE7 WORKGROUP SERVER (7.3.X) on WINDOWS NT 4.
> I recently visited your web site. I found lot of interesting stuff on ORACLE. 
> Thanks for maintaining it.
> 
> Can U please send me all the FAQ U have and any interesting stuff which
> will help me to upgrade to ORACLE8.

I do not have any FAQs, but check out www.ioug.org or www.oracle.com for some.

> 
> Presently I have few problems :
> 
> 1. May be this is foolish, but how to query the ROLLBACK SEGMENTS ?
> 
> Let us say I delete from EMP table :
>    
>   delete from emp where sal > 5000;
> 
> and let us say 5 rows got deleted.
> 
> I didn't ROLLBACK or COMMIT. So the deleted rows still exist in 
> ROLLBACK SEGMENTS. Now how do I query the deleted rows ?

There is no way to do this. The rollback segments are in internal Oracle
format. The only thing I can think of is to open another session. Since you
have not COMMITted yet, the other sessions will be able to see the
deleted rows. In the other session, type:

SELECT FROM emp WHERE sal > 5000;

This will show the 5 rows.

> 
> 2. In MS SQL SERVER, I can create a temporary table and do all the
>    operations with the temporary table by just prefixing # to the 
>    tablename
> 
> CREATE TABLE #MY_TABLE ( FIRST_COLUMN ....
> 
>    so the above table #MY_TABLE is a temporary one stored in TEMPDB and later when
>    we disconnect, will be droped.
> 
> IS THIS AVAILABLE IN ORACLE ?  IF YES THEN HOW TO DO IT ?

This is available in PL/SQL, but not in regular SQL. An explanation of PL/SQL
can be had in many books. My favorite is O'Reilly's "PL/SQL Programming"
by Steve Feuerstein. You can create a CURSOR which exists until you either
close the cursor or disconnect from the database.
> 
> 3. Using PRO*C, when I connect, I write :
> 
>    EXEC SQL CONNECT :UID IDENTIFIED BY :PWD;
> 
>    where UID & PWD are host variables declared and accepted.
>    but how do I specify the CONNECT STRING ?

I hope I am answering ths correctly. Try:

EXEC SQL CONNECT :UID@HOST_STRING IDENTIFIED BY :PWD;

> 
> 4. How do I count number of rows available in a table without using COUNT function.
>    Can I use DECODE function ?  If yes, then please show me how.
> 

There are two ways to determine the number of records:
1) SELECT COUNT(*) FROM table_name;
2) ANALYZE TABLE the_table_name ESTIMATE STATISTICS;
   SELECT NUM_ROWS FROM ALL_TABLES
   WHERE TABLE_NAME = 'the_table_name';
> Thanks again.
No problem.

-Ari

Back to Ari Kaplan's Home Page

"Product user profile information not loaded"? Why?
Newsgroups: comp.databases.oracle.misc
Subject: Re: "Product user profile information not loaded"? Why?
References: <19970311204400.PAA12923@ladder01.news.aol.com>

josephs221@aol.com (JosephS221) writes:

>I just created a new database under Oracle 7.2.3 on an AT&T 3000 box.
>When I set it as my ORACLE_SID, and invoke SQL*PLUS, I get the above
>message. It also messages me that:
>Table or view does not exist.
>Error in disabling roles in product user profile.
>What did I do wrong, and how do I fix it? Thanks in advance for your help!

Joseph,

The PRODUCT_USER_PROFILE table does not exist. You need to create it by
running the "pupbld.sql" file. It appears in the
$ORACLE_HOME/sqlplus/admin directory. You need to run this as the SYSTEM
user. This should be run during all database creations.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->             www.arikaplan.com                                 <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What are my OPEN_CURSORS and MAX_OPEN_CURSORS?
On Mon, 8 Mar 1999, PG wrote:
> Hi Ari
>
> I had a look at a database and i've seen the following thing :
> open cursors = 50 (default)
> opened cursors current = 475
> Sometimes the user gets ora 1000 max open cursor exceeds.
>
> I can not find any trace of open_cursors or max_open_cursors in the
> init..ora file
> Where is max_open_cursors defined ??  what can i verify or do ???
> Peggy Gies
> Compex-LIS N.V.
> peggy.gies@compex.be
> tel direct :  (32) 54 31 86 21
> tel central: (32) 54 31 86 10
> Fax: (32) 54 34 45 10
>
Peggy,

For any Oracle parameter that is not defined in the init.ora file, the
default is taken. To find out all parameters that have the default values
(in your case max_open_cursors), issue:

select name, value
from v$parameter
where isdefault = 'TRUE';

To find all other parameters, issue:

select name, value
from v$parameter
where isdefault != 'TRUE';

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 270+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

newbie.. start services/database
Newsgroups: comp.databases.oracle.server
Subject: Re: newbie.. start services/database
References: <5gbkem$dva@chronicle.concentric.net>


 ait@concentric.net (jeff kish) writes:
>Sorry for this question, but our trained people just left and here I
>am in charge!!
>I have read the documentation and was wondering, what is the
>difference between starting the oracle services for a given SID and
>starting the database itself? The reason I ask is that when we do a
>backup, we stop the services, and after the backup is done we start
>the services again (automagically from a .bat file) under NT 3.51,
>Oracle 7.3.
>However when I get in in the morning, even though the services are
>started, the database won't respond until I stop and restart the
>services.
>Thanks for any knowledgeble replies and assistance!
>Jeff Kish
>Applied Image Technology
>ait@concentric.net

Jeff,

Look at how the database is started in the *.bat file. If it includes
"startup nomount" or "startup mount" as the final step, then the Oracle
background processes start (pmon, smon, dbwr, etc) bu the database will
not be available for people to access.

The last step of the startup script should be either "startup" or "alter
database open", the latter if the database has been started but not
opened.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What are the new features of Oracle8?
On Fri, 19 Mar 1999 aashis@bom3.vsnl.net.in wrote:

> Hi Ari,
> I would like to know the difference between Oracle8  and Oracle 7.x. I
> know it may be a very vast subject to explain, but if you could just
> briefly give me an overview of the basic differences between them ,it
> would be great..like what's available in Oracle 8 which isn't in the
> older versions etc.
> Looking forward to your reply,
> Thanking you,
> Parul Sheth
>
Parul,

You are correct in that it would take a while to explain the differences.
The most important are listed below:

* Datatypes: new ones (BLOB, BFILE, CLOB, etc) and larger VARCHAR (4000)
* Tables support 1000 co,umns
* Partitioned tables and indexes
* Better parallel processing (CREATE INDEX, CREATE TABLE AS SELECT, ...)
* Object-relational features (Nested Tables, VARRAYs, object views)
* Better security (expiring passwords, password history, locking a user
  out if they enter 3 invalid passwords, etc.)
* Index-only tables (tables stored in B*Treive format)
* Reverse key indexes - for indexs with unevenly distributed data
* Better Cost-based optimization
* Deferred constraints
* Updatable views with INSTEAD OF Triggers

Check out most Oracle8 books for more info on the above subjects.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 270+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do I install Oracle?
On Fri, 19 Mar 1999, ALEXANDER A. FLORES wrote:

> i am new to oracle dba.....soon we will be
> installing oracle7.1(although it is an old version)
> to hp-unix10.01.....i would like to do it myself as much
> as possible.....i don't have any manuals yet.......how should i begin installing
> oracle7.1? what are the OS commands needed? assume i have installed the OS already.
> can you explain to me both using a CD-ROM media and
> a tape media for oracle......
>
> thank you very much........
>

Thanks for your very kind words.

Your Oracle 7.1 should come with an installation guide, which explains all
of the steps. Basically it goes like this:

1) Create Oracle environment variables (ORACLE_HOME, ORACLE_BASE,
ORACLE_SID, add $ORACLE_HOME/bin to your PATH, and set up LD_LIBRARY_PATH
to $ORACLE_HOME/lib)
2) Create your directory structure to be OFA compatible
3) Make a CREATE DATABASE script. There should be samples on the CD-ROM
4) Make the initSID.ora and configSID.ora files. Again, samples should be
   on the CD-ROM
5) Go to the CD-ROM and then the orainst directory. Run "orainst" and you
   will be prompted through installing the Oracle executables.     
6) When the executables are loaded, run "root.sh" as root.
7) Create your database with the CREATE DATABASE scripts.

Note that some versions of Oracle's installer can create sample databases
for you. I do not recall if 7.1 is one of them.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 270+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->   
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to send messages to the Alert Log...
Alex Hudghton wrote in message <36F25E13.5638F559@capgemini.co.uk>...
>Is it possible to send messages to the standard alert log from an Oracle
>session ??
>
>Regards
>
>Alex
>
One way to do this is to set up the UTL_FILE_DIR to the ../bdump directory. Then, you can open and append to the alertSID.log file from within Oracle using the UTL_FILE package.

Best Regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 270+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do you create Export/Import views?
On Tue, 9 Mar 1999, Ralf Staib wrote:
> Hi Ari,
>
> we want to import a Oracle7-Full-Datatbase Dump into an Oracle 8-Database with
> The Error-Message was IMP-00023:
>
> IMP-00023     import views not installed, please notify your DBA
>
> Cause:        The necessary Import views were not installed.
> Action:       Ask your database administrator to install the required Import 
>               views
>
> Which VIew?s are these?? How  can I get them created??
> You have a great site.
>
>
> We would appreciate it, if you could help us.
> With kindly regards
>
> Ralf + Wolf
Hi,

What you need to do is run "catexp.sql" as SYS or INTERNAL. The file is
located in $ORACLE_HOME/rdbms/admin.

This script creates data dictionary views for the Export and Import
utilities. There are a couple of dozen views created. If you are curious
to learn more about them, read the documented catexp.sql file itself.
$$
This script should have been run when your database was created.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

<ORA-0729 on HP
Newsgroups: comp.databases.oracle.misc
Subject: Re: ORA-0729 on HP
References: <01bc35b1$8c5e3900$6a428ad0@pc060.groupZ.net>

"RYoung"  writes:
>I have been unable to locate this ORA primarily because the software manual
>is 2 states away. It continues with
>"ORA-0729: spcre: semget error. unable to get first semaphore set.
>HPUX ERR 28 No space on device"
>Am I running into a lack of semaphores and/or shared memory segments? There
>appears to be several hundred MB of space remaining on the drives, So the
>'no space' doesn't seem to refer to the drive. 
>-- 
>Robert Young
>rcyoung@summer.dbsol.com
>"Standard disclaimer for employee views..."

Robert,

The 'no space left on device' refers to the memory allocation, not the
physical disk drives. What is going in is your "PROCESSES" parameter in
the init.ora file is to high for your HP machine.

You can either lower the processes parameter, or change the UNIX kernel
parameter "semmns". It is default to 128. This is rarely sufficient if you
have more than one instance running on your box, or a large instance.

If you have databases up and running, you can find out how many semaphores
(semmns) are being used by typing:

ipcs -b |grep oracle

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Flushing shared pool does not free memory?
On Mon, 22 Mar 1999, Hearley, Jennifer wrote:

> Hi, I am not sure if you are still answering questions but if you could
> point me in the right direction I would really appreciate it. We are running
> Oracle 7.3.2 on a SunOS 5.5.1 Unix platform. The problem I have been
> encountering is as follows:
> If I reboot the server, the free memory is around 150000, however, after
> queries are performed the free memory seems to drop down to 4108 and stays
> that way till the server is rebooted. If I flush the SGA that does not
> change this. It seems as though Oracle is hanging on to the memory after the
> query is executed. And it causes the queries to run slower. Is there
> something I should be looking at to prevent.
> Thank in advance for any help you can give me.
>
> Jennifer M Hearley
> Lead Database Developer
> E-Commerce
> Newark Electronics
>
First, check if you have any packages pinned in memory. If so, that is why
your free memory does not increase after you flush the SGA.

Next, look at the V$SGASTAT view. This will tell you what is taking up
your memory.

If you are talking about system free memory (outside the database on the
server), then each connection to the database takes up memory (2-4M each
typically).

Also, information in the SGA is kept in a b-tree format. So, flushing the
shared pool gets rid of just the lowest "layer" of memory. The next flush
command removes the next-to-lowest "layer" of memory, and so on. So, to
flush out everything try:

ALTER SYSTEM FLUSH SHARED POOL;
ALTER SYSTEM FLUSH SHARED POOL;
ALTER SYSTEM FLUSH SHARED POOL;

and then check your free memory.
Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant 

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What is the best way to perform bulk data loads: Perl or SQL*Loader?
On Thu, 11 Mar 1999, Mary T Kuehn wrote:
> Hi Ari,
> How are you?  I was hoping you might have time (and I assume you have the
> experience) to provide your opinion on Perl vs. SQL*Loader.  We want to
> create routine batch jobs to perform bulk data loads and extractions
> to/from an Oracle8 database on a HP 11 server.  Does one tool stand out
> as much more efficient than the other?  Particularly, can you speak to
> the ease of use and performance costs for each of these tools?  Thanks in
> advance!  Hope all is well!
> Mar
From a performance standpoint, SQL*Loader in direct mode is best, as it
can bypass some Oracle overhead involved in the loading process. Perl
cannot do this.

In either case, think of using the NOLOGGING option in Oracle8, which does
not produce redo log activity. This improves performance, but be aware
that you will have to restart the load from the beginning of a table in
the event of a failure mid-load.

Perl gives greater flexibility than SQL*Loader in formatting the data that
you will be loading. So, if your data is in a "free form" format than Perl
would be a good option. On the other hand, if your data is in a delimited
or fixed format, than SQL*Loader would be the best to use.

Hope that this helps!

-Ari

Back to Ari Kaplan's Home Page

Can't run Server Manager in Motif mode
> Hi Ari,
> 
> I am running ORACLE 7 SERVER Release 7.3.3 on a Solaris 2.5 platform.
> The problem I am experiencing is that I can not run svrmgrm from my
> command line. I get The following error message :
> 
> TK2-00001: an undefined Oracle Toolkit II failure occurred
> 
> Can you please help me on this one?
> 
> Regards
> 
> 
> MARIUS DE BEER
> marius@atio.co.za
> ORACLE DBA
> ATIO Corporation                     P.O.Box 4467,Rivonia,2128
> Tel   : (27) (011) 235 7280          Fax: (27) (011) 807-3568
> Cell  : (27) (0) 82 776 1737
> ATIO Africa House, Tuscany Office Park, Block H, Coombe Place, Rivonia
> 

Make sure your DISPLAY environment variable is set to the IP address
of your computer. Also, check your TERM variable. If all else fails, set
it to "vt100". Check with your system admin to find your IP address (this is
if you are in an office networked environment.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
> 

Back to Ari Kaplan's Home Page

How to see free space within existing extents?
Thomas Klinger wrote in message <36f7b376.26787321@194.48.138.240>...
>Hi there!
>
>Sounds like an easy question.
>I want to get the used space of a table in percentage digits.
>
>I.e. I have a table which takes at its init size ~174MB. And it is
>still at extent 0. Max_Extents=6. 
>But how much is the table really filled up? How to do this?
>
>USED_SPACE_OF_CURRENT_TAKEN_BLOCKS=?
>FREE_SPACE_IN_THIS_EXTENT=100%-USED_SPACE_OF_CURRENT_TAKEN_BLOCKS
>
>Is it also possible to get the value of available rows which can be
>inserted into FREE_SPACE_IN_THIS_EXTENT and how much rows can be
>inserted at the max?
>
>Can anyone help me?
>
>
>Kind regards
>
>       Thomas Klinger
>       Systemspecialist
Thomas,

In Oracle7, to find out the total blocks of a table that contain rows, enter
the following SQL

SELECT COUNT(DISTINCT(SUBSTR(ROWID,1,8))) FROM table_name;

In Oracle8, you can find the total blocks using DBMS_ROWID:

SELECT COUNT(DISTINCT(SUBSTR(DBMS_ROWID.ROWID_TO_RESTRICTED(ROWID),1,8)))
FROM table_name;

You will get the total number of blocks that contain records of the table.

To determine the overall size, find the block size:

SELECT value FROM V$PARAMETER WHERE NAME = 'db_block_size';

The total space of the data is the multiplication of "Total Blocks" *
"Block Size". This will be in bytes.

To find the free space in the table, subtract the size calculated above (used
size) from the total size of the most recent extent.

Another option is to run statistics on the table, then issue:

SELECT EMPTY_BLOCKS FROM USER_TABLES WHERE TABLE_NAME='table_name_here';

to find the total blocks:

SELECT BLOCKS FROM USER_TABLES WHERE TABLE_NAME = 'table_name_here';

The only drawback is that you may not wish to use the cost-based optimizer and hence not want to generate statistics.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-> 

Back to Ari Kaplan's Home Page

How do you see the trigger body in the data dictionary?
> 
> Ari , 
> 
> Thanks for your help on database startup on reboot of machine ...
> 
> Another question I have, 
> 
> SQL> desc user_triggers;
>  Name                            Null?    Type
>  ------------------------------- -------- ----
>  TRIGGER_NAME                    NOT NULL VARCHAR2(30)
>  TRIGGER_TYPE                             VARCHAR2(16)
>  TRIGGERING_EVENT                         VARCHAR2(26)
>  TABLE_OWNER                     NOT NULL VARCHAR2(30)
>  TABLE_NAME                      NOT NULL VARCHAR2(30)
>  REFERENCING_NAMES                        VARCHAR2(87)
>  WHEN_CLAUSE                              VARCHAR2(2000)
>  STATUS                                   VARCHAR2(8)
>  DESCRIPTION                              VARCHAR2(2000)
>  TRIGGER_BODY                             LONG
> 
> here you can see that Trigger Body is long, is there a way to see the 
> complete content of this column for a specific trigger.
> 
> I set linesize up to 400 and no luck, set wrap on still a bad try  and I 
> could see only the begining portion of the code ....
> 
> If you have any tip please let me know...
> 
> Thanks
> Bijilal
> 
Yes. do "SET LONG 10000". The linesize does not matter.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Are multiple extents bad for performance?
> 
> Ari,
> 
> I'm a non-systems person who knows just enough to be dangerous.  Our
> department used table spaces so extensively and had such a need to be
> able to maintain our own records that the systems department set us up
> with our own user ID.  They segregated our tables in such a way that we
> are in control of them along with a large set of table spaces.  Over the
> past few years our company has seen high turnover in the systems
> department and information that I received in the past regarding extents
> and performance is being contradicted by our current DBA administrator.
> 
> 
> For the most part all of our tables are built with the following
> structure.  
> PCTFREE  10 TABLESPACE TS_QTVLPT
> STORAGE ( INITIAL   96879K  NEXT  9687K  MINEXTENTS   1
>            PCTINCREASE   0  MAXEXTENTS 121 )
> 
> The PCTFREE is always 10, storage NEXT is always 10% of INITIAL,
> MINEXTENTS = 1, PCTINCREASE = 0, and MAXEXTENTS = 121.  The indexes are
> built the same with the exception of the removal of MINEXTENTS 1.
> 
> What I have been told in the past is that if a table goes into multiple
> extents, the performance suffers.  The table should be rebuilt and
> defragmented.  We were told to watch our tables and indexes and if they
> go into more than 2 extents to let the systems department know.  We have
> some fairly extensive selects and inserts in our programs and some very
> large tables.  It did seem that our programs would run more efficiently
> when rebuilt and no longer in extents.  We currently have some tables in
> 13 extents and indexes in 23 extents.  I have been told by our DBA
> administrator that extents do NOT affect performance and therefore he
> isn't willing to rebuild them.  What is the right answer?
> 
> If in fact the number of extents does affect performance, could you
> point me to some documentation so I can convince our DBA administrator
> of the fact.
> 
> Thanks,
> Kathryn
> kcox@rgare.com

Extents does affect performance. The industry buzz is that anything more than
four will affect performance. This is documented in dozens of Oracle books,
including Oracle documentation itself. If you are on UNIX, you should have
received a "Performance Tuning for Oracle on UNIX" where this is mentioned.
Also get "Special Edition Using Oracle8" that explains on P.802-804 why
fragmentation and multiple extents are bad for performance.

For example, "Although fragmentation is usually considered primarily a space
issue, like all things in a database system, it has its effects on performance.
Whether directly or indirectly, extent fragmentation triggers unneccessary
dynamic extension, which you do not want occurring unnecessarily, from the
standpoint of performance. If, in the lifetime of a tablespace, segment
creation and dropping has created a swiss cheese effect, it detracts from 
performance by necessitating I/O's from multiple extents....."
"...the PQO configuration becomes slower and slower because it was initially
configured based on load-balancing the extents. In addition, what was
initially a set of sequential reads from contiguous disk locations are now
groups of sequential reads from various (random) disk locations, requiring
more seek activity!"

This book can be found at a discount through my web page
(www.arikaplan.com), as I am a co-author.

Hope this helps. The best way to convince him (and yourselves) is to do timing
statistics for the large extent table, then defragment it and see the
difference. From your DBA's stand, it seems he/she may be unwilling to do
this.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Breaking delimited data into separate fields
> 
> Hi  Kaplan,
> 
> I am sorry to disturb you. But I am not able to solve the problem below
> with PL/SQL. If you could guide me.
> 
> I have list of record in a variable say : xyz is of varchar2 and the
> value contained in xyz is :
> 
> XYZ|PQR|OPQ|http://www.xyz.com|this is a test description|Description
> ABC|AAA|BBBAA|http://www.abc.com|This is test too|jhjjjjjjjj
> KKK|KKKK|JJJJ|http://www.opq.com|Anything|jksdkjskd
> 
> These are three records in a variable xyz which are seperated by a new
> line character and each field is seperated by a pipe symbol. This is an
> input to a procedure  as:
> 
> create or replace procedure add_site( xyz IN varchar2)
> IS
> BEGIN
> 
> END;
> 
> Is it possible that I can break the xyz variable's data  first for each
> row record and then for each and every column (which is delimited by a
> pipe '|' symbol) ? Is there any inbuilt function to find out the char
> '\n' as in 'C'? SUBSTR function does not work because a row record or
> column record can of variable length.
> 
> The above input I am getting from the client browser which I have to
> break and put in a table after validation check for each and every
> record.
> 
> Thanks and Regards,
> Vipin
> 

"INSTR" will give the position of a string within another string.
You can also use CHAR for special characters. I believe 10 or 13 is a newline.

Using the above two (with SUBSTR) you can break it out. Say for instance that
CHAR(15) as the | separator (it probably isn't but I can't look it up now).
To get the first column, do

SQL> SELECT SUBSTR(the_line,1,INSTR(the_line,CHAR(15))) FROM the_table;

XYZ
ABC
KKK

3 rows selected.

SQL>

I hope this helps!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do you see table names in SQL*Plus?
> 
> All tables owned by me that is...
> 
> Thanx
> Carlos Roman
> 
> 
> Hello!
>  Im new at Oracle and I just want to know...
> How the hell can you see the names of all the tables you have created
> through sqlplus
> 
> Thanx!
> -Carlos Roman
> 
To see your tables, type:

SELECT TABLE_NAME FROM USER_TABLES;

To see tables owned by everyone, type:

SELECT OWNER, TABLE_NAME FROM ALL_TABLES;

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Encryption in SQL*Net 2.3
>
> Could you please outline any widely known or other security issues
> associated with SQL*Net v2.3.x.x.x. My main concern is SQL*Net in the
> NT4 environment. Is encryption an out of the box option?OR, Do I need to
> separately purchase security/encryption add-ons?Do I need SNS? I am
> assuming that you are a SQL*Net security guru. Anyway, any information
> you could send to me would be greatly appreciated.

I am not a security guru, but I do not think that SQL*Net 1.x or 2.x
offers any encryption out of the box. For Oracle7, there is the "Trusted
Oracle" option (see
http://www.oracle.com/database/trusted/html/chapter1.html) and for
Oracle8, their networking software "Net8" DOES have encryption out of the
box.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-> 

Back to Ari Kaplan's Home Page

What to do if someone says the DB is running slowly.
> Ari,
> 
> What would you do if someone called you and said the DB is running slowly,
> what would you check & why ?
> 
> Cheers
> 
> Dan Butler
> MLEME Oracle Database Support
> Merrill Lynch Europe
> +44 171 892 8062
> mailto:dan_butler@ml.com

Dan,

There are many things to look at. Start with the alert.log files to see if
there are any errors occuring. Then, check for table locks (V$LOCK view) -
this is to see if users are temporarily locking out other users with their
actions.
Another important check is the buffer cache hit ratio. If the database has to
constantly read from disk instead of memory, you will see a BIG performance
degradation.
Also check the free memory in the SGA. If you are swapping SQL in and out of
the SGA, performance will degrade.
Disk contention is important too. Make sure you are OFA compliant. Make sure
that your tables and indexes (and redo logs) are on separate drives and if
possible separate controllers.
If you are using cost-based optimization, ensure that your statistics are
up-to-date.


Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Copying data from Access to Oracle
> I recently browsed through ur webpage to get some tricks on how to export data
> from my database in Access to Oracle..But unfortunately I couldn't find an
> answer..
> If u can help me it would be great..My database is pretty large  about 1.5 MB..
> And I have already defined my tables in Oracle 7.3. The only problem is
> transferring records from my Access table to Oracle table..Help would be
> greatly appreciated.

There are two ways to do this:
1) Export the Access table into a tab-delimited ASCII file. Then use
   SQL*Loader to load the data into your existing Oracle tables. You will have
   to set up the SQL*Loader control files, which is documented in the
   "Oracle Utilities Guide" book, among other 3rd-party books.
2) Set up an ODBC connection between Access and Oracle. Then, you can cut and
   paste or run an update query in Access.

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Breaking up tables with LONG columns
> Hi Ari,
> 
> I am an Oracle Developer (Forms 4.5).
> I have following Query.
> In Oracle Manual it has been suggested to 
> 
>        "Place each LONG column in a table separate from other         
> associated data. This prevents SQL statements from scanning         LONG 
> columns during full table scans" .
> 
> My problem is How to do this during table creation. 
> I know that LONG column should be last in table definition.
> Please guide me in this matter.
> Thanks and regards
> Prashant 

Prashat,

What Oracle recommended was to create an entirely NEW table. So, instead of
making a table like the following:

TABLE_A:
-------
ID          varchar2(100)
NAME        varchar2(100)
SALARY      number
DESCRIPTION LONG

you should make TWO tables, joined by the primary key (in this case ID):

TABLE_A:
-------
ID		varchar2(100)
NAME		varchar2(100)
SALARY		number

TABLE_B:
-------
ID		varchar2(100)
DESCRIPTION	LONG

This will improve scanning the table for names and salaries. To get the long
column, you can always join table_a and table_b.

Best of luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Table Sizing
Subject : Re: Table sizing
----- Message Text -----
On Mon, 29 Mar 1999, Cheryl Baker wrote:

> Hi, I just have one question for you. We are using Oracle 8 and were trying
> to set up our tables. Do you have any tips on table sizing for us, it would
> be greatly appreciated.
>
Here is what I usually do:

1) Get an estimate of the number of records for the table, both now, and
   projected to 6 months from now
2) Find the average length of each record. If you cannot do this
   perfectly, then try to make a good guess.
3) Determine how often the table is updated/inserted/deleted. If it is
   changed often (and the record sizes vary), then the PCTUSED would be
   low, something like 40-60. If the table is static, then I'd make the
   table PCTUSED 85 or 90.
4) Determine my database's block size:
   select value from v$parameter where name = 'db_block_size';

Now I have all of the information needed to size my table:

Records per block = (block size - 110 bytes for overhead) * (PCTUSED/100)/
                    Average Record Size

Total blocks = (records in table) / (records per block)
Total table size = blocks * block size
   
Give a little fudge factor and make this your INITIAL extent size.
Your NEXT will be determined by your 6 month growth projection.

Best regards,
   
-Ari Kaplan
Independent Oracle DBA Consultant
   
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Selecting only EVEN or ODD records
Ari,

I love your web page and visit quite often. One question:

How do I select just the EVEN or ODD records in a table?

Thanks,

Kishore
---------------------------------------------------------------------------
(see additional comments from Bob Smith and John Lennon following Ari's
 response)

Kishore,

Glad that you like the web page.

As for your question, you can do it in 2 ways:
   
1) Write a PL/SQL routine to open up a cursor (SELECT * FROM TABLE_NAME;).
   When looping through the records, output the row only if it is
   1,3,5,7,... or 2,4,6,8,... You can use a variable to keep track of the
   row number.
   
2) If you have a sequenced primary key, do

   SELECT * FROM TABLE_NAME WHERE
   mod(primary_key_column,2) = 0;

   for even numbers. For odd numbers, do:

   SELECT * FROM TABLE_NAME WHERE
   mod(primary_key_column,2) = 1;

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Just found your site, and appreciate the time you take to pass along these
tips. I did have one comment on tip 295 -- Selecting only even or odd
records. If the table does not have a sequenced primary key, you can create
one with a subquery.

SELECT username
  FROM (SELECT rownum num, username
          FROM dba_users
       )
  WHERE MOD(num,2) = 0;


I realize that relational theory does not place an order on records, but
this structure might be useful in some cases.


Thanks,

Robert(Bob) Smith
Crown Equipment Corporation
(419) 629-2220 x2070     [Phone]
(419) 629-9233           [Fax]
bob.smith@crown.com
---------------------------------------------------------------------------

SQL> desc member_list
 Name                            Null?    Type
 ------------------------------- -------- ----
 E_MAIL                                   VARCHAR2(50)
 NAME                                     VARCHAR2(50)

How do I select just the EVEN or ODD records in a table?

select e_mail from (select rownum row_num, e_mail from member_list)
where mod(row_num,2) = 0 -- EVEN

select e_mail from (select rownum row_num, e_mail from member_list)
where mod(row_num,2) = 1 -- ODD

Regards

John C. Lennon
Database Consultants Inc.
7201 W Lake Mead Blvd, Suite 203
Las Vegas NV 89128
Tel: (702) 498 4990
Fax: (702) 871 4318
e-mail: johnlennon@ieee.org
Website: http://members.aol.com/jomarlen/

Back to Ari Kaplan's Home Page

How to allow EVERY user access to a table
On Fri, 26 Mar 1999, BJ Woodard wrote:

> Ari,
> 
> I visited your page and enjoyed it very much.  The web page was well  
> laid out and had good information.  I am emailing you because you seem
> to be a highly proficient DBA.  I alas, am merely an accomplished Unix
> admin and a Oracle ignoramus.
> 
> Due to some unforseen circumstances I have inhereited our current Oracle
> DBMS for the short term.  Today I received a request from two users to
> create read only access too all tables in our database.  I was able to
> create the users via the server manager.  However after spending much
> time scouring Oracle documentation I have been unable to determine what 
> definition needs to be set in order to allow global read access.  Could
> you possibly provide me with some enlightenment on how to accomplish
> this task?
>
> Any help you can provide would be most appreciative.  The task itself
> seems rather minor however finding the right information has proven to
> be anything but!
> 
> Thanks,
> 
> BJ Wooadrd
> AIX Administrator
> 
BJ,

Glad that you like my web page, and welcome to the world of Oracle!

To answer your question, what you need to do is grant privileges to
PUBLIC, which is the "global" access you are looking for.

GRANT SELECT ON table_name TO PUBLIC;

will let EVERYONE see your table. They have to specify the owner's name to
view the data:
  
SELECT * FROM owner.table_name;
  
If you do not want users to specify the owner, then you will need to
create a PUBLIC SYNONYM:
  
CREATE PUBLIC SYNONYM table_name FOR owner.table_name;

Now, all users need to do is reference the synonym:


SELECT * FROM table_name;

Hope that this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Using DECODE for RANGES of values
Subject : Interesting DECODE question
----- Message Text -----
On Tue, 9 Mar 1999, dharmesh bengali wrote:
>  Hi Ari,
> 
>  while looking for an answer to my question I came across your web
> site. You have answers for every questions. However, I did not find an
> answer to  my question, maybe you can help.
>
>  1. select empno,ename,job,sal,decode(sal,1500,'very less salary',
>       'good salary') status from emp;  
>
>     Using decode i want to display 'very less salary' for employees
> who earn salary less then 1500 and 'good salary' for employees
>     who earn salary more then 1500.
>
>     i tried using
>
>       select empno,ename,job,sal,decode(sal,sal < 1500,'very less
> salary','good salary')status from emp;   
>  
>     but it didn't work.
>  
Dharmesh,

Your question can be solved using DECODE and SIGN.
SIGN(1500-SALARY) is 1 if SALARY > 1500.
SIGN(1500-SALARY) is 0 if SALARY = 1500.
SIGN(1500-SALARY) is -1 if SALARY < 1500.

So, putting it all together, you caan issue:

SELECT empno, ename, job, sal,
DECODE(SIGN(1500-sal),-1,'very less salary',
                         'good salary')
FROM emp
/
   
Best regards,
   
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Insufficient Privileges with SYS account

MARCH 20
Jan Thomsen  writes:

>We have Personal Oracle installed here. We changed SYSTEM and SYS 
>passwords but not the DB password (default "oracle"). When shutting
>down the DB (with Database Manager) the DB password is required. 
>However, by now this password is not accepted. As well, it is not 
>possible to shut down the DB using the DBA with sys login, although
>sys has full DBA privileges;Oracle returns with "insufficient 
>privileges". Has anybody experienced the same problems and knows
>something to do against it?

>Thanks a lot
>Jan Thomsen and Laurence Geiger

Jan and Laurence,

Even though you tried shutting the database down with the "sys" account, 
and sys has "full" DBA privileges, the "sys" account cannot shut down the 
database. You must be connected INTERNAL to shut down the database. See 
the Oracle7 Server Administrator's Guide (page 1-4 in my book), and your 
installation and users guide for details.

Basically, INTERNAL is a special, powerful administrative account to 
startup and shutdown the database. It is the ONLY account that can do it. 
The one exception is if your operating system supports operating system 
roles; if so, you can grant OSOPER or OSDBA roles. Again, this is 
system-specific, and you should read up on it in your installation 
manuals before you try to use it.

Good luck!

-Ari Kaplan
Independet Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do you application tune?
> 
> Hi Ari, 
> 
> I am a new Oracle DBA. Recently I come across a problem.
> 
> Our developers have developed one "Point of Sales" software in oracle 
> Forms 4.5. Since I am new in this Environment , I don't know the Table
> designing and Application. 
> 
> Yesterday, One user complained to me that application response time is 
> slow.
> 
> Now I want to tune the application. I know all the tools like TKPROF
> utility, Hints and like. I also know how to tune SQL statement.
> 
> But, since I don't know table design and Application, I don't know
> from where to start Application Tuning.
> 
> Please guide me in this matter. Please tell me how to find out 
> Problematic SQL statement.
> 
> Thanks
> 
> Bye
> Prashant Shindgikar
> 
The first thing to do is to look at the EXPLAIN PLAN for the SQL statements.
To find out what's being run most often, type:

SELECT SQL_TEXT, EXECUTIONS
FROM V$SQLAREA
ORDER BY EXECUTIONS;

There are other columns in the V$SQLAREA that you can query to see the
SQL statements that took up the most memory, or the most disk io.

Also, check out some of the books in the stores, such as Advanced Oracle
Tuning by O'Reilly & Assoc.

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Two EXPLAIN PLAN questions
On Thu, 1 Apr 1999, Tracy Felty wrote:

> Mr. Kaplan,
>    Your web page has a wealth of knowledge and has been very helpful.  I
> have a question concerning oracle indexes.  I am using oracal 7.3.  I have a
> table with a unique primary key that consists of 4 columns.  I have been
> analyzing my DB and have set the autotrace on so that I can see how selects
> are being processed.  The optimizer is set to 'CHOOSE' and I have analyzed 
> my entire schema, so all tables and Indexes have been analyzed.  When I    
> perform a select with a where condition using all 4 keys Oracle is doing a
> full table access instead of an index search and a table access by rowid. 
> It appears that most of my indexes on other tables are working as expected.
> Here is my Index, select statement and execution plan:
> 
>
> SQLWKS> select * from user_ind_columns where index_name = 'SYS_C004851'
>
> INDEX_NAME    TABLE_NAME          COLUMN_NAME   COLUMN_POS COLUMN_LEN
> ----------    ---------------     ------------  ---------- ----------
> SYS_C004851   APPRAISAL_EST_TAX   TAX_YEAR          1         22
> SYS_C004851   APPRAISAL_EST_TAX   ACCOUNT_NBR       2         22
> SYS_C004851   APPRAISAL_EST_TAX   DISTRICT_NBR      3          4
> SYS_C004851   APPRAISAL_EST_TAX   FUND_CD           4          4
> 4 rows selected.
> 
> 
> SQL> select * from appraisal_est_tax where tax_year = 1998 and account_nbr =
> 84 and  district_nbr =
>  'C001' and fund_cd = 'GEN';
> 
> Execution Plan
> ----------------------------------------------------------
>    0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=31)   
>    1    0   TABLE ACCESS (FULL) OF 'APPRAISAL_EST_TAX' (Cost=1 Card=1
>           Bytes=31)
> 
> ALSO, on the execution plan what is 'COST' and 'CARD' ??  Thank you for
> whatever help and advice you can give.  I really appreciate your time in
> this matter.
> 
> Tracy
> TFelty@cpssys.com
> 
Based on your information, Oracle WILL use the primary key, with two
exceptions:
1) If there are only a few (usually < a few thousand) records, Oracle will
   do a full-table scan as opposed to using an index to retrieve a small
   number of records
2) If the cardinality ('CARD' per your question) is low, meaning that
   there are few distinct values of the index key versus the total number
   of records.

Since you are using a primary key, #2 would not be relevant, as a unique
index has the highest possible cardinality.

So, I am assuming that there are not many records in your table. If there
are, you will have to use a hint in your SQL and/or call Oracle support.

Best regards,
  
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->   
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->   

Back to Ari Kaplan's Home Page

Ora-600 Space Leak...Explain, causes
Newsgroups: comp.databases.oracle.server
Subject: Re: Ora-600 Space Leak...Explain, causes
References: <33427E0D.730E@lmco.com>

Judie Stroup  writes:
>Got the following error reported to my alert log...
>Tue Apr  1 14:54:52 1997
>Errors in file /fs01/home/oracle/admin/DEV/udump/ora_12361.trc:
>ORA-00600: internal error code, arguments: [729], [266536], [space
>leak], [], [], [], [], []

>Can someone explain what a "space leak" is in this context and what
>are the possible causes of this error.

>FYI, I'm running Oracle 7.3.2.3 on HP-UX 10.10.
>thanks...judie
>judie.stroup@lmco.com

The space leak has been a bug with Oracle for years now. Basically, UNIX  
allocates memory for each Oracle instance. You can see this by typing:

ipcs -m

A space leak occurs when this memory is divided up into two (or more)
addresses. This typically does not cause problems for users, but may waste
UNIX memory. Shut your database down and start it up, and the memory will
be cleared.

Oracle typically supplies patches to fix this bug, so give Oracle support
a call.

I'm sorry to hear Oracle still has this problem, since we are upgrading to
7.3.2 on HP-UX as well.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Which views, procedures, and packages are dependent upon a table?
On Mon, 8 Mar 1999, James Zheng wrote:
 
> Hi Ari,
>    Here is the question. I need to do some table restructure. Without
> using any third-party tool, how could I efficiently find out from data
> dictionaries the 1)views 2)procedures 3)packages built upon the table?
>    Thank you in advance.
>
> Jim
>    
Jim,
  
Do the following SQL:

SELECT * FROM DBA_DEPENDENCIES
WHERE REFERENCED_OWNER = 'owner' AND
      REFERENCED_NAME = 'table_name';

Regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 275+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

CREATE DATABASE: a sample script
From akaplan@interaccess.com Wed Apr  7 10:51:06 1999
Date: Wed, 7 Apr 1999 10:49:34 -0500 (CDT)
From: Ari D Kaplan 
To: Vanessa 
Cc: akaplan@interaccess.com
Subject: Re: rollback segments

On Tue, 6 Apr 1999, Vanessa wrote:

> Sir
> I was browsing for information on rollback segments and I got to your website.
> 
> I am confused on on the necessary things to create for a new dbase eg.
> rollback segs. In short
> I don't know what to do to create a database now. 
> 
> Thanks
> Admirer 

Hi Vanessa,

Thanks for thinking of me for your Oracle questions.
You can create a database in two ways:
1) Use the Oracle installer to generate a default database
   Steps: create the Oracle user, directories, and run "orainst" install
   program.
2) Use a script to manually create the database for better control
   Steps: create the Oracle user, directories, create database scripts,
   and initialization parameter files.

   For the create database script, use the CREATE DATABASE command and
   then issue CREATE TABLESPACE, CREATE ROLLBACK, CREATE USER, and so on.

   A sample script is below:

-Ari Kaplan
Independent Oracle DBA Consultant
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
connect internal
startup nomount pfile=/home/oracle/admin/PROD/pfile/initPROD_0.ora
create database "PROD"
    maxinstances 8
    maxlogfiles  32
    character set "WE8ISO8859P9"
    datafile
        '/export/home6/oradata/PROD/system01.dbf'  size   40M
    logfile
        '/export/home6/oradata/PROD/redoPROD01.log' size 8M,
        '/export/home6/oradata/PROD/redoPROD02.log' size 8M,
        '/export/home6/oradata/PROD/redoPROD03.log' size 8M;

REM # install data dictionary views:
@/home/oracle/product/7.3.4/rdbms/admin/catalog.sql

REM * Create additional rollback segment in SYSTEM before creating tablespace.
REM *
create rollback segment r0 tablespace system
storage (initial 16k next 16k minextents 2 maxextents 20);

REM * Use ALTER ROLLBACK SEGMENT ONLINE to put r0 online without shutting
REM * down and restarting the database.
REM *
alter rollback segment r0 online;
REM *   1 rollback segments for every 4 concurrent xactions.
REM *   No more than 50 rollback segments.
REM *   All rollback segments the same size.
REM *   Between 2 and 4 homogeneously-sized extents per rollback segment.
REM * Attempt to keep rollback segments to 4 extents.
REM *
create tablespace rbs datafile
        '/export/home6/oradata/PROD/rbs01.dbf'  size   100M
default storage (
        initial          2M
        next             2M
        pctincrease        0
        minextents         2
);

REM * Create a tablespace for temporary segments.
REM * Temporary tablespace configuration guidelines:
REM *   Initial and next extent sizes = k * SORT_AREA_SIZE, k in {1,2,3,...}.
REM *
create tablespace temp datafile
        '/export/home6/oradata/PROD/temp01.dbf'    size   50M

default storage (
        initial      256k
        next         256k
        pctincrease  0
);

REM * Create a tablespace for database tools.
REM *
create tablespace tools datafile
        '/export/home6/oradata/PROD/tools01.dbf'   size   15M;

REM * Create a tablespace for miscellaneous database user activity.
REM *
create tablespace users datafile
        '/export/home6/oradata/PROD/users01.dbf'   size   10M;


REM * Create rollback segments.
REM *
create rollback segment r01 tablespace rbs;
create rollback segment r02 tablespace rbs;
create rollback segment r03 tablespace rbs;
create rollback segment r04 tablespace rbs;

REM * Use ALTER ROLLBACK SEGMENT ONLINE to put rollback segments online
REM * without shutting down and restarting the database.  Only put one
REM * of the rollback segments online at this time so that it will always
REM * be the one used.  When the user shuts down the database and starts
REM * it up with initSID.ora, all four will be brought online.
REM *
alter rollback segment r01 online;
alter rollback segment r02 online;
alter rollback segment r03 online;


REM * Since we've created and brought online 4 more rollback segments,
REM * we no longer need the second rollback segment in the SYSTEM tablespace.
alter rollback segment r0 offline;
drop rollback segment r0;

REM * Alter SYS and SYSTEM users.
REM *
alter user sys temporary tablespace temp;
alter user system default tablespace tools temporary tablespace temp;

REM * Run catproc as internal...
@$ORACLE_HOME/rdbms/admin/catproc.sql

REM * Run dbmsutil as internal...
@$ORACLE_HOME/rdbms/admin/dbmsutil.sql

REM * For each DBA user, run DBA synonyms SQL script.  Don't forget that EACH
REM * DBA USER created in the future needs dba_syn.sql run from its account.
REM *
connect system/manager
@$ORACLE_HOME/rdbms/admin/catdbsyn.sql
@$ORACLE_HOME/sqlplus/admin/pupbld.sql

> 

Back to Ari Kaplan's Home Page

Freeing up TEMP space after a large JOIN operation
On Wed, 7 Apr 1999, Hearley, Jennifer wrote:

> Hi Ari,
>
> I have a question that I hope you can answer. I have created a temporary
> tablespace that I have assigned to certain users who run jobs that require
> large table joins. My question is: does Oracle recycle the space once the
> job has finished running? We are pressed for space and that file usually
> seems pretty large. I was thinking of moving it to its own partition but I
> wanted to know what information you had if any.
>
> Thanks,
> Jenn Hearley

Jennifer,
 
Yes, Oracle will recycle the space. What I mean is that Oracle frees
up the tablespace. To the operating system, the temp tablespace
datafile will always be there (Oracle pre-allocates the file before
using it, as it does with all tablespaces).

Here is a quick overview of the join process:

1) Oracle will try to do a join in the SORT_AREA (defined by
   SORT_AREA_SIZE).
2) If the SORT_AREA gets filled up, Oracle writes temporary segments
   to the user's temporary tablespace.
3) Once the operation has completed, an Oracle background process will
   remove these temporary segments
4) Contiguous free space is NOT automatically coalesced unless the default
   PCTINCREASE storage parameter for the temporary tablespace is non-0.
   If you want to coalesce, issue:

   ALTER TABLESPACE temp_tablespace_name COALESCE;

Regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Using TAB as a delimiter in SQL*Loader

On Sat, 3 Apr 1999, Grant Hofer wrote:

> Hey there Ari.  I came across the e-mail on your page, and I have a very
> simple question for you, if you'd be willing to help me out.
> 
> Basically, I just need to know how to set sqlldr to use a tab delimiter,
> instead of (for example), comma's.  I've got a tab delimited file, but I
> don't know the syntax to get sqlldr to delimit by tabs.  I hate to bother
> you on Easter weekend, but I'm in kind of a bind, and I really need to
> figure this out.  Thanks very much for your time,
> 
> Grant Hofer
> 3rd Year Information Systems Student, University of Calgary
Grant,

Glad to help out. You need to use the "TERMINATED BY WHITESPACE" clause in
your SQL*Loader controlfile. According to Oracle's docs,

"If TERMINATED BY WHITESPACE is specified, data is read until the first
occurrence of a whitespace character (space, tab, newline). Then the current
position is advanced until no more adjacent whitespace characters are found. 
This allows field values to be delimited by varying amounts of whitespace."

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

[HELP] How can I find deadlocks?
Newsgroups: comp.databases.oracle.server,comp.databases.oracle.misc
Subject: Re: [HELP] How can I find deadlocks?
References: <3353517C.2AA0@aena.es>

Manoli Alamo Medina  writes:

>Hi,

>I have a problem about deadlocks in ORACLE V7.1.4.
>Could anybody help me, about how to find them?
>(Please, send a copy of your post to mailto:sscc.malamo@aena.es)
>Thanks in advance!
>Manoli Alamo

Manoli,

The most direct method to find if a deadlock occurred is to look in your 
bdump/udump directories. Deadlocks produce a trace file, giving the session
numbers (along with much more detail).

If you want to see which processes are generally locking out other processes,
you can look in the MONITOR LOCKS of SQL*DBA (before Oracle 7.3), or the
V$LOCK view.

Also, in your $ORACLE_HOME/rdbms/admin directory is a script called:

utllockt.sql

This will show you which processes are locking other processes, and which
processes are being locked. It's a great utility, shown in a tree structure.

Best of luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Case insensitive searching
Newsgroups: comp.databases.oracle.server
Subject: Re: Case insensitive searching
Keywords: Case insensitive
References: <5j1uce$re8$1@gruvel.une.edu.au>

cmunday@neumann.une.edu.au (Craig Munday) writes:

>Being a DBA currently moving our systems from Sybase to Oracle I have a newbie
>question concerning sort ordered.
>Is it possible to configure an Oracle Database/Instance with a case 
>insensitive sort order?
>Your help would be much appreciated.

Craig,

Making a search case insensitive is done on a search-by-search basis and
cannot be configured Instance-wide.

To make a search ("query") case-insensitive, use the UPPER function. For 
example,

SELECT * FROM EMPLOYEES WHERE UPPER(EMPLOYEE_NAME)='LARRY ELLISON';

To order the results of a query regardless of the case, also use the 
UPPER function:

SELECT * FROM EMPLOYEES ORDER BY UPPER(EMPLOYEE_NAME);

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Question on tablespaces and table spaces
Newsgroups: comp.databases.oracle.server
Subject: Re: Question on tablespaces and table spaces
References: <335540BA.77AE@mda.ca>

Simon Goland  writes:

>I think I am just being overly confused about something trivial...
>As an example (on a conceptual level and not any specific semantics),
>say I have a tablespace TEST of 50 MB, empty. So I have 50 MB free. Now
>I create one table in this tablespace using something like:

>CREATE TABLE abc (
>   ...
>   
>   ...
>)
>TABLESPACE test
>STORAGE (
>   INITIAL 40,000,000
>   ...
>);

>Now, if I use Server Manager or any query to show me the free space in
>tablespace TEST, it will report only 10 MB free for the tablespace
>(approximately, to the nearest block size). Correct?
>Then, if after I insert some rows into my table ABC, I want to know how
>much free space do I have left in the table, I can ran
>  analyze table abc estimate statistics;
>followed by
>  select t.blocks        "Used blocks",
>         t.empty_blocks  "Free blocks",
>         s.blocks        "Total blocks"
>    from dba_tables    t,
>         dba_segments  s
>   where t.owner = ''
>     and s.owner = t.owner
>     and t.table_name = 'ABC'
>     and s.segment_name = 'ABC';

>Which will give me the free/used/total table space, in blocks.
>Am I correct? 
>-- 
>[ Simon Goland       B-)>     sg@mda.ca ]
>[   Without action there is no change   ]

Simon,

Your first assumption is correct; a 50M tablespace with a 40M table will 
have 10M free. To see the free space in a tablespace, you can:

SELECT sum(bytes) FROM dba_free_space WHERE tablespace_name = 'TEMP';

The SQL script that you provided will give you the free and used blocks 
WITHIN the pre-allocated space for a TABLE. So in your example, after 
inserting records in the ABC table, you may have 30% used blocks and 
70% free blocks.

To find the total and free space in the TABLESPACE, you can run one of my 
favorite scripts:

SELECT a.name, b.tablespace_name,
       substr('Free: '||sum(b.bytes)/1024/1024,1,30) File_Size
FROM dba_free_space b, v\$database a
GROUP BY b.tablespace_name, a.name
UNION
SELECT a.name, b.tablespace_name,
       substr('Total: '||sum(b.bytes)/1024/1024,1,30)
FROM dba_data_files b, v\$database a
GROUP BY b.tablespace_name, a.name
ORDER BY 1,2,3
/


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

limiting rows returned ?
Newsgroups: comp.databases.oracle.misc
Subject: Re: limiting rows returned ?
References: <5j2tdu$lv4@cronkite.ocis.temple.edu>

gopal@astro.temple.edu (Gopal) writes:


>Hi Folks,
>         
>We are using Oracle 7.3.x on Win/Nt 3.51.
>I am new to Oracle and I have a question about limiting  the rows
>being returned by a select statement.
>In MS SQL Server or Sybase you can say 
>set rowcount 1
>select * from ...
>and only one row will be returned.
>Is there a similar option in Oracle which can be used in SQL plus and
>stored procedure ?
>Regards
>Gopal

Gopal,

Use the ROWNUM clause:

SELECT * FROM ... WHERE ROWNUM < 2;

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-3113 errors, suddenly

APRIL 18
Newsgroups: comp.databases.oracle
Subject: Re: ORA-3113 errors, suddenly
Keywords: 3113
References: 
tgp@iglou2.iglou.com (Terry G. Phelps) writes:

>After a year of relatively trouble-free Oracle running, first on 7.1.3
>and lately on 7.1.6, I started getting ORA-3113 errors today. I don't know
>if it's relevant, but I recently upgraded my RS/6000 AIX from 3.2.5 to
>4.1.4, and then, just a few days ago, moved all applications and data to a
>new physical server, still running 4.1.4.
>I'm getting the errors on both server "batch" processes, and also on client
>PC applications running SQLNET 1. What exactly does this 3113 error mean??
>The error text says "end of file on communications channel" or something.
>Is the Oracle connection being lost? What should I do to fix this, or at
>least to isolate the problem. This is becoming a serious issue quickly.
>HELP.

The "ORA-3113" error is defined as you said as "end of file on 
communications channel", which means that the process has suddenly been 
killed. For example, you type "Ctrl-C" during a query, or someone issues 
a "kill session" command.

However, you should be aware that this error is known to be misleading, 
and is frequently a "catch-all" error, similar to the "ORA-600" error. 
Sometimes if Oracle has a problem, it reports a "ORA-3113" even if that 
is not the true cause.

For example, I have received the ORA-3113 error when using the "analyze 
table x estimate statistics;" command. This surely does not have to do 
with SQL*Net or anything associated with Oracle communications protocols.
Since you get this error even when running server "batch" processes, it
may not be a SQL*Net problem. Check to see if you use SQL*Net even when 
running server-only batch jobs.

Try to isolate the problem. Look for any other error messages on
the error message stack. Check your "alert_SID.log" file to determine
what was occuring during the problem(s). Also, look for any trace files 
that may have been generated.

Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<->   Visit my Web Page: www.arikaplan.com                           <->
<->               email: akaplan@interaccess.com                     <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

PL/SQL manuals?
Newsgroups: comp.databases.oracle.misc
Subject: Re: PL/SQL manuals?
References:  <335C6356.E361A@pmcgettigan.demon.co.uk>

Steve Phelan  writes:
>> Is there a non Oracle Manual for PL/SQL? other than the one that
>> comes
>> with the standard set of oracle manuals?
>> Thanks in advance.
>> --
>> Talk to you later!
>> Dara
>>

> Try 'Oracle PL/SQL Programming'. Oracle Press (Osborne/McGraw Hill),
>ISBN 0-07-882176-2.

>O'Reily also have a couple of PL/SQL books. I don't have them myself,
>but I'm sure someone around here can give you the titles/ISBN's.

>Steve Phelan.


Two great books:

1) Oracle PL/SQL Programming by Steven Feuerstein
   O'Reilly & Associates, ISBN 1-56592-142-9
   1-800-889-8969

2) Building Intelligent Databases with Oracle PL/SQL, Triggers, & Stored
   Procedures
   by Kevin T. Owens, Prentice Hall
   ISBN 0-13-443631-8
   1-800-382-3419

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Poor perfmance after large delete
Newsgroups: comp.databases.oracle.server
Subject: Re: Poor perfmance after large delete
References: <5jftum$igu$1@ocoee.iac.net>

mwagoner@iac.net (Mark Wagoner) writes:
>We had been testing our database setup with sample data and decided to try
>and go live.  The main table had 1.4 million rows, which I deleted by doing
>a series of DELETE FROM WHERE statements (I tried to truncate the table,
>but Oracle said there were constraints even after I disabled them all, but
>that is another problem).  After about 2 hours the main tables were empty
>so I went in and did a SELECT COUNT(*) to make sure.  It took almost 3
>minutes for the result to come back!  It took less than 2 seconds when the
>table was full!
>I have rebuilt the primary key and the unique keys using ALTER INDEX ...
>REBUILD.  I have also coalesced the tablespace to make sure any extra
>extents were freed.  I even executed the analyze_schema procedure to update
>the dictionary.  Nothing seems to help.
>Anybody know what is going on?  I called Oracle but have yet to hear back
>from them (it has been 3 days now).  I am afraid to start loading
>production data if the performance is going to be this bad.
>Version is Workgroup Server 7.3.2.2.1 on NT 4.0 w/service pack 1 installed.
>Any help would really be appreciated.
>--
>Mark Wagoner
>mwagoner@medplus.com (work)
>mwagoner@iac.net     (life)

What has happened is that Oracle set the highwater mark for your table at the
largest size it has been (1.4 million rows). Even selecting count(*) from the
table will take a while even after you deleted from the table.

The truly best method to improve performance is to TRUNCATE the table. 
This will reset the highwater mark. You will have to disable and/or drop all
constraints that reference the table. It is insufficient to disable the
constraints on the table. To find these constraints, try:

select * from user_constraints where r_constraint_name in
(select constraint_name from user_constraints where table_name = 
'TABLE_NAME');

Then disable the constraints on the tables that are reported by the above 
statement. Truncate should work at that point.

Using the REBUILD option (7.3 only) for the indexes was a good idea as well.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 50+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Cost-based optimizer information
On Tue, 20 Apr 1999, Getman, Aric wrote:
> Ari,
> 
> Just received a new assignment to perform research on Optimizer (cost vs.
> rule).  Are there any excellent books or publications on this topic that you
> recommend?
> 
> Also, what is bitmap index?
> 
> Thanks for your help,
> 
> Ace
> 

Ace,

There was a speech on this subject alone last week at the IOUG-A '99 in
Denver. Check out www.ioug.org to get the paper and/or powerpoint. They
have a link to get it on cassette tape as well.

My opinion is that the optimizer in Oracle8 is much more stable than in
Oracle7. If you have a combination of large tables and small tables, I
would recommend it in Oracle7 although it would be less predictable.

A bitmap index (Oracle8 only) is used for "low-cardinality" columns. For
example, a column with only "TRUE" or "FALSE" with a million records would
be terrible for a regular index but for bitmap indexes it is quite good.
Bitmap indexes are stored in binary (compressed) and so take up about only
10 of regular indexes.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Oracle limitations

On Tue, 20 Apr 1999, John Holland wrote:

> Ari,
>     I am hoping you have the answer to my question, since I can't find
> anything out
>     on Deja News or anywhere else.
> 
>     Does Oracle have limitaions on users, tables, or tablespaces?  I am
> setting up a
>     central database server to serve many application servers, but I
> want to make
>     sure I am not doing this wrong.  My idea is to have the central
> database server
>     and to make it easier for backing up and for managing centrally.
> How big can
>     the maxdatafiles be?  I increased it up to 30 from 20 and I just
> want to make sure
>     I am not going down the wrong road.
> 
>     Is this the wrong approach?  Would multiple database servers be a
> better idea?
> 
>     Thank you for any help you can give me,
> 
>     John
> 
Hi John,

There are no limits on users or tables. From what I remember, Oracle7 is
limited to 1024 datafiles (and hence tablespaces of there is one datafile
for each tablespace). In Oracle8 the number of datafiles can be as many as
1 billion files.

Your init.ora file will define how many processes can connect to the
database, and your MAXDATAFILES in the CREATE DATABASE command will define
the number of datafiles for the database.

You are not going down the wrong road. I personally prefer to have a
central database and expand to multiple servers only if there is a
geographical reason (fast networks and people working in a distributed
environment around the world), or for redundancy issues for a failover
system. Certainly for 30 datafiles and even tens of thousands of users can
be handled by a single server. And yes, it makes backup (and even moreso
recovery) much easier to manager.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Error - ORA-01652

APRIL 24
Newsgroups: comp.databases.oracle
Subject: Re: Error - ORA-01652
References: <317D95E9.56D0@mail.albany.net>

Steve Rentz  writes:

>Hello,
>	I have just started working with Oracle (two days ago).  The 
>error ORA-01652: unable to extend temp segment by 5412 in tablespace 
>TEMPJCREW, was occuring before I started, and I am wondering what it 
>means, as I can not find it in any of the manuals.

>	I am really an application programmer, but in my new position I 
>am currently also acting as the DBA.  We are using version 7.1 on Solaris 
>2.5.  The error occurs after doing a rather large select.

>	We have the following tablespace set up:

>create tablespace tempjcrew     datafile 'temp01.tab' size 2000m;
>alter  tablespace tempjcrew add datafile 'temp02.tab' size 1000m;
>alter  tablespace tempjcrew add datafile 'temp03.tab' size 500m;
>alter  tablespace tempjcrew add datafile 'temp04.tab' size 500m;
>alter  tablespace tempjcrew default storage (pctincrease 1 next 10m);

>temp01.tab and temp02.tab are on separate disks.
>From what I have read, the pctincrease has no affect in version 7.

>We are selecting approximately 20 million records.  Are we just running 
>out of space.  Do we need to create another tablespace?
>Any advice is appreciated.

>Steve

Steve,

I want to wish you good luck on your new DBA role. There is much to learn, and
two days is not enough to get up to speed. This message should hopefully 
help get you going.

First of all, make sure that the user has 'TEMPJCREW' as the TEMP 
tablespace in the user profile. To do this, type:

ALTER USER username TEMPORARY TABLESPACE tempjcrew;

Your problem could be as simple as not having this set, and the 
processing of the 20 million records is taking place in another smaller 
tablespace (SYSTEM, perhaps?)

Also, the pctincrease DOES have an effect in Oracle7. You have it set 
to 1. I would recommend setting it to a more even number, such as 0 or 
100. This will depend on how many extents you expect, how large your 
smallest datafile is (500m in your case), and so on. I would recommend 
starting at pctincrease 0. If it turns out that you run out of extents, then 
simply make the default INITIAL extent for the tempjcrew tablespace larger.

To find out if you DO need more space in the "tempjcrew" tablespace, 
issue the following statement while running the 20 million record query, 
preferably several times during the execution and right before the 
ORA-1652 error:

SELECT b.file_name, a.tablespace_name, a.bytes, a.blocks
FROM dba_free_space a, dba_data_files b
WHERE a.file_id = b.file_id
AND a.tablespace_name = 'TEMPJCREW';


The above query will tell you how much contiguous free space is contained 
on each datafile. If the free space keeps declining during your query, 
and eventually runs out of space, then you can conclude that you need to add
another datafile to the "tempjcrew" tablespace.
Do not add another tablespace as you suggested, because the new tablespace 
will not be used in the query. Instead, add yet another datafile to your 
"tempjcrew" tablespace.


Good luck.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

This is an easy one. How do I do a simple directory listing of my Oracle 7 tables?

APRIL 24
Newsgroups: comp.databases.oracle
Subject: Re: This is an easy one ..how do I do a simple directory listing of my
          available Oracle 7 tables
References: <4lkc7s$dod@ionews.ionet.net>

erickson@ionet.net (Roger Erickson) writes:

(How can I do a simple directory listing of my Oracle7 tables....)

>using SQL.  I am ODBC connected and can query any one table.  I just don't know 
>how to create a list of the tables.  I've read all the docs I have and it 
>doesn't flash out at me.  Please help a newbee.

>Thank you

>Roger

Roger,

If you have a dba account, type:

SELECT * FROM DBA_TABLES;

If you have a non-dba account, type:

SELECT * FROM ALL_TABLES;

To limit your selection, use the WHERE clause. For instance, to find all 
tables with the name "PERSON" in it, type:

SELECT * FROM ALL_TABLES WHERE TABLE_NAME LIKE '%PERSON%';

Good luck.
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Need help with simple SQL syntax

APRIL 24
Newsgroups: comp.databases.oracle
Subject: Re: Need help with simple sql syntax
References: 

==============================================================================
mruggiero@access.ch (Markus Ruggiero) writes:

>Please bear with me, I always thought I know sql - now I have my doubts.
>Simple interactive query to access records with a particular VMS date
>field beeing at least 14 days in the past. What is the correct syntax?
>(Oracle Rdb, former DEC Rdb)
>SQL> select * from myTable where timeField < 'today - 14 days'
>How do I correctly specify 'today - 14 days'?I get all sorts of error messages.
>Thanks for helping
>---markus---
>e-mail: mruggiero@access.ch
==============================================================================
Markus,

There is a simple solution for your question. Oracle references today as 
SYSDATE. So, to reference 'today - 14 days', you can type:

SELECT * FROM myTable WHERE timeField < SYSDATE - 14;

Good luck.
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

System and temp tablespace
Newsgroups: comp.databases.oracle.misc
Subject: Re: System and temp tablespace
References: <335EB54A.446B9B3D@cc.uq.edu.au>

Priya Tantry  writes:
>What are the implications of having the system tablespace and the temp
>tablespace files on the same physical disk. Does that, in any way,
>affect performance?
>Priya Tantry
>University of Qld

If you have enough drives to spread one file onto each drive, that would be
the most efficient. However, in most environments this will not be the case.

Putting SYSTEM and TEMP on the same disk will affect performance based on
several factors:

1) The SORT_AREA_SIZE will mostly determine how often the TEMP tablespace is
   used. If it is sufficiently large, then no temporary segments will be
   created and thus no problems putting SYSTEM and TEMP together.
2) How many objects are in TEMP? Most environments will not put any tables, etc
   in the TEMP tablespace. If this is not your environment, then depending
   on how much the TEMP tables are used will determine whether or not put 
   the TEMP and SYSTEM togethe on the same disk.
3) Most SYSTEM activity occurs during instance startup. This is when the data
   is read and (hopefully) cached in memory. So the largest performance hit
   when merging TEMP and SYSTEM on the same disk will be when the instance
   first comes up.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What to do if your NEXT won't fit in your tablespace

I have a question about tablespaces.  Recently I ran a
query that listed all the tablespaces where the next allocated
extent would not fit in the tablespace.

My question is what my course of action should be.
Should I coalesce?
Should I export drop and import?
Or should I give more space to the tablespace?

Thanks for your assistance.
-------------------------------------------------------
Arthur,

If possible, see how many free blocks are in the table. You can:

ANALYZE TABLE xxx ESTIMATE STATISTICS;

SELECT EMPTY_BLOCKS FROM USER_TABLES WHERE TABLE_NAME = 'xxx';

This will tell you how many free blocks need to be filled up before a new
extent is needed. Sometimes you allocate the INITIAL (or even NEXT) too
large. For example, if your INITIAL is 500M and your NEXT is 500M and you
have 1 record in the table, then you will have 1 used block and thousands
of empty blocks. If the NEXT (500M) will not fit, this is OK since it will
take a while for your table to need to get another extent. Depending on
your application, this could be immediately (if you are loading data) or
not in a thousand years.

If it looks like your free blocks will soon fill up, then the preferred
method is to size your NEXT extent properly relative to your other
extents. If you still need more space, then you will need to add it to
your tablespace.

Hope this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How long to migrate Oracle 7.3 to Oracle 8.0?
> 
> Hey Ari,
> 
> I have a client that is upgrading Oracle 7.3 to Oracle 8.0 and I was
> wondering how long that would take.  We were curious as to wether this could
> be accomplished after hours in a few days or what?  Let me know.
> 
> Matt Boyce
> ETS
> 888-750-9797
> 
> 
In theory, you can do it in a day. It all depends on if the database is located
on one server (or more), and the size of the database. Oracle provides a
migration utility, but you also have to alter environment variables, networking
software, and so on.

Plus, you should back up the old database just in case, which could take
hours.

So, 2-3 days realisticly.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Restricting users to only their own records in a table
> Hi,
> 
> I want to know if i a user can access only a part of a table of another user.
> Ex.: table teste ( name1 varchar2(10) , name2 varchar2(10))
> Can i create a user that can access where name2 = 'ORACLE'???
> or 
> Can i create a user that can access only the lines that its insert????
> If not, i need a solution about it???
> 
> Thanks
> 
> Fabio Bispo
> fabio@trt20.gov.br
> 
Fabio,

One way to do this is to make views with the appropriate restrictions.
Then, you can grant SELECT on the view to the user. So, in your case, the
view would be defined as:

CREATE VIEW limited_to_oracle AS
SELECT * FROM teste
WHERE NAME2 = 'ORACLE';

As for creating a view so that users can only see the records that they
added, you can add a column in the table with the USERNAME of who did the
insert. You can add a BEFORE INSERT trigger to populate this column with
the username. Then the view would limit the result set to only records
that are the same as the current username.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Changing column names

On Thu, 29 Apr 1999, Daniel Vizel wrote:

> There are column names which have a "#" character suffix to identify
> keys in an Oracle database. Is there an easy way to create equivalent
> tables prefixed with "N_" with column names changed to remove the "#"
> character? Once new tables are created I need to copy the data from the
> original table to the new. There are around 50 tables which need to be
> copied.
> 
Daniel,

You can create the new table and move the data all in one SQL statement.
Suppose that you have a table:

Table_A
COLUMN_1#   VARCHAR2(200)
COLUMN_2#   NUMBER
COLUMN_3    NUMBER

and you want to create Table_B like
N_COLUMN_1  VARCHAR2(200)
N_COLUMN_2  NUMBER
COLUMN_3    NUMBER

You can issue:

CREATE TABLE Table_B (N_COLUMN_1, N_COLUMN_2, COLUMN_3) AS
SELECT COLUMN_1#, COLUMN_2#, COLUMN3)
FROM Table_A;

Hope that this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to use " in Oracle Data

MARCH 21
Newsgroups: comp.databases.oracle
Subject: Re: How to use " in Oracle data
References: 
<4islge$6e0@news.Belgium.EU.net>

ghp@infosoft.be (Gerard H. Pille) writes:

>In article , 
>blained (blained@nando.net) says...
>!>
>!>
>!>This is being relayed for a co-worker:
>!>
>!>We are encountering db values that contain both double quotes and 
>!>apostrophes.  Has anyone found a work-around for this situation?
>!>
>But what is the problem?

>-- 
>Kind reGards
>     \ /   |
>      X    |
>     / \   s
>     Gerard


Gerard was correct in that you didn't fully describe your problem. However,
if you want to deal with single quotes for values in your SQL statements, 
you need to prepend another single quote. For example,
-----------------------------------------------
Insert a record with a single quote at the beginning:

insert into TAB_NAME values
('''This is a test!');

See if this was inserted correctly:

select * from TAB_NAME;

'This is a test!

1 row selected.
---------------------------------------------
If you want to search for a single or double quote within a string, use the
INSTR function. If there is no quote, then a 0 is returned. Otherwise, 
the position of the quote is returned. See your SQL Language Reference 
Manual for more details on this.
---------------------------------------------
You can also use the TRANSLATE function to make all single quotes double 
quotes, or vice versa. This will change any occurence of a character to 
whatever new character you choose within a string.

I hope this helps! Your question was ambiguous, so let us know if you 
need more information. Good luck.


-Ari Kaplan
Independet Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

How can I find how many instances in a server
Newsgroups: comp.databases.oracle.server
Subject: Re: How can I find how many instances in a server
References: <5ka675$cle$1@cronkite.seas.gwu.edu>

lovedog@gwis2.circ.gwu.edu (Shaochun Lin) writes:

>How many instances in a server(down or up). Is there a
>way we can find it or some UNIX file storing this kind of info.
>Any words would be appreciated. Thanks, Shaochun,

There are several options for looking at instances on a server, depending 
on your setup:

1) Issue "ps -ef |grep pmon" or "ps -a|grep pmon"
   This will list all instances UP

2) Issue "cat /etc/oratab". This should show all instances, whether up or 
down. They SHOULD all be in this file.

3) Issue: find / -name "bdump" -print 2>/dev/null
   This will show within the paths returned the names of all instances 
(if you are OFA compliant - Oracle Flexible Architecture).

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ free technical tips, visit my Web Page:               <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What Init file values are being used?

On Fri, 30 Apr 1999, John Girifalco wrote:
> Ari, 
> 
> I have a question. Once an instance is up and running, how can you tell
> what initialization 
> file the database was started with? Is there an entry in one of the
> v$tables? Any help you 
> may provide regarding this question will be greatly appreciated. Thank
> you. 
> 
> John Girifalco 
> DBA duPont Hospital for Children 
> 
John,

You need to query the V$PARAMETER view:

SQL> desc v$parameter
 Name                            Null?    Type
 ------------------------------- -------- ----
 NUM                                      NUMBER
 NAME                                     VARCHAR2(64)
 TYPE                                     NUMBER
 VALUE                                    VARCHAR2(512)
 ISDEFAULT                                VARCHAR2(9)
 ISSES_MODIFIABLE                         VARCHAR2(5)
 ISSYS_MODIFIABLE                         VARCHAR2(9)
 ISMODIFIED                               VARCHAR2(10)
 ISADJUSTED                               VARCHAR2(5)
 DESCRIPTION                              VARCHAR2(64) 

The key columns are NAME, VALUE, and ISDEFAULT. If ISDEFAULT is "FALSE"
then it is set in the init.ora file or indirectly through another init.ora
value.

So, a good query is:

SELECT NAME, VALUE
FROM V$PARAMETER
WHERE ISDEFAULT = 'FALSE';

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Basic PL/SQL questions

On Mon, 3 May 1999 DCarter328@aol.com wrote:

> I NEED CODES FOR THESE PROBLEMS.
> 
> 1. CREATE PL/SQL ANONYMOUS BLOCK THAT DISPLAYS THE WORDS "I AM LEARNING 
> PL/SQL".

SET SERVEROUTPUT ON SIZE 10000
BEGIN
   dbms_output.put_line ('I AM LEARNING PL/SQL');
END;
/

> 
> 2. CREATE PL/SQL ANONYMOUS BLOCK THAT COMPUTES AND DISPLAYS THE AVERAGE 
> STARTING AGE OF ALL EMPLOYEES. (CREATE AN EMPLOYEE TABLE AND INPUT 3 RECORDS)

CREATE TABLE EMPLOYEE
(LASTNAME  VARCHAR2(100),
 FIRSTNAME VARCHAR2(100),
 AGE       NUMBER
)
/
INSERT INTO EMPLOYEE VALUES ('Gates','Bill',39);
INSERT INTO EMPLOYEE VALUES ('Ballmer','Steve',42);
INSERT INTO EMPLOYEE VALUES ('Weisman','Irving',41);

SET SERVEROUTPUT ON SIZE 1000
DECLARE
   avg_age NUMBER;
BEGIN
   SELECT avg(age) INTO avg_age
   FROM EMPLOYEE;
   DBMS_OUTPUT.PUT_LINE('The average age is...');
   DBMS_OUTPUT.PUT_LINE(avg_age);
END;
/    

> 
> CAN YOU PLEASE ALSO TELL ME HOW TO PRINT USING THE SPOOL COMMANDS AT THE 
> BEGINNING AND THE ENDING OF THE CODES.

You use the "SPOOL file_name.lst" and "SPOOL OFF" commands. For example,
to print the commands and the results, do:

SPOOL myfile.lst
{command1};
{command2};
{...};
SPOOL OFF

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

NOT EXISTS
> 
> Hi all:
> I have a strange problem.I have a query that is populating a particular 
> table based on equi-joins formed on multiple tables. This query seems to 
> take about 6-7 seconds. 
> insert into TABLE_A 
> select LOAN_NUMBER, 
>                 col2,
>                 col3....
> from     LOAN_TABLE,
>         TABLE_B,
>         TABLE_C
> where LOAN_TABLE.LOAN_NUMBER = TABLE_B.LOAN_NUMBER 
> and  ......;
> But when I make the following change (include NOT EXISTS), the query does 
> not seem to return any rows even after 10 mins though TABLE_A is empty.!! 
> All tables have been analyzed.
>      
> INSERT INTO TABLE_A 
> SELECT LOAN_NUMBER,
>                 col2,
>                 col3.....
> FROM LOAN_TABLE,
>         TABLE_B,
>         TABLE_C
> WHERE NOT EXISTS 
>         ( SELECT 'x' 
>           FROM TABLE_A 
>           WHERE LOAN_TABLE.LOAN_NUMBER = TABLE_A.LOAN_NUMBER ) 
> AND      LOAN_TABLE.LOAN_NUMBER = TABLE_B.LOAN_NUMBER 
> AND ......;
>      
> Any help is appreciated. 
> Thanks
> Shaheer Mecci.
------------------------------------------------------------------------
Actually, using NOT IN prevents Oracle from using an index if there is
one. NOT EXISTS (or EXISTS) is much more efficient.

Try aliasing your TABLE_A in the NOT EXISTS clause as in the following
example:

INSERT INTO TABLE_A 
SELECT LOAN_NUMBER,
                col2,
                col3.....
FROM LOAN_TABLE,
        TABLE_B,
        TABLE_C
WHERE NOT EXISTS 
        ( SELECT 'x' 
          FROM TABLE_A here_is_the_alias
          WHERE LOAN_TABLE.LOAN_NUMBER = here_is_the_alias.LOAN_NUMBER ) 
AND      LOAN_TABLE.LOAN_NUMBER = TABLE_B.LOAN_NUMBER 
AND ......;

As for not responding in 10 minutes, even though TABLE_A is empty, you may
have been locking yourself out. Try looking for locks while you are
waiting. Regardless, the aliasing above should help.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Export-related questions

> Here are my questions: I want to move some objects -not all- from a
> user on instance A to another user's schema on instance B. The objects are
> tables indexes sequences, triggers, procs, etc...
> Can I do a USER export, take the resulting export file and import only a
> portion of it? I don't see how. Otherwise if I only export in TABLE MODE, I
> have the tables and indexes I want but NOT the sequences.
> If I use TABLE mode, is there an easy way to move the sequences from instance
> A to instance B while keeping the correct NEXT value for the sequence. If
> so, what kind of script do I need to do that?
> Thanks a LOT!
Guy,

When exporting on the TABLE level, sequences are not included. Only when
you export with FULL=Y or OWNER=xxx will sequences get exported.

Your first question: can I export a user and import only part of it...the
answer is yes. Specify TABLES=a,b,c when you import. Not that you can only
select the TABLES to import; you cannot do the same for sequences,
procedures, etc.

If you want to bring over sequences: export the entire user, then do an
import with "SHOW=Y LOG=logfile.log" options. You will now have a file,
"logfile.log" which contains all of the CREATE SEQUENCE commands,
including what the current sequence numbers (and increments, etc.) are. Be
sure to remove the extra quotes and line feeds that the SHOW=Y generates.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do you determine free space in DB?
Newsgroups: comp.databases.oracle.server,culist.oracle-l
Subject: Re: How do you determine free space in DB?
References: <336a4a86.25286403@news.videotron.ca>

dandrade@icao.org (Dalton M. de Andrade) writes:

>I would like to know how to determine the following:
>1. How much space (in bytes) is allocated in the datafile(s) for a
>database;
>2. How much of the allocated space is used/free;
>3. How much unallocated space there still is in the datafile(s).
>We're running Oracle 7.1.4 on a SCOUnix box.
>Any help will be appreciated.  
>Pls e-mail me at dandrade@icao.org.

1. select tablespace_name, file_name, bytes from dba_data_files;

2. In Oracle 7.3, you can use the "dbms_space.unused_space" procedure
   to determine the used and unused space within a table.

   For your case (Oracle 7.1.4), you can see how many blocks are being USED by
   the table:

   select count(distinct substr(rowid,15,4)) from TABLE_NAME;

   The total ALLOCATED can be determined with:

   select blocks from dba_segments where segment_name = 'TABLE_NAME';

   (replace TABLE_NAME with the table you wish to analyze).

3. SELECT a.name, b.tablespace_name,
       substr('Free : '||sum(b.bytes)/1024/1024,1,30) File_Size
   FROM dba_free_space b, v\$database a
   GROUP BY b.tablespace_name, a.name
   UNION
   SELECT a.name, b.tablespace_name,
          substr('Total: '||sum(b.bytes)/1024/1024,1,30)
   FROM dba_data_files b, v\$database a
   GROUP BY b.tablespace_name, a.name
   ORDER BY 1,2,3
   /
 
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Help on how to get decode the resource id
Newsgroups: comp.databases.oracle.server
Subject: Re: Help on how to get decode the resource id
References: <5kmg57$qnl@lantana.singnet.com.sg>

engsys@merlion.singnet.com.sg () writes:

>Hello everyone,

>Can anyone tell me as how to get the exact resource from the v$lock
>using id1 and id2. I read somewhere that id1 will help in fetching 
>the object from the all_objects. 
>My question is how do i get a particluar record that is being locked
>by a particular process when o see the id1, id2. does id1, id2 point to
>a table/row or can it be any other resource.
>Thanks a lot in advance .
>Lakshmi Prasad

Lakshmi,

For the most part, id1 relates to the internal Oracle ID for an object. To
find out what it is, you can enter:

select * from dba_objects where object_id = xxxx;

Be sure to replace "xxxx" with the value of id1.

This works in many cases, including row-exclusive and table-exclusive locks.
Other locks are more internal latches, which is beyond the scope of this
response. The "Concepts" manual provides for a good background.

The above select statement will work in the majority of times, though.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Database Character Sorting
> 
> I'm curious if there is any way to produce a listing of characters in the
> order that they are sorted on the Oracle database.  I can't seem to find this
> information anywhere.  I know Sybase offers a system procedure that will
> provide such a list.  I was wondering if Oracle offered the same.  Or is there
> documentation on the sort order that Oracle uses?  Is it specific to certain
> parameters used at install?  Does it vary with the machine that the database
> is running on?
>
You can type:
select chr(1) from dual;
select chr(2) from dual;
select chr(3) from dual;
...
select chr(256) from dual;

This will show you the ASCII map that Oracle uses to sort data.

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Combining Multiple Event Triggers on One Table
> 
> Dear ari,
> 
> i have visited ur homepage and got some very usefull tips.
> thanks a lot. u are doing this as a service to the oracle community
> 
> here i have one more doubt.
> 
> is it possible to create a 2nd database trigger for a same table for a
> same event . for eg,
> 
> create trigger tr1 after insert on tab1
> begin
> insert into emp(eno) values (1);
> end
> 
> create trigger tr2 after insert on tab1
> begin
> insert into emp2(eno) values(2);
> end
> 
> 
> because i have read from one book saying that it is possible from oracle
> server release 7.1 onwards. i have tried this with oracle release 7.2 but
> it is failed with ora error number ora - 04090. 
> 
> please reply back to the same id.
> 
> thanks a lot
> 
> yours
> 
> palani
From what I have been told, this is an Oracle 7.3 (and 8.0)
feature and is not available in 7.2.

For your case, you could "combine" the logic of the two triggers
into one, although it is more work on your part. The other option is
to upgrade the database.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Picking the Least-Used Rollback Segment for SET TRANSACTION
> 
> Hi,
> 
> Could you help me here.
> 
> This is my scenario.
> I have 8 large rollback segments and a few small rollback segments.
> I have an application that requires a large rollback segment. My
> application is using the SET TRANSACTION command to set to one of the
> eight large rollback segment. 
> Now, here is my problem.
> I have to pick the least used rollback segment for the SET TRANSACTION.
> How do i go about doing this.
> 
> Regards
> Geetha
> 
> Geetha Ramasubramanian
> E-mail: gramasub@transcendent.com
> Phone:  (201) - 475 - 4242
> 
Geetha,

You should pick the rollback segment with the fewest number of active
transactions. This information is kept in the v$rollstat view in the
xacts column. You will need to link it with the v$rollname view. Look at
the following SQL:

SELECT NAME, XACTS
FROM V$ROLLSTAT a, V$ROLLNAME b
WHERE a.usn=b.usn
ORDER BY XACTS
/

This will show each rollback segment and the number of active transactions
it is working on. Now, you will need to pick the lowest one, and there can
be several "tied" with the fewest XACTS. So, look at the following SQL:

SELECT NAME, XACTS
FROM V$ROLLSTAT a, V$ROLLNAME b
WHERE a.xacts in
   (SELECT MIN(c.xacts) FROM V$ROLLSTAT c) AND
    a.USN = b.USN AND
    ROWNUM < 2
/

The ROWNUM < 2 ensures that only 1 record is returned. You can also include
the 8 large rollback segments with an addiational "AND NAME IN ('RBBIG1',
'RBBIG2','RBBIG3','RBBIG4','RBBIG5','RBBIG6','RBBIG7','RBBIG8')" to ensure
that no small rollback segments are selected.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Where is OPTIMAL Rollback Segment value stored in Oracle DD

> If I create a rollback segment with the OPTIMAL clause,
> where does Oracle store that value is their data dictionary?
> The rest of the storage parameters are stored in DBA_ROLLBACK_SEGMENTS
> 
> 
> Rick
> 

In V$ROLLSTAT, there is a column called OPTSIZE. You can join V$ROLLSTAT
with V$ROLLNAME (on the USN columns) to find the names of the rollback
segments.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Sample Data Warehouse init.ora file
Ari,

What does the initdw.ora file look like? I heard that Oracle provides a
sample one that is specific to Data Warehouses but have not been able to
find it.

thanks,

-Kevin
---------------------------------------------------------------------------
Kevin,

Here it is. I got it from Oracle 8.1, so it may be slightly different for
previous versions. The 8.1 features are noted, and parameters like
shared_pool_size and db_block_size should be the same for Oracle8.0 or 8.1.

Enjoy!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
#***********************************************************************
# Example INIT.ORA file for data-warehousing applications
#***********************************************************************
# This file is provided by Oracle Corporation to help you customize
# your RDBMS installation for your data warehousing application.
# The primary purpose of this file is to provide a starting point 
# for parameter settings in a data-warehouse. This file is designed
# for release 8.1. 
#
# 'Data warehousing' is an expansive term. In general, this file 
# assumes that a data warehouse is characterized by: 
#   - end-users execute only queries (rather than updates)
#   - end-user queries often examine large amounts of data
#   - data-loading and updating occurs only during batch operations, 
#      when the table, index, or partition is unavailable to
#      end-users' queries
#
# Some parameter settings are generic to any data-warehouse application.
# Other parameters depend upon the size of the data warehouse; different
# settings are provided for these parameters, for the following categories
# of data warehouses:
#      Category      Size of raw data      CPUs      Memory
#      SMALL         <50GB                 4         ~1GB
#      MEDIUM        50-200GB              4-12      2-4GB
#      LARGE         >200GB                12-16+    >4GB
# 'Raw data' refers to the size of the actual data, and does not
# include index space or temp space. 
# Further customization of these parameters will likely yield better 
# performance for your particular environment. 
#
# More detailed information on all parameters can be found in the 
# in the documentation. 
#
# INSTRUCTIONS: Edit this file and the other INIT files at 
# your site, either by using the values provided here or by providing
# your own.  If you are using Oracle Parallel Server,place an IFILE= line 
# into each instance-specific INIT file that points at this file.


#***********************************************************************
# Database parameters
#***********************************************************************


# Database blocks should be large in data warehouses. This improves 
# performance for operations involving large amounts of data.
db_block_size = 8192

# When building a new application, the compatibility should be set to the 
# current release to take advantage of all new features. 
compatible = 8.1.5

# Initially, set db_files to a reasonably high number.
#db_files = 1000


#***********************************************************************
# Memory parameters
#***********************************************************************


# Shared pool size should be, in general, equal to approximately 2%
# of the total physical memory. 
shared_pool_size = 20971520                              #SMALL (20M)
#shared_pool_size = 41943040                             #MEDIUM (40M)
#shared_pool_size = 83886080                             #LARGE (80M)

# The numbers of buffers should be approxiately equal to 2% of the
# total physical memory. The actual parameters value can be 
# calculated as: (2% of physical memory) / db_block_size
db_block_buffers = 2500                                  #SMALL
#db_block_buffers = 5000                                 #MEDIUM
#db_block_buffers = 10000                                #LARGE

# The following two parameters, hash_area_size and sort_area_size,
# depend upon the number of anticipated concurrent queries and the
# amount of available memory. Reasonable starting values are given
# below.  Each query will allocate its own memory for sorting and/or
# hashing, up to the maximum amount of memory specified below. Each
# parallel query will allocate up to 2 * (degree of parallelism) *
# area_size.  These values must be set so that there is enough memory 
# to accommodate the anticipated number of concurrent queries.

# Hash joins will perform better with larger hash_area_size. In a
# data warehouse that has a significant number of joins, up to 75%
# of the physical memory may be dedicated for hash joins, so these
# parameters can be increased. 
hash_area_size = 8388608                                 #SMALL (8M)
#hash_area_size = 15728640                               #MEDIUM (15M)
#hash_area_size = 26214400                               #LARGE (25M)

# For queries, sort_area_size should remain relatively small (even for
# large databases). Consider increasing the value of sort_area_size when
# building indexes.
sort_area_size = 1048576                                 #SMALL (1M)
#sort_area_size = 2097152                                #MEDIUM (2M)
#sort_area_size = 4194304                                #LARGE (4M)

# The default for create_bitmap_area_size is 8M. This default is
# adequate for cardinalities up to 1 million. 'Cardinality' is the
# number of distinct values in a given column (not the number of
# rows). For higher cardinalities, it may be necessary to increase this
# parameter.
#create_bitmap_area_size = 8388608

# Bitmap_merge_area_size is used for bitmap range queries and bitmap
# star joins. For larger databases that utilize bitmap indexes, this 
# value should be raised from the default (1M) to a value closer to
# the sort_area_size.
#bitmap_merge_area_size = 1048576


#***********************************************************************
# Parallel Query parameters
#***********************************************************************


# Parallel query parameters have been greatly simplified in release
# 8.1. These new parameters are recommended for both new data-warehouses
# as well as existing data-warehouses that are being upgraded to 8.1
parallel_automatic_tuning = true

# This parameter determines the default number of parallel query 
# processes. Typically, 2 parallel processes per CPU provides good
# performance. However, for systems with a smaller number of CPUs,
# more parallel processes may be desired. 
parallel_threads_per_cpu = 4                                 #SMALL
#parallel_threads_per_cpu = 2 or 4                           #MEDIUM
#parallel_threads_per_cpu = 2                                #LARGE

# Note that the older parallel-query parameters are still
# valid. Existing data warehouses can be upgraded to Oracle8i without
# changing any parameters related to parallel query.


#***********************************************************************
# Optimizer and query parameters
#***********************************************************************


# All data warehouses should use the cost-based optimizer. All advanced
# performance features, such as star-query support, hash joins, and
# bitmap indexes are only accessible via the cost-based optimizer.
optimizer_mode = choose 


# This parameter controls the use of new optimizations and performance
# techniques. When building a new application, this parameter should
# be set to the current release to take advantage of all new
# features. This is the default. When upgrading from an older release,
# it is recommended to set this parameter to the current release,
# although one could choose to set this to older releases for backwards
# compatibility.
#optimizer_features_enable = 8.1.5


# When using a star schema, set this parameter to true.
star_transformation_enabled = true

# The following parameters may provide better performance for certain
# environments. These should be set only after evaluating their
# performance impact.
# always_anti_join = hash
# always_semi_join = hash


#***********************************************************************
# IO parameters
#***********************************************************************


# Multiblock reads allow for the database to retrieve multiple
# database blocks in a single IO. In general, a high multiblock read
# count provides better performance. Oracle supports IO's up to 512k on
# many platforms, and this IO size is generally appropriate. Disk
# striping will also affect the value for multiblock read count, since
# the stripe size should ideally be a multiple of the IO size.
db_file_multiblock_read_count = 64

# hash_multiblock_io_count and sort_multiblock_read_count default to
# db_file_multiblock_read_count. However, when setting the
# db_file_multiblock_read_count to a large value (as above), these two
# parameters should be set to lower values.
hash_multiblock_io_count = 8
sort_multiblock_read_count = 8


#***********************************************************************
# Materialized view parameters
#***********************************************************************

# This parameter enables the use of materialized views for improved
# query performance. 
query_rewrite_enabled           = true 


#***********************************************************************
# Other Parameters
#***********************************************************************


# This section lists other parameters that, although not specific
# to data warehousing, are required for any Oracle database. 
#db_name=80 
#control_files=/vobs/oracle/dbs/t_cf1.f 

#db_name = MY_DB_NAME

# Define at least two control files by default
#control_files = (ora_control1, ora_control2)

Back to Ari Kaplan's Home Page

Dead SQL*Net process

April 7, 1996
Newsgroups: comp.databases.oracle
Subject: Re: Dead SQL*Net process
References: 
kmku@hkusua.hku.hk (Ku Kam Ming) writes:

>Are there any script or way to kill all dead processes?
>Should I use SHUTDOWN ABORT instead of SHUTDOWN IMMEDIATE in order to 
>kill all processes remained?

>Thanks,
>--
>**********************************************************************
>Kam-ming Ku (kmku)	          GB: 
>*********************************************************************
> 

Kam-ming,
If you have dead, or "zombie" processes, then sometimes shutting the
database down will not get rid of the processes. This includes either 
SHUTDOWN ABORT or SHUTDOWN IMMEDIATE.

To get rid of the dead processes that cannot be stopped from SHUTDOWN, 
first try a "kill -15 {process-id}". Substitute the process-id with 
{process-id} in the examples included here.
If that fails, then try "kill -9 {process-id}". Make sure that you logged 
in as the owner of the process (most likely it will be the "oracle" id).

Now, if the process still exists after a "kill -9 {process-id}", then do 
one of the following:
1) login as root and kill the process.
2) Physically shut down the system and restart. 

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What is a Thread Advance?

> 
> Ari,
> 
> Just visited your site and I think it's awesome!
> 
> I have an Oracle server (Solaris 2.5.1, Oracle Enterprise 7.3.3) and noticed
> that something is continuously writing the following
> line$ORACLE_HOME/rdbms/log/alert_SID.log ;
> 
> Thu May  7 06:13:43 1998
> Thread 1 advanced to log sequence 3038
>   Current log# 2 seq# 3038 mem# 0: /oracle/oracle7/dbs/log2LA98.dbf
> 
> What does this mean?  Is this the sign of a problem?  Any hints will be
> appreciated.  Thanks...
> 
> Andy Martinez
Thanks for the compliments, Andy. I do the web site for free and appreciate
comments.

As for your alert messages, they are normal notifications of redo log changes.
"log2LA98.dbf" is one of your redo logs. Oracle uses redo logs to keep track
of all changes in the database (in the event of a failure). Oracle will keep
writing changes to the online redo log; once it fills, Oracle does a switch
and puts the message you see in the alert_SID.log file. Then Oracle will
write to the next redo log, and so on.

This is a normal database occurrence.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Methods to recover database

> On Fri, 7 May 1999, Mio Mio wrote:

> Mr. Ari Kaplan:
> 
> Hi. I believe this is the first time for me to email you personally.
> We don't have much knowledge in Oracle administration much more with backup
> and recovery procedure so I though I should seek your expert advise.
> 
> We really need help at this point in time. 
> We have just made the mistake of updating several tables with the wrong set
> of data a while ago.
> The wrong update was done on a production database. As such it will
> definitely have big implications.
> 
> Is it still possible for us to _restore_ all those data?
> What we have is a full database backup done 3 days ago.
> 
> Please advise.
> 
> Thanks in advance.
> 
> Mio-Nino P. Marquez
Mio Nino,

The answer to your question depends on how you were backing up the
database. If you were using exports, then you can truncate or drop the
tables that need recovering and import the data just for those tables.

If your full backup was successful, you can recover the database in full
up to the point that you took the backup. If you are in ARCHIVELOG mode
and have all archived redo logs, then you can recover until ANY point
after your full backup.

Before you try anything, I recommend shutting down the database and making
another FULL backup of your current data, just in case.

Best regards and best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 280+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Multiple Triggers on one table? Also, Temporary Tables?

On 11 May 1999 EVL.MISMDS@RANE.sprintrpg.ems.vsnl.net.in wrote:

> Dear sir,
>          How are you?It is after a long time we are mailing to you.
>          One reason is that we did not want to disturb you frequently.
>          But to clear our doubts in Oracle,we have no other substitute
>          for you.( I include even the Oracle support we have ).This is a
>          request from us.

Sorry to hear that support is not as helpful as you would like them to be.
Be persistent with them - they should work all of your problems through to
your satisfactory resolution. I will answer your questions below:

>          The queries for which we are not able to find
a solution
>          1) As of oracle7, we cannot create more than one trigger
>             based on an event for a table.But we were able to create
>             n number of triggers for a single table for a single event
>             (for example Before insert event) and when the event occurs,
>             all of the triggers created, fires.
>             What is the basic reason for Oracle supporting this concept?

I assume that you are asking why Oracle supports multiple triggers for an
event on a table. The main reason is that it makes it easier to
selectively turn individual triggers on and off to get appropriate actions
to happen or not. If you were constrained to one trigger per event (before
Oracle8) then you would have to code ALL conditions into one trigger and
it would be more difficult to modify and maintain the code.


> 
>          2) How is the performance of Database is reduced when we create
>             more back end triggers?

It depends on what the trigger does. Basically, for each record that you
insert/update/delete (depending on the trigger), the database performance
will degrade by how long it takes for the trigger code to be processed.
For example, if you COMPUTE statistics after every record entered in a
million-record table, your performance will be horrendous. On the other
hand, if you ensure that one field is converted to uppercase before being
inserted, your performance will be mostly unaffected.

> 
>          3) Is there any term like TEMPORARY TABLES in Oracle? I was told
>             that we can create temporary tables in oracle which will be
>             existing for the current instance. If Database is shutdown and
>             started, these tables will disappear. If this statement is true,
>             please give us the syntax of creating such tables.

In Oracle 8.0 and earlier, I am not aware of any such tables. There are
CURSORS in PL/SQL (Oracle 8,7,6) that act as temporary tables. You can
define them, open them, fetch records from them, and so on. They are
removed when you close the cursor. In Oracle 8i, there are temporary
tables, but I do not have the syntax to create them for you.

>          We are using Oracle for our day to day transactions and we are
>          attracted by this excellent RDBMS and we want to learn more and
>          more and always keep learning Oracle.If this is not disturbing,
>          we will be frequently mailing to you.
>          Thanking you.
>          From
>             ( P.B.Neelagandan And N.Hariharan )
You are welcome to email me as many questions as you like. I get many a
day and cannot guarantee that I can answer them for you if I become busy.
But feel free to try!

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Using an inner SELECT statement with UPDATE

On Tue, 11 May 1999, Parry, Brian S wrote:

> Ari,
> 	I'm very new to Oracle.  I've used MS SQL Server for 3 years.  I'm
> trying to update one table with data from another table where they have some
> matching information.  I keep getting the following error:
> 
> SQLWKS> UPDATE INCOMING_LEAD
>      2> SET INCOMING_LEAD.DEPARTMENT_CD = OFFER_INPUT_KEYCODE.DEPARTMENT_CD,
>      3>     INCOMING_LEAD.PROGRAM_CD = OFFER_INPUT_KEYCODE.PROGRAM_CD,
>      4>     INCOMING_LEAD.EFFORT_CD = OFFER_INPUT_KEYCODE.EFFORT_CD,
>      5>     INCOMING_LEAD.OFFER_CD = OFFER_INPUT_KEYCODE.OFFER_CD
>      6> FROM OFFER_INPUT_KEYCODE
>      7> WHERE OFFER_INPUT_KEYCODE.INPUT_KEYCODE =
> INCOMING_LEAD.PROMO_INITIAL_KEYCODE
> 
> FROM OFFER_INPUT_KEYCODE
> *
> ORA-00933: SQL command not properly ended
> Can you tell me what I am doing wrong?
> Thank you very much for your help,
> Brian
> brian.parry@eds.com
> 
In Oracle, the syntax is:

UPDATE INCOMING_LEAD
SET (INCOMING_LEAD.DEPARTMENT_CD, INCOMING_LEAD.PROGRAM_CD,
     INCOMING_LEAD.EFFORT_CD, INCOMING_LEAD.OFFER_CD) =
    (SELECT OFFER_INPUT_KEYCODE.DEPARTMENT_CD,
        OFFER_INPUT_KEYCODE.PROGRAM_CD, OFFER_INPUT_KEYCODE.EFFORT_CD,
        OFFER_INPUT_KEYCODE.OFFER_CD
     FROM OFFER_INPUT_KEYCODE
     WHERE OFFER_INPUT_KEYCODE.INPUT_KEYCODE =
           INCOMING_LEAD.PROMO_INITIAL_KEYCODE)
/

You basically do one inner select and join the two tables in the inner
select's WHERE clause.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Set instance 2: command

Newsgroups: comp.databases.oracle
Subject: Re: Set instance 2: command
References: <3198A016.7EED@kbsi-aus.com>

Yvonne Butler  writes:

>I have 3 instances running... but I can't seem to get the 
>"Set instance 2: [SID]" command working when I get into SQLDBA.
>I'm running in a Unix environment.

>Help!!!

Yvonne,

Look at the Oracle7 Server Utilities Guide, Pages 12-21, 12-23, and 12-25.
For those comp.database.oracle people that don't have the guide, it basically
says that the SET INSTANCE changes the DEFAULT instance for SQL*DBA 
sessions. It does NOT connect you to the database. The default instance
"is used for the STARTUP, SHUTDOWN, and CONNECT commands when no instance
is specified."

The syntax is as follows: node name, hyphen, database name:
INSTANCE home_office-main_database

If all you wanted to do was use SQL*DBA for your different SIDS, there is
a much easier method. Simply type:

export ORACLE_SID=sid-name

(substitute "sid-name" with the actual ORACLE_SID).

Then, go into SQL*DBA and connect!

Good luck....

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SQL Query
Newsgroups: comp.databases.oracle
Subject: Re: SQL Query
References: <319A4927.41C67EA6@openmarket.com>

May 15, 1996

Shuzi Chen  writes:

>How to write the SQL like the following?

>   select * from test where name like 'hel[ply]'
>   it will return the records which name is help, hell or hely.
>Sybase can do exactly like the above. I do not think the Oracle supports
>the [].

>Thanks in advance.
>-- 
>----------------------------------------------------------------------
>Shuzi Chen               
>chen@openmarket.com

One way to do this:

select * from test where name in ('HELP','HELL','HELY');

In Oracle, there are only two pattern characters used in conjunction with 
the LIKE clause:

1) The underscore is a one-character wildcard. So,

select * from test where name like 'HEL_';

will return HELP, HELL, HELY....but it will also return HELA, HELB, HELC, 
etc. if those rows exist in the table.

2) The percent sign is a several-character wildcard...

select * from test where name like 'HEL%';

will return HELP, HELL, HELY....but it will also return ALL records that 
start with 'HEL', such as 'HELLO', 'HELTER-SKELTER', 'HELOTROPISM', well 
you get the idea.

Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-06571
Newsgroups: comp.databases.oracle.misc
Subject: Re: ORA-06571
References: <5lfvc4$q3i$1@newbabylon.rs.itd.umich.edu>

lbt@terminator.rs.itd.umich.edu (Lyle B Tiffany) writes:
>Oracle claims the following with the message "ORA-06571: Function XXX does
>not guarantee not to update database".
>   select XXX('one', 'two') from dual;
>But the function XXX does not really update any databases.  How in the world
>can I fool the Oracle?  The manual I have does not have the message number
>ORA-06571.
>-- 
>Bernard Tiffany                      
>Internet: Bernard.Tiffany@umich.edu                     CompuServe: 75046.2667 
>"With malice toward none; with charity for all" Abraham Lincoln, March 4, 1865

Bernard,
According to my documentatoion

06571, 00000, "Function %s does not guarantee not to update database"
// *Cause:  There are two possible causes for this message:
//          * A SQL statement references a packaged, PL/SQL function
//            that does not contain a pragma that prevents the database
//            from being updated.
//          * A SQL statement references a stand-alone, PL/SQL function
//            that contains an instruction to update the database.
// *Action: If the referenced function is a packaged, PL/SQL function:
//          Recreate the PL/SQL function with the required pragma; be
//          certain to include the 'Write No Database State' (WNDS)
//          argument in the argument list of the pragma.
//          If the referenced function is a stand-alone, PL/SQL function:
//          Do not use the function.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Scheduled Hot Online Backups - HELP!!!
Newsgroups: comp.databases.oracle.server
Subject: Re: Scheduled Hot Online Backups - HELP!!!
References: 

"Hadi@Force12.com"  writes:
>I'm having severe problems setting up scheduled hot online backups.
>Here's what I've done.
>Installed Oracle7 Workgroup Server 7.3.2.2.1 for WindowsNT 4.0 along
>with OEM 1.2.2 . The installation was carried out as per the manuals and
>Note:45412.1 from Oracle UK Response Centre (OEM 1.2.2 Installation and
>Configuration)

>The Starter database ORCL was setup and running when I first logged in
>to OEM as the repository owner.  

>I wanted to do an online backup of the Orcl database and (its
>tablespaces), however the database was running in NOARCHIVELOG mode.

>I couldn't shutdown the database as DBA so I connected as internal and
>ran the following script:

>STARTUP NOMOUNT;
>ALTER DATABASE MOUNT;
>ALTER DATABASE ARCHIVELOG;
>ALTER DATABASE OPEN;

>On logging back into OEM as the DBA, the ORCL database and Listner had
>red crosses through them so I couldn't schedule a backup job.

>I rang Oracle support, who suggested that I set up a shedule in NT using
>the AT command and run a batch file to log into Oracle and run a backup
>script.  This sounds like a less than optimal solution given that we are
>developers with a VB front end application who want to set up the backup
>process for a distant customer (without a dba) and not have to provide
>constant dba-style support.

>So here in a nutshell is what we want to do:

>Simple automatic online backups, preferably to a tape drive, requiring
>minimum support.

>I hope someone can help.

>Thanks to anyone who can.

>Hadi
>Hadi@Force12.com
It is not sufficient to "ALTER DATABASE ARCHIVELOG" to start archiving.
You must also include:

log_archive_start=true
log_archive_dest=???
log_archive_format=???

in your init*.ora file. Be sure to sop and start your database for the
parameters to take effect.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

dbms_output causing problems
> Thanks, the problem was due to statements in the function such as:
> 
>    dbms_output.put_line('xxxxxxx');
> 
> By commenting out the statements, the error ORA-06751 disappeared.
> -- 
> Bernard Tiffany                      
> Internet: Bernard.Tiffany@umich.edu                     CompuServe: 75046.2667 
> "With malice toward none; with charity for all" Abraham Lincoln, March 4, 1865
Bernard,

If your dbms_output is causing problems, try running the following script:

$ORACLE_HOME/rdbms/admin/dbmsotpt.sql

This will re-create and re-compile your dbms_output built-in package. If the
script successfully runs, then try un-commenting the statements.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Tablespace Fragmentation
Newsgroups: comp.databases.oracle.server
Subject: Re: Tablespace Fragmentation
References: <5li9d0$1b8@owl.jmu.edu>

gangadnx@jmu.edu (Nadira Gangadhar) writes:
>We're running Oracle 7.1.6 and 7.3.2 on HPUX and need some help with tablespace 
>fragmentation problems.  We routinely run a script (on 7.1.6 databases) that 
>was created in-house to defrag tables and indexes (through export and import), 
>and we use a script that forces a coalesce of contiguous free extents in 
>tablespaces, which is from Oracle Support.  The tablespace coalesce does not 
>get all the disjointed bits of free space (looked at user_free_space).  There 
>is therefore a lot of total free space but in small chunks, so we have to keep 
>adding datafiles.  For 7.3.2 databases the tablespace coalesce and rebuild 
>index commands are used.  

>How do we deal with this problem?  I have been told that exporting, dropping 
>the tablespace, and importing takes a considerable amount of time and is not 
>feasible.  We're currently evaluating a few tools that do reorgs (any 
>suggestions here?), but it will be several months before we can get one.

>Thanks for any help.
Exporting, dropping, and importing everything will do the job. You are
already exporting, dropping, and importing via your in-house script, so I
don't think the process will be any slower. It just depends on if you were
routinely doing this for ALL tables/indexes.

Other parameters to look at:

* Are your PCT_INCREASEs 0 or 100? Making it anything else causes the
fragmentation you describe.
* Are your INITIAL EXTENT/NEXT EXTENT exact multiples of your
db_block_size? If not you will also encounter fragmentation.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ Oracle technical tips, visit my Web Page:             <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to change password in SqlPlus/Net?
Newsgroups: comp.databases.oracle.misc
Subject: Re: How to change password in SqlPlus/Net?
References: <5li7g8$kif$1@hecate.umd.edu>

epaik@deans.umd.edu (Ellen Paik) writes:
>Sorry about the cluelessness of the question, but how do you change your
>password (the one you use to connect to an Oracle database)?  I'm talking
>about the one you'd code into your Pro C program in the EXEC SQL CONNECT
>string, not the one to get on a server that runs the Oracle gateway.

>Hope that made sense.  Any help would be greatly appreciated.

>+------------------------------------------------------------------+
>| Ellen Paik                                                       |
>| Programmer/Analyst                                               |
>| Academic Data Systems                                            |
>| University of Maryland, College Park                             |
>| Phone: (301) 405-7259                                            |
>| Fax:   (301) 405-7942                                            |
>+------------------------------------------------------------------+
In SQL*Plus, type:

alter user USERNAME identified by PASSWORD;

This will change the users's password (assuming you are the user or have
DBA privileges).

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Creating a Database

> 
> Hi Ari,
> 
> I have enjoyed your talks @TCF for 2 years.  
> 
> Here I have one question:
> 
> I'm going to create one Instance (not the default one)
> on NT box.  Could you direct me to the right procedure
> or Web-link.
> 
> Thanks.
> 
> Alex Lin
> 
> 
Your Oracle program should have come with some documentation. Check the
CD-Rom. You can also look at "Oracle8: Beginner's Guide" or "Oracle:
Beginner's Guide" by Oracle Press. Also, my "Oracle8 How-To" has step-by-
step instructions on setting up an NT database.

Basically you use the "CREATE DATABASE" command to create the initial
SYSTEM tablespace, control files, and redo logs. You will need to have an
initSID.ora file with all needed parameters created. After the initial
creation, you need to create additional tablespaces, rollback segments, and
then run the "catalog.sql" script.

I know this is the much-shortened version, so I recommend looking at those
books. No Web pages come to mind.

Best of luck, and thanks for coming to my TCF speeches.

-Ari

Back to Ari Kaplan's Home Page

Question about check constraint
Newsgroups: comp.databases.oracle.misc,comp.databases.oracle.server,comp.databases.oracle.tools,comp.databases.oracle.marketplace,comp.databases.oracle
Subject: Re: Question about check constraint
References: <864055106.15780@dejanews.com>

tomas@senna.std.lt writes:

>Does anybody know is it possible create check constraint that restrict
>updating or inserting into table columns of varchar2 type values that
>have numbers or others symbols ex: test11 not allowed  test[ not allowed 
>test allowed

There are several ways to do this:

In the check constraint clause,
1) instr(upper(translate(column_name,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()"-_=+[]/?;:,.<>',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ00000000000000000000000000000000000')),'0') =0

This will be 0 if only characters are used. Otherwise a number > 0 will be
returned and the constraint will prohibit the record to be inserted.

2) Do it the long way:
  column_name not like '%0%' and column_name not like '%1%' and
  column_name not like '%2%' and column_name not like '%3%' and
  column_name not like '%4%' and column_name not like '%5%' ...
  ....
  ....

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

SQL: Truncate and referential integrity

On Wed, 19 May 1999, Tarver, Steven wrote:
> Hi Ari,
> 
> First time asker, long time reader!  My question:
> 
> I wish to delete all records from a parent table and all records from a
> child table.
> 
> If I delete from from the child table then delete from the parent,
> everything works fine.  But if I truncate the child table, then try to
> truncate the parent, I get an error:
> 
> ERROR at line 1:
> ORA-02266: unique/primary keys in table referenced by enabled foreign keys
> 
> Do you have insight into this?
> Thanks and best regards,
> Steve Tarver
> 
Steve,

Glad that you enjoy my web page!

As for your question, I can hopefully shed some insight, which lies in the
differences between the DELETE command and the TRUNCATE command.

DELETE removes one or more records in a table, checking referential
constraints (to see if there are dependent child records) and firing any
DELETE triggers. In the order you are deleting (child first then parent)
there will be no problems.

TRUNCATE removes ALL records in a table. It does not execute any triggers.
Also, it only checks for the existance (and status) of another foreign key
pointing to the table. If one exists and is enabled, then you will get
your error. This is true even if you do the child tables first.

You should disable the foreign key constraints in the child tables before
issuing the TRUNCATE command, then re-enable them afterwards.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-01555: snapshot is too old error

> 
> Hello
> 
> I'm getting these errors when I execute the script below:
> 
> Errors:
> 
> 01555: snapshot is too old; rollback segment number 4 with name "R03"
> 
> Script:
> 
> SELECT  se_desc, na_desc, DECODE (fw_sex, 'L', 'Lelaki', 'P', 
> 'Perempuan') fw_sex,  COUNT (fw_reg_icno) fw_cnt
> FROM     mh_renewal, dc_fworkers d, mh_sector, mh_nation
> WHERE  fw_nation = na_code
> AND        fw_sector = se_code
> AND        rl_doc_no = fw_id
> AND        fw_worker_type IN ('F', 'M')
> AND        rl_app_date 
> BETWEEN TO_DATE (:p_from_date, 'DD/MM/YYYY') 
> AND        TO_DATE (:p_to_date, 'DD/MM/YYYY')
> GROUP BY se_desc, na_desc, fw_sex
> 
> Any ideas what causes this and workarounds? I attached a file regarding 
> the rollback segments size :
> 
Whatever your rollback segment sizes are, they are not enough for your
transaction. The ORA-1555 indicates this. You have two choices:

1) Increase the sizes of all rollback segments. How large is impossible
   for me to say without knowing what indexes exist, the size of the four
   tables, etc. You will have to try some larger value, and keep increasing it
   if you keep getting the ORA-1555 error.

2) Have a large rollback segment, and before you execute a transaction, enter:
   "ALTER SESSION SET TRANSACTION rollback_name;"
   to use a large rollback segment.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to copy LONG column
Newsgroups: comp.databases.oracle.server
Subject: Re: How to copy LONG column
References: <33826895.2A40@mindspring.com>

Tom Wilson  writes:
>I need to copy a long varchar from one table to another using 
>UPDATE tab1 SET longcol = (SELECT longcol2 FROM tab2 WHERE 
>tab1.key=tab2.key);
>But I get an error that this is an invalid use of a LONG column.  How do 
>I insert or update a long column by copying a value from another column?
>Tom

The only way I have been able to do this is to use PL/SQL. Define a
variable as LONG and open a cursor into the variable. From here you can
manipulate the variable in ways you cannot with straight SQL. Things such
as substr, rtrim, instr, length, etc.

I hear Oracle8 will be able to handle LONG manipulations in SQL.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 60+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Copying constraints, indexes, etc. along with a table
> 
> Hi ari 
> 
> I recently purchases your oracle8 - How To book with is very good. I have all
> read your technical reponses which I  found quite useful 
> 
> I was hoping you could help me witha  small problem 
> 
> I have got two instances on one machine a production and a development
> instance. 
> 
> There have been time when I needed to copy a table from the development to
> the production instance, but when I do that it does not seem to recreate all
> the triggers, constraints, indexes etc 
> 
> Is there an easy way to copy a table with all its indexes , constraints etc 
> 
> regards 
> 
> michael Dsouza
> 
> 
> 
Glad you like the book.

To copy a table with all indexes, constraints, triggers, grants, etc.
you need to EXPORT the table from one instance and
IMPORT it into the other.

To get all of the commands, you can type

IMP SHOW=Y to see all of the CREATE commands.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Working with DBMS_OUTPUT

On Wed, 19 May 1999, Jonathan Lui wrote:

> I am having problems getting the DBMS_OUTPUT to work.  I have used the set
> serveroutput on.  How do I enable this option?
> 
> As well I would like to display a number returned from a select count(*)
> command in a report.  Would I have to store this value in an array or would
> I have to put this value temporarily into a field and extract it that way.
> 
> Thanks
> 
> Jonathan Lui
> 

Jonathan,

You can select the count into a variable and then use DBMS_OUTPUT to
display the results:

DECLARE
  var_count   NUMBER
BEGIN
  SELECT COUNT(*) INTO var_count
  FROM my_table
  WHERE column_1 = 'HAPPY GILMORE';
  DBMS_OUTPUT.PUT_LINE('The count is ...');
  DBMS_OUTPUT.PUT_LINE(var_count);
END;
/

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

select the last n records from a table

On Fri, 21 May 1999 pgrossi@lycosmail.com wrote:

> Hi Ari, 
> 
> I'm trying to select the last n records stored on a table but I didn't find
> until now a solution to my problem. Could you help me ?
> I tried using rownum way but I don't know if it's the right and/or the best
> way.
> 
> Thanks in Advance
> 
>    Pietro

Pietro,

ROWNUM can only be used to select records from the "front" of the order of
records being returned.

To find the "last" n records depends on what you mean by "last". Oracle
returns records randomly (actually by the way they are stored) unless
there is an ORDER BY CLAUSE.

If this is the order, then you can make a PL/SQL routine. Create a cursor
with any ORDER BY CLAUSES (not mandatory). Then make a counter variable.
When you select a record, increment the counter. After the counter
surpasses a threshold, start returning records (DBMS_OUTPUT.PUT_LINE).

Hope that this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What's a schema, and should I update SYS tables/views?
> 
> Mr. Ari Kaplan,
> 
>   Remember me. Some time back I contacted U regarding Rollback Segments,
>   Now I want some details regarding Schemas.
> 
>   1. Upto my knowledge Schema is created by default with the same name
>      as the username. But can I create Schemas on my own and assign
>      some users to use that Schema ?
>      
>      Please give me some real life examples of Schemas.

A schema is a user account, along with all of the objects owned by that
user account. So, one thing you can do is create tables under one user account
and grant SELECT, INSERT, UPDATE, and/or DELETE privileges to PUBLIC or roles
or other user accounts. Also you can do the same for synonyms (CREATE PUBLIC
SYNONYM x for username.x).

> 
>   2. Let us say I have the following table :
> 
>      table name : LOG_FOR_USER_SESSIONS
>      owner      : SYS
> 
>      column name           datatype         description
>      --------------------------------------------------------------
>      USER_NAME             VARCHAR2(30)     STORES USERNAME
>      DIS_CONNECT_TIME      DATE             STORES CONNECT TIME OR
>                                                 DISCONNECT TIME
>      CONNECT_OR_DISCONNECT VARCHAR2(1)      STORES 'C' IF CONNECT
>                                             STORES 'D' IF DISCONNECT
>      ----------------------------------------------------------------
> 
>      Now tell me how do I store information regarding user connects and
>      disconnects into the about table.

Don't mess with SYS tables. What you should do is set up database auditing.
You can audit to this LOG_FOR_USER_SESSIONS table or to a file. Look at your
Oracle documentation on Auditing.

> 
>   3. Is there any way to update DYNAMIC PERFORMANCE TABLES.

No. They are read-only VIEWS (they are not tables).

> 
>   THATS ALL FOR NOW
> 
>   THANX IN ADVANCE FOR HELPING ...
> 
Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Using alter table add constraint syntax ?
Newsgroups: comp.databases.oracle
Subject: Re: Using alter table add constraint syntax ?
References: 

esha1@cix.compulink.co.uk ("Mike Ziemann East Su") writes:

>This is a line from my create table statement which successfully creates 
>a constraint on a table T95  :

>SPARE_1                 NUMBER(10)   CONSTRAINT IDX_T95 UNIQUE USING
>INDEX 
>STORAGE(INITIAL 3000K NEXT 250K MINEXTENTS 1 MAXEXTENTS 99 PCTINCREASE 0)
>TABLESPACE CMDS95,
>my problem is that I want to delete this constraint then recreate it in
>a different tablespace.  I deleted it with:

>alter table T95 drop constraint idx_t95 cascade;
> but I just cant work out the alter table add syntax to create it
> somewhere else!! Can anybody help ?
> Please email answer to
>
> esha1@cix.compulink.co.uk
> Thanks
> Mike

Mike,

Issue the following statement:

alter table T95 add (constraint idx_t95 unique (COLUMN_LIST)
                     using index tablespace NEW_TABLESPACE
                           storage (initial 3000k next 250k
                                    minextents 1  maxextents 99
                                    pctincrease 0));

The COLUMN_LIST is the columns in order that the index should be based on.
Replace NEW_TABLESPACE with the tablespace that the index should be
created in.
Also, the "using index" clause enforces the uniqueness with an index that has
the same name as the constraint. This clause should only be used for
unique and primary key constraints. In your case it is.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Oracle sequences: how does it work internally?

On Mon, 24 May 1999, Andreas Reinbrecht wrote:

> Hi there - I have a question that is giving everybody in our company
> headaches.  We are using oracle as the database for a MAGIC application
> (which has been running without any problems for at least 5 years).
> 
> The problem we have is that we have a 0 record created (unique key) in one
> of tables.  The programs that create a new 'Product' in the table, call a
> separate little resident task that grabs the next oracle sequence in
> embedded SQL:
> 
> SELECT psseq.nextval FROM dual
> 
> Is the what the query looks like.
> 
> Now to the question:  I need to know exactly how oracle assigns sequences,
> how locking is handled by the database, and what kind of locking is taking
> place.
> 
> A theory that I have is that this program that returns the new sequence
> after the SQL is executed, might return a zero if 2 users do the .nextval at
> exactly the same time.  But before I can change the program, I need to know
> whether you think I am looking at the right place, the red-tape involved in
> updating the system is extensive .
> 
> The task that runs the query is set to "Lock before Update", "Retry on
> Locked Record", and "Skip on Fail".  Seeing as sequences aren't physical
> 'records' because the number is assigned dynamically, I think the record
> locking that MAGIC implements falls through, and the "Skip on Fail" might
> actually tell the program to abort if Oracle encounters an error, *other*
> than a locked table/record.
> 
> Well, I surely HOPE you can try and help me explaining exactly what happens
> in the oracle process!
> 
> Thanks in advance,
> Andi
> 

Andi,

I hope that I can help out. Oracle does not handle sequences like it does
other objects such as tables. For example, if you insert 10 records with
the NEXTVAL and then issue a ROLLBACK command, the sequence does not get
rolled back. Rather, the 10 records will have incremented the sequence and
the next insert will have the 11th value of the sequence. This will result
in "holes" in the sequence. Oracle chose this so that multiple people can
safely use a sequence without fear of duplicate values.

So, if two users simultaneously grab the NEXTVAL, they will each be
assignment unique numbers. Oracle can do this because it caches the
sequence in memory. The init.ora parameter SEQUENCE_CACHE_ENTRIES controls
the size of this cache.

If you want to "skip on fail" then you should determine the error NUMBER
being returned and then have the program decide if it is a "fail" type of
error.

For the "retry on lock" you can determine if the record is locked first.
Review the V$LOCK data dictionary view for more information on how to do
this.

Best regards to everyone in the ".za" domain!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-4090 error

On Mon, 24 May 1999, SYEDFEROZ wrote:

> hi,
> 
> i have this vague problem with oracle 7.3.4.
> 
> we have one development machine running an oracle instance. in our
> application there is a need for writing multiple triggers on the same table
> for the same event. now creation of this triggers is not a problem and it
> goes through fine on the development machine, of course with the sequence of
> execution not guaranteed.
> 
> now to test the same we have created another database and when the scripts
> are run on the new database an error ora 04090 is reported, whereas the same
> runs perfectly on the development database.
> 
> any solutions/reasons as to why this happens?
> 
> rgds
> 
> feroz
> 
Feroz,

Are the development database and the new database of the same 7.3.4
version? If so, then is the "COMPATIBLE" initialization set differently in
the two databases? If not then I would recommend calling Oracle support.

From my understanding, ORA-4090 would be returned in 7.3.4 no matter what:

04090, 00000, "'%s' specifies same table, event and trigger time as '%s'"
// *Cause: Trigger is of duplicate event and trigger time.
// *Action: Combine the triggering information into one trigger which is
//         fired at the given time.  

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

TKPROF syntax

On Thu, 13 May 1999, Gopal Raghavan wrote:

> Hi Ari:
> 
>    I have a couple of questions for you.  Is the TKPROF utility
> available for Oracle 7.3.4 and Oracle8?  I dont see any mention of this
> in Oracle8 books.  If available, how does one use it?  I remember
> having to input the FOREGROUND_DUMP_DEST parameter in the Init.ora file
> for Oracle V 6.  Oracle8 does not permit me to put this parameter in
> the Init.ora file.  The second question is, Is anybody using the
> Object-oriented features of Oracle8 for development, in the real world?
>  Looks like the mixture of Object-oriented and relational features are
> more of a hinderance than enhancement. What do we have to do
> specifically as DBAs to accomodate object-orientedness?  Your web page
> is the best!!
> 
> Best Regards.
> Gopal Raghavan
> 
Gopal,

Glad that you like my web page. I will answer your questions below:

1) TKPROF: Yes, it is still used but the FOREGROUND_DUMP_DEST is no longer
used. There is info in the Oracle docs on this. Here is the syntax:

Usage: tkprof tracefile outputfile [explain= ] [table= ]
              [print= ] [insert= ] [sys= ] [sort= ]
  table=schema.tablename   Use 'schema.tablename' with 'explain=' option.
  explain=user/password    Connect to ORACLE and issue EXPLAIN PLAN.
  print=integer    List only the first 'integer' SQL statements.
  aggregate=yes|no
  insert=filename  List SQL statements and data inside INSERT statements.
  sys=no           TKPROF does not list SQL statements run as user SYS.
  record=filename  Record non-recursive statements found in the trace
file.
  sort=option      Set of zero or more of the following sort options:
    prscnt  number of times parse was called
    prscpu  cpu time parsing
    prsela  elapsed time parsing
    prsdsk  number of disk reads during parse
    prsqry  number of buffers for consistent read during parse
    prscu   number of buffers for current read during parse
    prsmis  number of misses in library cache during parse
    execnt  number of execute was called
    execpu  cpu time spent executing
    exeela  elapsed time executing
    exedsk  number of disk reads during execute
    exeqry  number of buffers for consistent read during execute
    execu   number of buffers for current read during execute
    exerow  number of rows processed during execute
    exemis  number of library cache misses during execute
    fchcnt  number of times fetch was called
    fchcpu  cpu time spent fetching
    fchela  elapsed time fetching
    fchdsk  number of disk reads during fetch
    fchqry  number of buffers for consistent read during fetch
    fchcu   number of buffers for current read during fetch
    fchrow  number of rows fetched
    userid  userid of user that parsed the cursor

2) The object-relational features:
   I do not know anyone who uses these. Basically, you can define your own
datatypes, nest tables, and have array-type columns. If you have a need
for them go for it, otherwise I do not know anyone using these features
yet. I heard that their performance is worse than having regular tables
joined together. This was as of 8.0.3.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Oracle Licensing - How much does it cost?

On Tue, 25 May 1999, Dave Van Zandt wrote:

> Hi, I attended your IOUGA session, and I recognize you may not have time
> to address this.  My question is, your script on "concurrent users"
> treats the sessions at the time of the snapshot: is this the criteria
> Oracle uses to establish licensing, i.e, one session = one concurrent
> user?  If so, is one then penalized because of the SYSTEM background
> processes running?
> 
> I don't seem to get a straight answer from Oracle Sales on this one --
> wonder why.....
> 
> Kind regards,
>  
> David Van Zandt
> David.Vanzandt@Alcoa.com
> 
Dave,

Glad that you attended my session. As for your question, it is a good one.
Oracle Sales has different criteria for different licenses. There is an
unlimited license (based on a per-CPU bases) which is different for
production and development databases. There is a subscriber-based license
(number of users in a database - that is the number of "subscribers" to a
service with profiles stored in the database). There is also a per-user
license. This is what you are most likely referring to.

First, Oracle does not have any limitations in the database for licensing.
For instance, if you have a 5 user license and 500 people connect, they
WILL technically be able to. You will just be operating illegally.

As for the script from the speech, the query IS the one for the per-user
basis. You should look at the "maximum concurrent users since the database
came up" results and subtract the number of background processes to get
the per-user license arrangement. This varies (you may have multiple
database writers, for instance).

Keep in mind that the licensing issues are constantly changing from
Oracle. The people I deal with are generally flexible (anywhere from 10%
to 35% off) depending on the situation. So, keep working with your Sales
Representative (or talk to several of them from different companies) until
you can mutually work something out.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Where are the Oracle8 How-To source codes?
> 
> Dear Sir:
> 
> Re: Oracle8 How - To publish in 1998 DSBN# 1-57169-123-5
> 
> I could not find the book's source codes at http://www.mcp.com  I get =
> message " the site is invalid site" or similiar message.
> 
> I go to http://www.waite.com and I find Oracle8 How-To published in 1996 =
> or 1997 and its IBSN # is a different number. The book I purchased was =
> published in 1998, not 1996 or 1997.
> 
> Please e mail me where I can find web site to  download source codes.

Yes, there was an "Oracle How-To" and "Oracle8 How-To". The web page you want
(with the source code) is:

www.waite.com/dev/1-57169-123-5/1-57169-123-5.html

You can link to it off of my web page at:
www.arikaplan.com                       

> 
> My PC has Window 95 and not be installed  Window NT. My Oracle8 does not =
> have "Type".   Can I still run book's sample files under Window 95 and =
> without "Type"?  =20
The sample files should all work. I don't know why your type does not work.
Maybe your syntax is incorrect. If the samples regarding TYPE still don't
work then make sure that you installed the object-relational features when
you installed the database.

> 
> Thanks.
>  Sincerely,
> 
> Mike  Liu=20
> 

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Can't drop a table
On Wed, 26 May 1999, Goolalay Goolalay wrote:
> Hi Ari,
> My problem is I can't drop one particular table. Error message is
> ORA-00604: error occurred at recursive SQL level 1
> ORA-08102: index key not found, obj# 35, dba 83887328 (2)
> 
> Not even describe the table. I asked Oracle support but they don't have any 
> solution right now, the last thing I would do is to restructure everything. 
> That particular table also cannot be exported.
> 
> Another question is, can I export whole tables except a few in one line 
> statement, exp73 ........ table=....
> 
> Thanks in advance.
> 
(NOTE: Additional advice from Allen Moore after my comments!)

The error messages that I see are:

08102, 00000, "index key not found, obj# %s, dba %s (%s)"
// *Cause:  Internal error: possible inconsistency in index
// *Action:  Send trace file to your customer support representative,along
//           with information on reproducing the error

To find the object, issue:

SELECT * FROM DBA_OBJECTS WHERE OBJECT_ID = 36;

If you can drop the object then you should be fine. Sometimes Oracle has
objects created with the name in lowercase:

SQL> CREATE TABLE "lower_tab" (COL1 VARCHAR2(100));

Table created.

SQL> DESC lower_tab;

Object does not exist.

SQL> SELECT * FROM lower_tab;

ERROR at line 1:
ORA-00942: table or view does not exist

SQL> SELECT * FROM "lower_tab";

No rows selected.

SQL>

So, you can see that if you enclose the table (or index, etc.) in quotes
and put it in lower-case, then the SQL will work. This may or may not help
in your case. If not, then you will have to work with Oracle support
because you have a corrupt database.

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant
----------------------------------------------------------------------------
(From Allen Moore...)

I wanted to help contribute by providing you with some additional information on
our experiences with Tip #324 regarding the ORA-08102 error "index key not found
"...We've had this error crop up in our database multiple times over the last
six months especially when it came to rebuilding indexes.  What we had found
after painless hours of downtime and lots of time with Oracle support was that
this error was caused by a corrupted block on the index.  VALIDATE INDEX found
the block for us right away.  With that in mind we dropped and recreated the
index and everything returned to normal as far as Oracle was concerned. We also
had Unix admin run a test on that disk to be sure all was well structurally and
it turned out we had some bad sectors on the disk itself.  Once replaced we
haven't had the error since.

Again thanks for your site and I hope I in some small way contributed.

Allen Moore, ihov@sleeplessmoon.com

Back to Ari Kaplan's Home Page

Is Export/Import the best way to recreate tables?

On Fri, 28 May 1999, AmyTse wrote:

> Hi all:
> 
> Is the following procedure for recreating table safe?
> 
> 1. export table.
> 2. import table use SHOW=Y to have a create table script.
> 3. Drop existing table.
> 4. Run the create table script from step 2.
> 5. import data back to the newly created table.
> 
> Will I loose any constraints of the table by using this procedure?
> The purpose of recreating table is to change the tables to other
> tablespace. Please advise.
> 
> Thanks,
> 
> 
> Amy 
> 
> Regards,
> 
> 
> 
> Amy 
> 
Amy,

Your method is not always safe. For example, any procedures, packages, or
triggers, FK constraints, and so on that point to the table will become
invalid.

When you do the SHOW=Y option in the import, you will also see SQL for
creating GRANTs, TRIGGERs, CONSTRAINTs, and so on. You will need to run
these SQL statements as well.

Regardless, after using your method, you will need to revalidate any
objects that become invalid and recreate the foreign key constraints (if
any) that had been pointing to the table.

Sounds like fun, doesn't it?

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 295+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

rollback segments are not shrinking
> 
> 
> 	I encountered the problem of rollback segments being too small a while ago
> - and increasing them fixed it for a period of time.  I just had to add
> another 300M.  But what I am noticing, is that the used space in the
> rollback segments never decreases from the size they were when I added the
> new tablespace.
> 
> TS                           FILE_ID      BYTES       USED       FREE  
> PCT_USED
> ------------------------- ---------- ---------- ---------- ----------
> ----------
> RBS                                2  104857600   68161536   36696064
> 65.0039063
> RBS                               10   52428800   51122176    1306624
> 97.5078125
> RBS                               14  157286400   46862336  110424064
> 29.7942708
> RBS                               15  314572800       4096  314568704
> .001302083
> 
> 
> 	Even when  reboot the servers and restart oracle, they do not decrease in
> percent used. (I noticed this last time when the third one was added - the
> other two never dropped below 22% and 16%).
> 
> 	Is there anything I can run that will clean them up?
> 
> 				-Christine
Your condition is common. Rollback segments to not shrink when a
transaction is complete. You need to set your OPTIMAL size of each
rollback segment. Even then, it does not always shrink. You have to
attempt to extend the rollback segment past the current extent for it
to shrink to its OPTIMAL size. Otherwise, you can issue "ALTER ROLLBACK
SEGMENT xxx SHRINK;" This will cause the rollback segment to shrink to
the optimal size...do this for each rollback segment, and your USED space
will decrease.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
> 
> _______________________________________
> Christine Hales, System Analyst
> AEA Management
> Phone (519) 254-4410 Ext. 146  
> Fax (519) 258-6884
> 
> ----------
> > From: akaplan@yang.interaccess.com
> > To: Christine Hales 
> > Subject: Re: Rollback Segments Too Small
> > Date: Wednesday, January 28, 1998 12:35 PM
> > 
> > Christine -
> > 
> > You do not need to shut down the database to do this. Although I do not
> > know your database situation, I would recommend increasing the rollback
> tablespace size. You have 10 segments and 150M of space. This leaves just
> 15M for
> > each rollback segment on average.
> > 
> > You can tell by sure by doing:
> > 
> > SELECT SUM(BYTES)/1024/1024 Megs
> > FROM DBA_FREE_SPACE
> > WHERE TABLESPACE_NAME = 'RBS';
> > 
> > Replace RBS with the name of your rollback tablespace. You will see how 
> > much or little space you have left.
> > 
> > I'd recommend doubling your space to 300M. Try re-running the program
> > that caused an error. If you still get one, keep increasing the size of
> the rollback segments until the error stops.
> > 
> > -Ari
> > > 
> > > 
> > > 	In recreating the rollback segments - do I shutdown the database to do
> > > this - or can I do it while the database is up?  And do I have to
> increase
> > > the tablespaces as well?
> > > 
> > > 			-Christine
> > > _______________________________________
> > > Christine Hales, System Analyst
> > > AEA Management
> > > Phone (519) 254-4410 Ext. 146  
> > > Fax (519) 258-6884
> > > 
> > > ----------
> > > > From: akaplan@interaccess.com
> > > > To: chales@schukra.com
> > > > Subject: Re: Rollback Segments Too Small
> > > > Date: Monday, January 12, 1998 12:25 PM
> > > > 
> > > > > 
> > > > > I got the following error:
> > > > > 
> > > > >  ORA-01555: snapshot too old (rollback segment too small) : errno
> > > -1555:
> > > > > 
> > > > > 	I have 10 rollback segments, each identical in design 
> > > > >         (initail 128K, next 128K, optimal 256K)
> > > > > 	And I have 2 rbs tablespaces, the first 50M, the next 100M.
> > > > > 	What do I need to increase?
> > > > > 		
> > > > > 		Thanks in advance,
> > > > > 			Christine
> > > > Christine,
> > > > 
> > > > You need to increase either the INITIAL, NEXT, or both. What is
> happening
> > > is
> > > > one process, attached to one rollback segment, took too much data for
> > > > one rollback segment to keep the process's view of the data in a
> > > consistent mode.
> > > > 
> > > > So, drop all rollback segments and recreate. For starters, try:
> > > > 
> > > > INITIAL 1M
> > > > NEXT 1M
> > > > OPTIMAL 2M
> > > > MINEXTENTS 2
> > > > 
> > > > 
> > > > Best of luck,
> > > > 
> > > > 
> > > > -Ari Kaplan
> > > > Independent Oracle DBA Consultant
> > > > 
> > > > <-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
> > > > <-> For 150+ Oracle tips, visit my Web Page:                      <->
> > > > <->                                                               <->
> > > > <->             www.arikaplan.com                                 <->
> > > > <->                                                               <->
> > > > <->             email: akaplan@interaccess.com                    <->
> > > > <-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
> > > 
> > 
> 

Back to Ari Kaplan's Home Page

cron jobs: It can't find sqlplus
> 
> Hi Ari,
> 
> I'm trying to put in place batch jobs in the crontab, but it seems that I
> have environment problems, because I'm not able to open sqlplus from the
> crontab. I'm working in an AIX environment on Sun Solaris. I tried adding
> "export" environment variables in the batch job with no success. The output
> is the following:
> 
> /oracle/products/733/bin/sqlplus not found.
> 
> though I have, in the ksh script ran from the crontab, an explicit
> environment variables assignement: 
> 
> export ORACLE_HOME
> ORACLE_HOME=/oracle/products/733
> export PATH
> PATH=$PATH:$ORACLE_HOME:
> 
> then the call to sqlplus:
>  
> $ORACLE_HOME/bin/sqlplus scott/tiger << ...etc
> 
> in the same ksh script.
> 
> Is there a way to have my environment set in the crontab so that all my
> references to SQL will be OK?
> 
> Thank you,
> 
> Karina.
> 
> 
You are certainly on the correct path. Crontabs need environment variables
set in Unix operating systems. However, they do not always reflect the default
shell for your user account. For example, cron may be running in ksh but your
default may be csh.

So, you should ensure that the cronjob runs in the ksh by adding this as the
first line in the crontab:

#!/bin/ksh

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How many OPEN CURSORs do I have?
 
> 
> Hi Ari.
> I am getting problem when running report 2.5:
> Numbers of open cursors exceeded!
> I am runnig oracle 7.3.
> Max open_cursors is set to 255.
> Please advice.
> Thank you.
> Eric.
> 
> 
To see how many open cursors you have, type:

select * from v$sysstat where name = 'opened cursors current';

If this is over 200, then you need to change your initSID.ora file. Change the
like max_open_cursors to say 400 or 500. Then shutdown and restart your database.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Converting dBase IV files to Oracle
 
> 
> I have four tables in dBase IV (.dbf) format.  I would like to convert
> those tables into Oracle tables.  Is it possible to do this? If yes how
> do I go about doing this.  I found a book in a book store and it has
> very poor instruction on using SQL*Loader.  I tried to follow those
> instructions and created a contro file.  Then I started loader from dos
> and tried to convert files (control as well as DbaseIV files were in
> drive A:).  However the SQL*Loader failed to open the control file.
> 
> Then I tried the same procedure using databese files in text format.
> But, loader again failed to load the control file.
> 
> vpatel@jps.net
> 
> Do you have any suggestions?  Your help in this matter will be very much
> appreciated.
> 
You need to change the dBase IV files from .dbf format and export them into
an ASCII-delimited file. I am not familiar with the process in dBase IV.
Otherwise, you will have to use a program like Microsoft Access to import
the tables (into Access) and then export them into an ASCII-delimited file.

Once it is in ASCII format, you can then use SQL*Loader to load in the data.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 160+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Which users are using which Rollback Segments?
 
> 
> Ari,
> 
> I enjoyed your session this morning on "A Bag of Tricks and Tips for
> DBAs and Developer."
> 
> As discussed during the question and answer period,  I would like to be
> able to identify the SQL statement (and Oracle user executing the
> statement) responsible for a disk sort when a disk sort is in progress.
> I know there must be a way to extract this information from Oracle's
> data dictionary.  When temporary objects appear in the dba_segments
> view, they are owned by SYS and have a naming convention of
> ., which appears to be 
. data. I've > been unable to trace these temporary objects back to a user or SQL > statement. Can you tell me what is the proper SQL statement to query > the database for this information? > > The database in question is version 7.1.6. > > Thanks, > Bill Reidy > wreidy@csc.com > Bill, Thanks for coming to the speech and being so patient with my slow reply. I was out of the country and just recently got back. Anyway, I do remember your question and went to investigate, as I thought that I remembered the answer. From what I concluded, I could not link the user with the sort, as Oracle assigns SYS as the owner (like you mentioned). What I have been doing, however, is seeing which users are using which rollback segments. I will give you the script for you to try. It only shows transactions that take more than a few seconds to complete, which is the case when the TEMP segments are used. It is this way that I can relate the user to the TEMP segment (if there is only one such rollback segment being used in the database). Otherwise I can only limit it to those users using rollback segments at the moment. Try the following SQL to see which users are using rollback segments: set pagesize 24 select to_char(rownum+3) ||') ' || rpad(r.name,17) || rpad(to_char(p.pid),11) || rpad(p.spid,11) || rpad(nvl(p.username,'NO TRANSACTION'),17) || rpad(p.terminal,8) FROM v$lock l, v$process p, v$rollname r, v$session s WHERE l.sid = s.sid (+) and p.addr = s.paddr and trunc(l.id1(+)/65536)=r.usn and l.type(+) = 'TX' and l.lmode(+) = 6 UNION select '2) ROLLBACK SEGMENT'||' '|| 'ORACLE PID' ||' '|| 'SYSTEM PID' ||' '|| 'TRANSACTION ' ||' '|| 'TERMINAL' from dual UNION select '1) ' from dual UNION select '3) ----------------' ||' '|| '----------' ||' '|| '----------' ||' '|| '----------------' ||' '|| '--------' from dual ORDER BY 1 / Best of luck, and I hope that this helps you,

Back to Ari Kaplan's Home Page

ORA 1653: Unable to Extend Table
  

On Wed, 2 Jun 1999, M. HITHAYATHULLAH wrote:

> Hai Kaplan,
> 
> 	How R U?. Today  I had faced one problem. In Report Writer Ver 1.1 on
> Oracle 7.1, while I trying to copy a report in Report Writer Menu into a
> new report name, I am getting error like this
> 
> " ORA - 01653 UNABLE TO EXTEND TABLE
>   SYSTEM.SRW_TEXT_LONG BY 473 IN TABL, INSERT INTO SRW_TEXT_LONG(APPID,
> TIMEID, TYPE, PANEL, TEXT_OWNER) VALUES (:b rountinue :RWVCOP).
> 
> Please give me solution.
> 
> Thanks & Regards
> 
> M. Hithayathullah.
> 

The problem lies not in Report Writer itself but in the free space for
your TABL tablespace. The "ORA-1653" error indicates that your table,
SRW_TEXT_LONG, cannot increase in size.

To fix this, add space to your tablespace. Since you are on Oracle 7.1,
you can only do this by adding a datafile. First, see what datafiles
exist:

SQL> SELECT * FROM DBA_DATA_FILES WHERE TABLESPACE_NAME = 'TABL';

(various datafiles are shown)

SQL> ALTER TABLESPACE TABL ADD DATAFILE '/path/tabl05.dbf' size 250M;

Tablespace altered.

SQL>

Note that in the above command, change "path" to where the file goes and
"tabl05.dbf" to the name of the datafile that you want to add.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Four questions (ROWID, Savepoints, Recovery Steps, alter sequence #)
  


Arul,

Thanks for the "Super" nickname, and I am glad that your friend
recommended me. I will answer your questions below:

On 29 May 1999, arul kumar wrote:
> 
> Hello Mr.Super(I think it's right name),
> 
> This is Arul(rather a ORACLE lover).  I came to know about Ur email id thru
> one of my friend. I am very happy to know that Ur responding to the queries
> send to  U. I have some quereies  too.
> 
> 1) What is the actual use of pseudo column Rownum? Can I use it to access    a
> specific row in a table?

To access a specific row in a table, use ROWID. The ROWID includes the
datafile, block, and row within the block information. So, if you export
and import the data, the ROWIDs will change.

ROWNUM is used only when selecting data. The FIRST record returned gets
ROWNUM of 1, the SECOND gets ROWNUM of 2, etc. So, the records get ROWNUMs
depending on the order that they are selected. For this reason, you cannot
specify a specific record with ROWNUM. ROWNUM is usually used to limit the
number of records returned:

SELECT * FROM EMP WHERE ROWNUM < 20;

> 
> 2) Where actually Savepoints are stored to keep track of the transaction   
> done by a user?

They are physically stored in the rollback segments and redo logs. So,
when and if there is a recovery or commit or rollback, Oracle will look in
either the redo logs or the rollback segments. It will roll forward or
rollback depending on the savepoints.

> 
> 3) Can I get Recovery steps for Point in time Recovery ? 

This is a big questions, because there are many types of recoveries. For
example: missing data datafiles, missing SYSTEM datafiles, missing
rollback segments, missing redo logs, missing controlfiles, etc.

Basically, you recover the database from tape (or select tablespaces
from tape) along with all archived redo logs. Then start up the database
in MOUNT mode and apply redo logs (and sometimes archived redo logs). You
can specify ALL or to recover until a specific redo log or a specific date
and time.

For the full syntax and samples look at the Oracle documentation or
"Oracle Backup and Recovery" by Oracle Press.

> 
> 4) How to alter the sequence no. once generated?

Follow the example below:

SQL> create sequence x;

Sequence created.

SQL> select x.nextval from dual;

   NEXTVAL
----------
         1

1 row selected.

SQL> /

   NEXTVAL
----------
         2

1 row selected.

SQL> alter sequence x increment by 1000;

Sequence altered.

SQL> select x.nextval from dual;

   NEXTVAL
----------
      1002

1 row selected.

SQL> /

   NEXTVAL
----------
      2002

1 row selected.

SQL>

> 
> 5) Can U just give me the websites where I can know more about ORACLE.

www.lazydba.com, www.oriolecorp.com, www.orafans.com, www.orafaq.org,
www.ioug.org, www.oracle.com

Don't forget to come back to my page or we'll miss you!

> 
> Thanks a lot spending time to see my mail and answering it.(in advance!!)
> 
> Regards,
> Arul.
> 

Back to Ari Kaplan's Home Page

Will deleting dump files affect the database?
  

On Wed, 2 Jun 1999, GoplalaKrishnan K wrote:

> Hi DBAs
> 
> Can any one tell me about the contents of cdump directory
> In my server it consumes lot of space.
> the conternts are not readable format.
> will deleting this files affect the database.
> 
> Please Help
> 

Goplala,

The cdump is one of the background file destinations for your Oracle
instance. Generally, cdump stores the core dumps created by other Oracle
errors. You will notice that Oracle creates a directory within cdump and
puts the core file in that subdirectory.

There will be a corresponding trace file in either bdump or udump (check
the number within the name of the file and the timestamp for correlation).
Usually, although not always, cdumps are caused by internal Oracle errors.
You should be sending these to Oracle support.

In any case, it does not hurt the database to delete these files. You can
examine these files in Unix with commands such as "strings -a" although
only Oracle support would know how to interpret it all.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SQL help
  
On Wed, 2 Jun 1999, Banerjee, Poolak wrote:
> Hi Ari,
> 
> I need a quick help. 
> 
> I have a table lot-header ('desc'ribed below). I have to make a query which
> will bring all the parentlotid (unique) and some other fields where the
> lotstarttime is NULL.
> 
> For the data set shown below, I expect the query will bring (2 records) only
> P1 and P2 as parentlots. It will ignore P3 as atleast one lotid (L18 here)
> for the parentlot P3 has non-null lotstarttime.
> 
> I tried the following one but gettingvery erratic values.
> 
> 
>   1  select unique(parentlotid), parentlotqty, numberofcarrier
>   2  from lot_header
>   3  where
>   4  lotstarttime = ALL (select lotstarttime from lot_header where
> lotstarttime is NOT NULL)
>   5* order by parentlotid desc
> SQL> /
> 
> PARENTLOTID PARENTLOTQ NUMBEROFCARRIER
> ----------- ---------- ---------------
> P3                                   3
> 
> This works fine...
> 
> But if I do
> 
> 1  select unique(parentlotid), parentlotqty, numberofcarrier
>   2  from lot_header
>   3  where
>   4  lotstarttime = ALL (select lotstarttime from lot_header where
> lotstarttime is NULL)
>   5* order by parentlotid desc
>   6  /
> 
> no rows selected
> 
> Here I expected atleast P1 and P2 will appear. If L18 also has null
> lotstarttime, then I expect P1, P2 and P3 to appear.
> 
> Please help me in having the correct sql query. This is very urgent. I am
> sure no point in mentioning that you will test the script before letting me
> know, but please understand the urgency of the situation.
> 
> Thanks in advance 
> 
> Cheers,
> 
> Poolak
> 
> Data contents.....
> 
> SQL> select lotid, parentlotid,lotstarttime from lot_header;
> 
> LOTID       PARENTLOTID LOTSTARTT
> ----------- ----------- ---------
> L1          P1
> L2          P1
> L3          P1
> L4          P1
> L5          P1
> L6          P1
> L7          P1
> L8          P1
> L9          P2
> L10         P2
> L11         P2
> L12         P2
> L13         P2
> L14         P3
> L15         P3
> L16         P3
> L17         P3
> L18         P3          02-JUN-99
> 
> 
> 
> 
> SQL> desc lot_header
>  Name                            Null?    Type
>  ------------------------------- -------- ----
>  LOTID                                    VARCHAR2(11)
>  FTGDFILENAME                             VARCHAR2(32)
>  FTGDLOADCOUNT                            NUMBER(2)
>  SOURCEBAUNUMBER                          VARCHAR2(8)
>  PARENTLOTID                              VARCHAR2(11)
>  LOTPRIORITY                              VARCHAR2(15)
>  BAU_NO_951                               VARCHAR2(8)
>  AUTOLINE                                 VARCHAR2(20)
>  PACKAGE                                  VARCHAR2(24)
>  DEVICE                                   VARCHAR2(11)
>  PARENTLOTQTY                             VARCHAR2(10)
>  LOTQTY                                   VARCHAR2(10)
>  NUMBEROFCARRIER                          NUMBER(2)
>  CELLNAME                                 VARCHAR2(20)
>  QTYINSPECTEDATABOS                       NUMBER(4)
>  TOTALDEFECTQTY                           NUMBER(4)
>  LASTPROCESSSTEP                          VARCHAR2(15)
>  LOTSTARTTIME                             DATE
>  LOTCOMPLETEDFLAG                         VARCHAR2(1)
>  LOTCOMPLETEDTIME                         DATE
>  MULTICHIPINDICATOR                       VARCHAR2(1)
>  LASTWSTXN                                VARCHAR2(4)
>  LOTSTATUSFORWS                           VARCHAR2(4)
>  CREATEDON                                DATE
>  CREATEDBY                                VARCHAR2(8)
>  LASTMODIFIEDON                           DATE
>  LASTMODIFIEDBY                           VARCHAR2(8)
>  CCROLLBACKFLAG                           VARCHAR2(1)
>  PRINTCOUNTER                             NUMBER(2)
> 
> poolak banerjee
> Manufacturing Solutions Practice
> COMPAQ Computers Asia/Pacific PTE LTD
> E-Mail: poolak.banerjee@compaq.com  
> Phone: 65-580-5445
> 
Poolak,

Your first query will work fine, as you noted:

select unique(parentlotid), parentlotqty, numberofcarrier
from lot_header
where lotstarttime = ALL (select lotstarttime from lot_header where
                          lotstarttime is NOT NULL)
order by parentlotid desc
/

PARENTLOTID PARENTLOTQ NUMBEROFCARRIER
----------- ---------- ---------------
P3                                   3

Your second query should be switched to the following:

select unique(parentlotid), parentlotqty, numberofcarrier
from lot_header
where parentlotid not in (select parentlotid
                          from lot_header
                          where lotstarttime is not null)
order by parentlotid desc
/

This will only select PARENTLOTIDs NOT from the inner-select, which is a
list of all PARENTLOTIDs where there are no lotstarttime values. It sounds
confusing (a few double-negatives) but it works.

Basically, the inner select shows all PARENTLOTID values that have at 
least one record with a LOTSTARTTIME value. Then the outer-select returns
all unique records where their PARENTLOTID is NOT in this list of
PARENTLOTIDs.

Hope that this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

1) How to defragment a tablespace 2) What objects are in a tablespace
 
> 
> Hi Ari,
> 
> I have a tablespace fragmentation problem (large free space fragmented into
> small non-contiguous chunks of space) on an tablespace dedicated to indexes
> for all db schemas. While looking at your site, I found among the Oracle
> tips on your site the #67 one about Tablespace fragmentation.
> 
> You answered that "Exporting, dropping, and importing everything will do the
> job." when Nadira Gangadhar talks about "exporting, dropping the tablespace,
> and importing" to defragment tablespaces.
> Does this mean that, in my case, I will have to export the whole database
> before dropping the tablespace, then re-import the whole database, to
> de-fragment one tablespace only?

You could do that, or find out which objects are in a tablespace (see below),
drop only those objects, coalesce the tablespace, and import only those
objects. It's trickier (you have to recompile any packages/procedures/triggers/
views that are dependent on the objects being dropped, if any).

> 
> Another question: what would be the query to find out which objects are into
> a given tablespace?

Try:

SELECT * FROM DBA_SEGMENTS
WHERE TABLESPACE_NAME = 'tablespace_here';

> 
> Thank you very much,
> 
> Karina Chami
> 
Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Finding the size of an index.
  
On Thu, 3 Jun 1999, Leo Sahaya wrote:
> Hi Ari,
>    How to find the size of an index? Please tell me the system table or view
> to find this.
> 
> Thanks
> Leo
> 
Leo,

You can find the size of any object (table or index) with the following
SQL:

SELECT sum(bytes)/1048576 Megs, segment_name
FROM user_extents
WHERE segment_name = '&enter_object_name'
/

This gives the total megabytes allocated for the index/table. Hope that
this helps!

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What users and SQL are locking rows/tables?

On Fri, 4 Jun 1999, Carlos A. Costa wrote:
> We need to know what users and SQL statements are locking rows/tables on a
> database. Any idea about how we can create a script to do this?
> 
> Thanks.
> Carlos
> 
Carlos,

Oracle comes with some great scripts to make extra lock-related views. In
$ORACLE_HOME/rdbms/admin, there are two scripts for you:

1) catblock.sql : creates the following views:
   * DBA_LOCKS : all locks, and if they are blocking other users
   * DBA_LOCK_INTERNAL : all locks and requests for locks
   * DBA_DML_LOCKS : each DML (Data Manipulation) lock and request for
     lock
   * DBA_DDL_LOCKS : each DDL (Data Definition) lock and request for lock
   * DBA_WAITERS : shows the SID of each session waiting for a lock
   * DBA_BLOCKERS : shows the SID for each session holding a lock that
     another session is waiting to free up
2) utllockt.sql : generates a nice tree-structure format of all sessions
     that are holding locks and the users that are waiting for those locks
     to free up. The tree can have several levels.
     For utllockt.sql to work, you need to run catblock.sql first (this is
     NOT documented as far as I could see!)

If you want more information than the above, download my "Life Without
Tools: Monitoring Your Database With The Power Of SQL" PowerPoint presentation.
One of the tips addresses your question.

Hope that this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What is the default maximum sequence value?
On Thu, 3 Jun 1999, Muhammad Siddiqui wrote:
> Hi there,
> 
> I've got a simple question on Oracle sequences.
> 
> What is the limit of the sequences ie what would be the maximum number it 
> would go to?
> 
> Many thanks
> 
> Muhammad
> 

Muhammed,

By default the sequence's maximum number is 1E+27, or

1,000,000,000,000,000,000,000,000,000

This is 1 octillion. I hope that this is sufficiently large for your needs ;)

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Question: How to handle duplicate table names?

Newsgroups: comp.databases.oracle
Subject: Re: Question: How to handle duplicate table names?
References: <31B7624A.23A2@mda.ca>

Todd Bealor  writes:

>Hi,

>I would appreciate hearing from anyone who has any insight into
>handling the use of duplicate table names. In the production 
>version of the applictation this will not be a problem as the
>tables will be accessed via SQL*net thus having different remote
>database extensions.

Oracle does not allow two tables to have the same name and the same
owner. There are ways to get around it  for what you want to do.

You should make SYNONYMS for the owner.table that you want to reference.
Then, when you move the the production server, you do not need to change
your code. The actual base tables would always be the same, but you can 
change the synonym easily to point to whichever owner or table you like.

For more information on synonyms, check the Oracle documentation if you
have it.

Good luck.
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

>The problem is that we are building a prototype using one database.
>While it is possible to place the tables into separate table spaces,
>I have not come across any mechanism for specifying which table space
>to look for a table. The only differentiation mechanism that I can
>find in Oracle is the use of the table owner as a prefix to the table
>name.

>i.e.	GROUP1.STATUS_CODES
>	GROUP2.STATUS_CODES

>With this approach we would have to transform all of the table names
>in the application programs when we port them to the actual production
>server. i.e. GROUP1.STATUS_CODES --> STATUS_CODES@SITE1 etc...

>Any alternative solutions would be greatly appreciated.

>Thanks,

>Todd

>------------------------------------------------------------------
>Wm. Todd Bealor			     LINC Project
>Systems Developer		     E-mail: tbealor@mda.ca
>MacDonald Dettwiler		     Phone:  +1 (613) 723-7667 x28
>240 - 1101 Prince of Wales Dr.	     Fax:    +1 (613) 723-7832
>Ottawa, Ontario, Canada K2C 3W7	     URL:    http://www.mda.ca
>
>------------------------------------------------------------------

Back to Ari Kaplan's Home Page

I can't find my archived redo logs!

On Mon, 7 Jun 1999, Shiva Maran wrote:

> Hi all,
> 
> I am working on Oracle 7.3.3.0. 
> My setting in the init.ORA is
> log_archive_start = true
> log_archive_dest = e:\tb1_arch
> log_archive_format = arch%s.arc
> In the table v_$log_history I find that the archive files have been
> created. 
> One line from this table :
>         1       305 06/03/99 13:40:08           8419         8421
> e:\tb1_arch\arch305.arc
> But when I see in the specified directory I do not find this file. 
> Where has the file gone??!!
> Oracle is installed on Wintows NT 4.0
> 
> Regards,
> Shiva
> 

Shiva,

You may not be in Archivelog Mode. Even though your
"log_archive_start=TRUE", the database has to be set (just once after its
creation) to be in ARCHIVE mode.

To find out your status, issue:

SELECT LOG_MODE FROM V$DATABASE;

The result will either be "ARCHIVELOG" or "NOARCHIVELOG".
If you are in "NOARCHIVELOG" and wish to change this, do the following:

1) Shut down your database (if possible back up your database now).
2) Start up the database in MOUNT mode (do not open it)
3) Issue "ALTER DATABASE ARCHIVELOG"
4) Open the database: "ALTER DATABASE OPEN"

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Resources for learning more about Oracle

Priya,

> 1. What should I know as a Oracle programmer apart from the
> subject(Oracle)...
>

This really depends on where you want to go with your career. If it's the
Internet, then learn Java, Perl, and CGI. If you want to do
Object-Oriented design then try Visual Basic or C++.
Regardless, make sure that you know SQL, how to do "Explain Plans", and
PL/SQL.

> 2.Is there any book/Website, where I can gain some knowledge about the
> computer world... ( For ex, My friend was talking about two tier and
three
> tier... I was sitting like, know nothing...So..To get some background
> knowledge about Oralce also).

There are hundreds of great books. Go to any bookstore and there are
entire sections geared towards the computer world. Also, keep up on the
news by getting magazines such as InfoWorld, Byte, and others so that you
will learn the "buzzwords". For beginners, the "For Dummies" series are
usually of high quality.

I would also suggest taking some classes, both in Oracle and in some
programming language. It sounds like you are a good self-starter, so go
get the books, load trial software (you can even get a free Oracle version
from www.oracle.com), keep coming back to my web page, or check out other
web pages. Good ones are www.lazydba.com, www.oracleassist.com,
www.oriolecorp.com, www.revealnet.com, www.orafaq.org, and www.orafans.com

Best of luck to you!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Archival and Restoration of inactive data
On Wed, 9 Jun 1999 gerowati@sg.ibm.com wrote:
> Dear Sir,
> 
> Hi, I am very new to Oracle and is very in need for guidences.

Welcome to the fun world of Oracle. I hope you have a successful career.

> 
> I need to archive my inactive data in the database to tape in order to
> maintenance the performance.  I intend to use the Export/Import utilities
> to perform this function.  Is it possible?  Here are my few questions + any
> help will be appreciatable:
> 
> 1) It seems that the export function can only export the whole table.  What
> can I do if I only want to export selected data?

You are correct - Oracle can only export the whole table. The other option
is to generate a tab-delimited file (see my tips at
www.arikaplan.com/oracle.html). You can specify a
WHERE clause in your SQL. The only difference is that you use SQL*Loader
to load the data instead of the import utility. It does not save index
definitions, grants, etc.

Another option is to physically create another table with the WHERE
clause:

CREATE TABLE emp_archive AS SELECT * FROM emp WHERE create_date <
to_date('12-JAN-1998');

Then you can export the EMP_ARCHIVE table and drop it from the database.

> 
> 2) Do I need to write SQL program to create a archive database and copy the
> selected data to it before I do the export?  If yes, what is the best way
> to do this?
> 

You can export straight from your database to the export file. There is no
need to archive the data first (unless you want to try the method above).

> 3) If I want to restore the data, can I directly import the data from the
> tape.  Will there any constraint?
> 

I have not tried this and cannot answer it.

> Thanks in advance.
> 
> Regards
> Minzinda
> 
Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Dropping a database
On Thu, 10 Jun 1999 dcelznick@euclid-hitachi.com wrote:
> Ari,
> 
> Thanks for the info -
> 
> I have exported the entire DB.  I am putting together my Create DB commands
> before I drop the DB.
> How do I drop the database??  I have searched the manuals i.e Alter
> database and such?  No Luck so far?
> What is a good procedure to do this?
> 
> Thanks,
> 
> Dave Celznick

Dropping databases are fun. Here is how to do it:

1) First, find all datafiles, controlfiles, and redo logs:

SELECT * FROM DBA_DATA_FILES;
SELECT * FROM V$CONTROLFILE;
SELECT * FROM V$LOGFILE;

2) Shutdown the database (abort):

SVRMGRL> SHUTDOWN ABORT;

3) Remove all of the files from the server ("rm" in Unix, "del" in NT)

There you have it!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Connectivity between Client and Server..

On Fri, 11 Jun 1999, Dhaval Rasania wrote:
> 
> Hi.. 
> Thanks in advance...
> 
> We have installed Oracle 8 on NT 4.0 Server on one machine and
> Developer 2000 on anoother machine running Windows 95. 
> 
> -What to do to get the connectivity between Oracle Database and
> Forms4.5 or reports 2.5 running on Windows 95. ?

You need to create a listener on the database server. There needs to be
both a listener.ora and tnsnames.ora file in $ORACLE_HOME/network/admin.
There are sample files there already for you to work on.

Start the listener with "lsnrctl start", stop it with "lsnrctl stop" and
see the status with "lsnrctl status".

On the client, you need SQL*Net. You can install this with the "Oracle
Client" software. There is a "SQL*Net Easy Install" program that guides
you through the installation. You can instead make your own tnsnames.ora
file and install the SQL*Net program. You need the IP address of the
database server and the database instance name and the port to check (1521
by default).

> 
> - Are there any network settings required?

See the above answer.

> 
> - Is it required to setup or configure server so that    database
> services can be accessible on network.

See the above answer on listener.ora and tnsnames.ora and starting the
listener.

> 
> - Is it required to create a connect string?

There is no need if your ORACLE_SID environment variable is set. If not,
then yes you need a connect string.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Import/Export facility
Newsgroups: comp.databases.oracle
Subject: Re: Import/Export facility
References: <31BEF67F.41C67EA6@pia.bt.co.uk>

Paul Taylor  writes:

>Hi there

>I can successfully export and import any size of table, but can only
>import a very small table.  I have tried increasing the 'pctincrease'
>from 0 to 50, which the manual recommends, but I realise it is not a
>good idea to do this anyway. Currently the max extents is set to 99.


>The error messages I receive are as shown below.

>IMP-00003: ORACLE error 1556 encountered
>ORA-01556: maximum number of 99 extents exceeded
>IMP-00021: operating system error - error code (dec 2, hex 0x2)
>IMP-00028: partial import of previous table rollbacked: 1834 rows
>rollbacked
>Import terminated successfully with warnings.
>This is all run under Oracle 6.
>Any ideas?
>Thanks in advance for any help.
>Paul

Paul,

It is not sufficient in your case to increase the PCT_INCREASE parameter. 
Since you have exceeded the 99 extents, it is clear that your extent sizes
are not large enough.

Set the INITIAL and/or NEXT extent to a larger value (at least 99 times
what they are now to even have a chance of fitting in only one extent).

The default value is 5 data blocks (not much at all - around 20k 
depending on your db_block_size) if not manually defined otherwise. So, if
you took the default value, you may have made your extents too small.

You may have also specified K when you intended to specify M
(kilobytes/megabytes) - so check your storage definitions.

Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What software defrags a database while the database is up?
 
> 
> Ari Kaplan:
> 
> We in our company have the Oracle 7 Server Release 7.0.16.4.0 for SCO =
> Unix Release 3.2 v 5.0.2and when it are filled a board we have to carry =
> out a export with compresion and matter again. The question is: Does a =
> sofware exist that do you can defragmentation my database without having =
> to make the export and the import and so don't have to take out to my =
> users of the operation?
> 
> Thank you
> Jaime Heredia
> CBI Seguros, S.A.
> e-mail: cbisgcnt@inetcorp.net.mx
> 
Yes. Probably the best is TSReorg by Platinum. You can do it immediately or
schedule it to run at a later time. Also, there are options to check the
potential failure/success of the operation. I highly recommend it.

Take care,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Slow CREATE and DROP TABLE and SYSTEM tablespace fragmentation
Fabio,

I will answer your questions below...

On Tue, 8 Jun 1999 fparacchini@alteanet.it wrote:
> Ari,
>      pardon me if I contact you directly, but it seems that after days of
> browsing you're the only one with the answer.

No problem. I hope that I can help.

> 
> The problem is this: I have an Oracle8 DB for BaaN IV (an ERP system) on
> IBM AIX 4.2 that shows a very bad response time with table creation and
> deletion. I tried to optimize the system, that now performs reasonably fast
> with operations on tables (insert, update, delete), and for what I found
> the symptom is an excessive reading of the disk where the SYSTEM tablespace
> resides. Normally the disks are not busy and there are a few Mb free at the
> OS level.
> I did an ANALYZE TABLE COMPUTE STATISTICS on every table of SYS, but the
> SYSTEM disk still works a lot.
> I found that the DB setup had a %increase of the SYSTEM tablespace of 50,
> and that seems bad for tablespace fragmentation, based on your
> explanations. I presume that now SYSTEM is badly fragmented, and needs a
> defragmentation.
> 
> The questions are:
> 1 - Are my assumption correct ? SYSTEM fragmentation really impairs the
> performance of CREATE and DROP ?

I have not seen this behavior before (slow DROP/CREATEs). With Oracle8,
you can have dozens or even hundreds of extents before there is a
performance problem. Oracle does say that you should NOT do statistics on
any SYS or SYSTEM object though.

The most likely cause is that you have a rollback segment or table/index
incorrectly stored in the SYSTEM tablespace.

One thing I do know is that if you drop and recreate a package or stored
procedure, some of the data dictionary tables grow and things slow down.
The only way to get around this is to drop and recreate the database (see
next step).

> 2 - How can I defragment SYSTEM, since it is not possible to export, delete
> and import like the other tablespaces ?

The only way is to export the entire database, drop the entire database
(shut it down and remove all files), recreate the database, and import the
database. If you do this be sure to do a full cold backup first!

 > 3 - Are there any other issues that I can check for this
behaviour ? > 

Check to see if any objects (rollbacks, tables, etc.) are stored
improperly in SYSTEM:

SELECT * FROM DBA_OBJECTS WHERE TABLESPACE_NAME = 'SYSTEM'
       AND OWNER NOT IN ('SYS','SYSTEM');
SELECT * FROM DBA_ROLLBACK_SEGS WHERE TABLESPACE_NAME = 'SYSTEM';

Look at the wait statistics, the hit ratios, see if there is memory
swapping/paging on the system.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

> Thank you in advance for your patience, I look forward for your helpful
> answer.
> Fabio Paracchini
> FParacchini@alteanet.it

Back to Ari Kaplan's Home Page

ORA-7331 and the SGA; is the db stable?
> 
> 1. How can determine the parameters of the file INIT.ORA, so as not to to
> have problems with the SGA?  , I had'the mistake ora-7331.  I have'a Sun
> Solaris 3000 Enterprise and Oracle 7.3.3.0.0.

Check your INSTALLATION GUIDE that came with your Oracle software. There are
some UNIX kernel parameters that determine how large the SGA can be. You
want to make it large enough for your application, but not too large that it
won't fit in memory or cause Oracle (and other programs) to use swap space.
> 
> 2. How it is if the were Database is stable, or, that parameters have to
> consider for this?

I'm not sure I understand. To see if the database is stable, check your
alert_SID.log file for any errors. Also check your core dump directory and
user dump directory for additional errors.

> 
> 
> 3. Which is the difference between a shutdown normal and a shutdown
> immediate?

Shutdown normal waits for users to finish everything and log out before shutting
         down. It does not allow new people to connect.
Shutdown immediate will automatically rollback all current transactions and log
         people out immediately after.
Shutdown abort instantly kills the database and may require some recovery upon
         startup.
> 
> P.D.
> Forgive my english, I am new in imail.
> 
> 
>           Regards
> 
> 

Back to Ari Kaplan's Home Page

PCTUSED - How can I display the value of table?
Subject: Re: PCTUSED - How can I display the value of a table?
Newsgroups: comp.databases.oracle.misc
References: <334a49bd.59685883@news.superlink.net>
Reply-To: akaplan@interaccess.com

Thomas Kremer (Thomas.Kremer@orechem.NOSPAM.com) wrote:
: Hello,
: 
: just a question regarding displaying some details about the table. How
: can I display the actuall values of a table XYZ? I want to see
: PCTUSED, PCTFREE.
: 
: Thanks a lot
: 
: The text of my message is reflecting my private opinion!
: To reply please get rid of the NOSPAM in my e-mai address!

Thomas,

You can do the following select:

SELECT owner, table_name, pct_used, pct_free
FROM all_tables
WHERE table_name = 'XYZ';

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Performance - empty blocks, 7.1 Unix
Newsgroups: comp.databases.oracle
Subject: Re: Performens - empty blocks, 7.1 Unix
References: <4q4q0p$1ofi@news-s01.ny.us.ibm.net>

petlars@ibm.net   (Peter H. Larsen) writes:
>I've got a "small" problem with a 7.1.5 RDBMS version. It seems to have problems
>reusing totally empty blocks after a rollback or delete. It often occurs after 
>deleting/rollback more than 35000 records.

>The symptom is: the rollback/delete completes, and everything seems okay, but 
>subsequent inserts into the table, is about 10-20 times slower than normal (even
>without any load, processing ONE record in ONE insert takes more than 1 second).
>This does not happen when the table is FRESH, or if I truncate the table after a
>rollback, or instead of deleting a lot of rows. All inserts are done from PL/SQL -
>either directly in a PL/SQL block or via a package.
>SELECTS also takes forever (Oracle somehow scans all empty blocks??).

>Does anyone know of this problem?  Is it a 7.1 bug, fixed in 7.2 or is it
>possible to be a platform specific problem?  It seems to me, to be somekind of
>"freepointer" problem,
>when PCTUSED gets below default settings ????

>===============
>Peter H. Larsen             Email: Petlars@ibm.net
>Complete Data Service       Fidonet: 2:235/134.0
>Happy Computing

(Article included after comments)

Peter,

I have had the same symptoms myself (both Oracle 7.0.16 and 7.1.3). You are
correct in that the internal pointers indicate a table at its largest
state in its history. So, if you load and delete records, the internal
pointer will indicate the largest size of the table.
Look at the number of extents on the table. Whenever a new extent is 
created, it is never de-allocated, unless you TRUNCATE or EXPORT/IMPORT 
the table.

In your INSERT statement, if you have a constraint that needs to check the table
for integrity reasons, it might be scanning the empty blocks, explaining the
longer times you have been getting.

Oracle support confirmed this to me a while ago.

Best of luck!
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

-----------------------------------------------------------------------------

Back to Ari Kaplan's Home Page

Backup of Oracle databases
Newsgroups: comp.databases.oracle
Subject: Re: Backup of Oracle databases
References: <4q5t84$p60@mozart.wg.icl.co.uk>

simon@openplus.co.uk (Simon Fawkes) writes:

>I need some information about backing up Oracle databases.  I want to
>perform a file level backup of an oracle database whilst the database
>is running.  Whilst this backup is being performed there will be no
>updates.  Is there anyway of locking the database so no updates can be
>performed but reads are still allowed.  If there is is this a safe way
>of performing the backup.

>TIA

>Simon Fawkes

Simon,

The safest way to allow the database to be available for reads during a 
backup is to perform a "hot backup" of the database. Not only can the 
users read data, they can update, insert, and basically do everything 
they normally can do. During that period, all database files can be 
backed up to tape.

A discussion of hot backups is beyond the scope of a posting - several 
books contain descriptions on how to do this. My favorite is "ORACLE Backup 
and Recovery Handbook" by Oracle Press.

Another option you might want to think about is exporting the database 
while it is up. Simply use the "consistent=y" option. Remember, however,
that exports cannot recover to a point-in-time after the export, while
image backups can recover to the point of a crash.

Hope this helps!
-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

starting a job at specified intervals
Newsgroups: comp.databases.oracle
Subject: Re: starting a job at specified intervals
References: <31C8BFAE.6FA3@luc.ac.be>

Jan Timmermans  writes:

>Hi,

>we have a simple database in ORACLE and each record contains a date of
>insertion. Now we want to automize the process of removing records after
>a certain time following there insertion. Is there a way to tell oracle
>to monitor the database and remove records that are too old.
>If you have any suggestions please mail me.
>Thanks

Jan,

The way to do this depends on the operating system and the version of
Oracle. I can tell you how we do this at our site, which runs Oracle 
7.0.16 on a Unix platform.

We schedule a cron job (a Unix concept that runs a script at given times)
that deletes records from journal tables every day. To avoid using a
password in the script, we use sqldba and "connect internal". For this to
work, the cron job must be run by oracle (or a user in the "dba"  unix
group). The commands to run are redirected from standard input. An
example follows:

sqldba << EOF
connect internal;
delete from POGO_STICKS_BOUGHT_JRN
       where INSERT_DT < sysdate - 5;
EOF


Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do you convert Microsoft Access to Oracle?
 
> 
> 1) Have you ever converted an Access database to an Oracle database?
> 2) Is it fairly straight forward?
> 3) What were some of the most problematic pitfalls?
> 
> Hope all is well - when you are home and have some time, let Angela and
> I know and let's make lunch plans!
> Take care,
> Mary
> 
> 
I have converted Access databases to Oracle before. If you are just concerned
about the tables, you can export the tables (one at a time) to a flat file,
create the table in Oracle, and use SQL*Loader to load in the data.

You can get a description of each Access table by going into "Design" mode
for each table.

If you need more than just tables, this is where things get tricky with
Access. Similar to triggers and stored procedures, Access has "Macros". To
convert these, you pretty much have to understand Access macros and convert
them over painstakingly one at a time into Oracle triggers/procedures.

Also, Access has Forms (screens for data entry/data viewing). These you will
either have to convert to Oracle Developer 2000, or if you want you can
keep them in Access and create an "ODBC Link" within Access to the Oracle
database. If you don't want Access at all in the picture you can also convert
the forms to Visual Basic, Powerbuilder, or a host of other products.

The last conversion part is the Access queries. Luckily, they are pretty much
compatible with Oracle. You need to go to the Access Query tab, select a query
to convert to Oracle, go to design mode, and then go to SQL mode. You can
cut-and-paste the SQL to a text editor and use it for Oracle. There may be
some differences in formatting (such as variable substitution), but for the
most part is straightforward.

Hope that helps!

-Ari

Back to Ari Kaplan's Home Page

How do I reclaim index space?

From: akaplan@interaccess.com (Ari Kaplan)
Newsgroups: comp.databases.oracle
Subject: Re: How do I reclaim index space?
Date: 19 Jun 1996 16:56:42 -0500
Organization: InterAccess, Chicago's best Internet Provider (708)-498-3189

dmoyer@gpu.com writes:

>Our production system is now at the point where we are deleting data
>off of it and are hitting index space limits.  I know lost index space due
>to deletes is not recovered.  Does anyone have a script or an idea how
>to drop and re-create indexes so that the space is reclaimed?  Any ideas
>will be tossed around and probably tried.  Thanks ...

>D. Scott Moyer, Jr.                        dmoyer@gpu.com (preferred for work)
>GPU Service Corporation                dsmoyer@enter.net (preferred for home)
>Reading, PA

Mr. Moyer,

Do just that - drop and recreate the index. Oracle will automatically
create the index with no spaces from deletion. Be sure to size the index
so that it fits within one extent.

When you say that "lost index space lost due to deletes is not recovered",
the space WILL be re-used, depending on your PCT-USED and PCT-FREE. What
you might be thinking is that once you create an additional extent and
delete records, the index does not "shrink" down an extent, and the space
is not "recovered" to be used by other objects. This is true. To fix
this, drop and re-create the index as well.

Best of luck to you,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Generators for Primary Keys
Subject: Re: Generators for Primary Keys
Newsgroups: comp.databases.oracle.misc
References: <33AA8194.2F78@kwsoft.de>
Reply-To: akaplan@interaccess.com
Distribution: 

Uwe Grauer (grauer@kwsoft.de) wrote:
: Does Oracle support Generators (gen_id) to get unique
: Integers for Primary Keys?
: If not, how do People get unique Integers for Primary Keys?
: TIA,
: 	Uwe

Uwe,

Use a SEQUENCE to generate unique numbers for your primary keys. Oracle
handles sequences very well in regards to data consistency... when
transactions are rolled back, the sequence does not "roll back" to an
earlier value.

To fully explain sequences is beyond the scope of a simple post, but I
will show the basic commands below:

CREATE A SEQUENCE:
create sequence UWE_SEQUENCE start with 1 maxvalue 999999 increment by 1;

FIND THE CURRENT VALUE (without incrementing):
select UWE_SEQUENCE.CURRVAL from dual;

FIND THE NEXT VALUE (and increment):
select UWE_SEQUENCE.NEXTVAL from dual;

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Migrating from Access to Oracle
On Mon, 21 Jun 1999, Ama Sarpong wrote:
> Hello Ari
> 
> How can I move data from access to oracle.  Have no clue.  I read
> the information in your feedback but it didn't help.  Can you give me
> from scratch what I am to do and how.
> 
> Thanks
> 
> Oracle 'babe'
> 
To move data from Access to Oracle, you can do one of two things:

1) Make a link to an existing Oracle table from within Access. Go to
"File", "Get External Data", "Link Tables". Then use an ODBC driver
(Oracle has a 32-bit or you can use InterSolv's) to link to your database.
If you have not set up an ODBC driver before, you do this in "Control
Panel" and then click on the "ODBC" icon. Now that the Oracle table is
linked, you can do all Access functions on it (Append, SELECT, Reports,
Forms, etc.)

2) Export from Access to an ASCII delimited file. At this point, use
Oracle's SQL*Loader to load the data into Oracle.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 300+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Is it ok to trim the listener.log?
 
> > My listener.log is enormous!
> > Would it be safe to trim it with both the database and listener up or do
> I
> > need to bring the
> > listener down?
> > My plan would be to do the following or something like it:
> >
> > lsnrctl stop
> > tail -100 listener.log > new_listener.log
> > mv new_listener.log  listener.log
> > lsnrctl start
> >
> >
> > Thanks in advance
> > Tom Teigen
> >
> >
-------- Reply ------------
Tom,

It's fine to trim your listener.log file, while the listener and/or database
is up. You can/should also trim your alertSID.log, and sqlnet.log.

Also, keep deleting old files in ../bdump, ../cdump, ../udump directories,
and any audit files that may be generated (oracle sometimes automatically
creates them for all CONNECT INTERNAL commands, depending on the operating
system).

Happy trimming!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Checking available free space
 

Chris Mahoney (mahoneyc@mh.adi-ltd.com.au) wrote:
: How can you check the amount of space available in a database without
: using the Oracle GUI?
: 
: Thanks in advance
: Chris
Try:

SELECT * FROM DBA_FREE_SPACE
ORDER BY TABLESPACE_NAME, BYTES;

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-01000 when altering table
 

D Morrow (morrowd@ci.portsmouth.va.us) wrote:
: Has anyone encountered the ORA-01000: maximum number of cursors exceeded
: error when trying to add a column to a table using the ALTER TABLE command.
:  I changed the value of OPEN_CURSORS from default of 50 up to 200 and still
: received the error.  It is not a large table (51 columns/about 5000 rows).
: 
: Any direction or guidance would be appreciated.
: 
: Thanx in advance

Three things:
1) You must shut down and restart the database for the new OPEN_CURSORS
   value to take effect. Make sure you do this.
2) You should explicitly CLOSE your cursors if you are opening them in
   PL/SQL or third-party tools. Otherwise you will continue to accumulate
   cursors until you exceed your limit.
3) You can find out how many cursors are open with:

   SELECT * FROM V$SYSSTAT WHERE NAME LIKE '%cursor%';

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ROWID Arithmetic
> 
> Ari,
> 	Hello once again.  I am hoping you can help with
> a question I have.  Is it possible to do a sort of
> "rowid arithmetic".  I will explain what I mean.  I want
> to be able to retrieve a record by rowid, then based
> on it's rowid, I would like to give the user "Go to Previous"
> and "Go to Next" buttons, and when the user clicks those
> buttons I would be able to have done some "rowid arithmetic"
> and defined what the rowid should be for the previous and
> next records.  I hope this makes sense.  I have had no luck
> getting help with this, even for someone to tell me if this
> is even possible.
> 	Thank you for your time in reading this.  I will
> greatly appreciate any assistance you are willing to 
> part with.
> 
> Thank you,
> John
> -- 
> 
> **********************************************************
> *  John Holland       (holland@blairlake.com)            *
> *  Technical Director                                    *
> *  BlairLake New Media  (www.blairlake.com)              *
> *  Tel 816.756.2121     Fax 816.756.2992                 *
> *  104 West 42nd Street, Kansas City, MO 64111-2301      *
> **********************************************************
> 
Hi John,

It seems that this is impossible, due to the way rowid is setup. The rowid for
each record looks something like: 00014CD0.0004.0011

The rowid is seperated in 3 portions. The first is the file the record is in,
the second is some internal pointer (record in a block I believe), and the third
is the block in the file.

In a perfect setup (one in which a table is given its own tablespace and the
records are loaded in order and there are no deletions or records chaining
across blocks), then you could decrement the middle portion until it gets to 1,
then decrement the third portion and reset the middle portion to the maximum
number of records in that block.

You can see already that it is getting complicated. Just to find the maximum
number of records in a block is complicated. This is for a "perfect" setup.
Things that could throw off rowid arithmetic:

1) If records are loaded/inserted out of order.
2) If any record is deleted (it will leave gaps in rowids)
3) If more than one object is in the tablespace with the table
4) If records span more than one block

If you want to navigate as you want, you could have a column with a sequence
value (the first record gets a 1, the next a 2, etc.). Since there could be
missing numbers (if records are deleted, for instance), you can decrement the record by going to 

"select max(sequenced_column) when sequenced_column <
                                  (whats_in_current_sequenced_column)".

You can also increment the record by going to
"select max(sequenced_column) when sequenced_column >
                                  (whats_in_current_sequenced_column)".

I hope this helps! BTW, I think you had a good question and would like to pos
my response on my web page along with 70+ other tips. Is this ok with you?


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Missing rollback segment



On Fri, 25 Jun 1999, Jen-Mei Wu wrote:

> I'll probably wait until our DBAs gets in to fix this problem (I do the
> systems and networking stuff), but I'm curious ...
> 
> One of our databases won't open because it says one of the rollback segments
> (the last one specified in init.ora) doesn't exist. Seeing as the database
> was shutdown successfully a few hours before for a backup, couldn't we just
> remove this rollback segment from the parameter file? My understanding of
> rollback segments is that they're temprorary space to rollback current
> transactions; after a shutdown, there shouldn't be any, should there?
> 
> Also, what might have caused this problem?
> 
> Thanks!
> 
> Jen
> 

Jen,

The rollback segments are "permanent" objects in the database ; that is,
they DO exist still when you shut down the database.

To temporarily solve your problem, change your init{ORACLE_SID}.ora file.
There is a line with a reference to all rollback segments. It will look
similar to:

rollback_Segments = (r01, r02, r03, r04, r_big)

Remove the reference to whichever rollback segment it is complaining about
and you should be able to start the database.

Somehow, this rollback segment got dropped. This can happen only if
someone explicitly drops the segment.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 305+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Dumping a schema
> I have a question and I don't know of any other way to contact you.
> I was wondering if you knew how to dump a schema in oracle 8.  I am but a
> lowly intern looking for enlightenment.  If you could help,I would be greatly
> appreciative.  I promise to praise your name to all that will hear.

Peter,

Thanks for the email and welcome to the world of Oracle. There are a few
ways to dump a schema. For Oracle-only format, you use the Export and
Import Oracle utilities. This will dump the contents of all tables,
clusters, rollback segments, etc. to a binary Oracle-only file. Import
loads it in again. There is tons of documentation about Export/Import in
books and in the included Oracle documentation.

If you want to dump to a flat-file, you can follow the example below:

SQL> DESC employees

LAST_NAME			VARCHAR2(100)
FIRST_NAME			VARCHAR2(30)
DEPARTMENT			NUMBER
SALARY				NUMBER

SQL> SET HEADER OFF
SQL> SET PAGESIZE 0
SQL> SET ECHO OFF
SQL> SET FEEDBACK OFF
SQL> SPOOL employees.txt
SQL> SELECT last_name||chr(9)||first_name||chr(9)||department||salary
     FROM employees;

(table gets spooled here)...

SQL> SPOOL OFF

Now, you have a file "employees.txt" that is filled with the data from
Employees. The || is Oracle's concatenation symbol. CHR(9) is the ASCII
symbol for a TAB. Usually, dumped files separate columns with a TAB.

Hope that this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 305+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

When do triggers fire? Can you export from one table and import into another?
> 
> Mr Kaplan,
> I have a couple of questions for you.
> 
> The first is a simple Export / Import question.
> 
> Does SQL Import require that the data be imported into a table having  
> the same name as the table from which the data was Exported? If yes, can 
> you please suggest a way of getting the data into a table with a 
> different name (without ever importing to a table having the same name)

Yes, the table has to have the same name. One thing you can do is make another
user account, and import using FROMUSER=oldaccount TOUSER=newaccount. Then
you will have the table (with the same name) owned by a second user. You can
then copy the table to the new table name as you desire.

> 
> Secondly, if I have some triggers set up on a table, that write data to 
> another table whenever a triggering event (inser, update or delete) 
> occurs on the base table, then do the triggers get fired after a COMMIT 
> has been issued on the base table or do these get fired as soon as the 
> triggering event happens?
> 
They get fired as soon as the triggering event happens, but for the database
to stay consistent the transaction (updates, inserts, deletes) do not become
visible by other users until there is a COMMIT (or rolled back with a ROLLBACK).

Take care,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
> Regards
> mbs26@hotmail.com
> 

Back to Ari Kaplan's Home Page

PLS-00323 error
Subject: Re: PLS-00323 error
Newsgroups: comp.databases.oracle.server
References: <33B444A3.3CE2C210@pantheon.yale.edu>
Reply-To: akaplan@interaccess.com
Distribution: 

Bala Bulusu (bb74@pantheon.yale.edu) wrote:
: Hi!!
: Is anyone familiar with the following error message:
: PLS-00323: subprogram or cursor 'CREATE_EMPLOYEE' is declared in
: a package specification and must be defined in the package body
: I tried recompiling the database package header and body after changing
: the procedure name hoping it would work... no luck!
: I'd appreciate any feedback...
: Thanks,
: B.
Bala,

According to my documentation, the Oracle PLS 323:

subprogram 'name' is declared in a package specification and must be
defined in the package body

Cause: You placed a subprogram specification in a package specification,
but neglected to place the corresponding subprogram body in the package
body. The package body implements the package specification, so the
package body must contain the definition of every subprogram declared in
the pckage specification.

Action: Check your spelling of the subprogram name. If necessary, add the
missing subprogram body to the package body.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Q: How to reconfigure shared-memory segment size in Sun Solaris 2.5.1 kernel (SPARC)
Subject: Re: Q: How to reconfigure shared-memory segment size in Sun Solaris 2.5.1 kernel (SPARC)
Newsgroups: comp.databases.oracle.tools
References: <33B7D460.281A@ix.netcom.com>
Reply-To: akaplan@interaccess.com

 htchen (htchen@ix.netcom.com) wrote:
: Hi! I am running Oracle 7.3.2 on a Sun SPARC 10.  While setting up for
: the first Designer/2000 repository,  I modified the following init.ora
: parameters for a particular database server instance to the values
: shown:
:         shared_pool_size = 18000000
:         db_block_buffers = 1000
:         global_names     = FALSE
:         open_cursors     = 200
:         processes        = 50.
: 
: However, when I tried to re-start the database server instance, the
: following message was returned to me:
: 
:         ORA-07331,smsnsg: unable to allocate the variable portion of the
: SGA.
: I assume I have to modify some parameters regarding shared-memory
: segments in the Solaris UNIX kernel.  Can someone share any information
: on how to resolve this problem?
: Thanks in advance.

Although your shared_pool_size and processes are fairly sized, your Sun
cannot handle it with its current configuration. It could be that you have
other instances running (in which case UNIX kernel parameters may need to
be increased). Regardless, try increasing the following UNIX parameters
and rebooting:

SHMMAX (in bytes, the largest size of shared memory Oracle can grab)
SHMINI (the max # of shared memory segments allowed) - in most cases this
is just one per Oracle instance.

If this fails, lower your shared_pool_area parameter until the Sun can
handle it.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Delete without Rollback?

Newsgroups: comp.databases.oracle
Subject: Re: Delete without rollback?
References: <4r81l3$4g1@kuikka.inet.fi>

pjr@sip.fi (Petri J. Riipinen) writes:

>Hi there.

>I have this one table, which I need to empty every now and then during my
>development. It's not too big, about 10000 rows. But when I do a complete
>delete (Delete * from mytable) it always fails and complains that the size of
>the rollback was exceeded (or something like that). Ok, I can understand that.
>But I wouldn't want to increase the size of the rollback-segment as this 
>delete operation is not going to be used in production, just for my testing.

>So, is there a way to do a "permanent" delete at once, so that Oracle wouldn't
>use any space in the rollback-segment?
>Peace,
>           Petri


Petri,

Using the "TRUNCATE" command will bypass the rollback segments when 
deleting records. For example, "TRUNCATE TABLE too_many_rows;" will 
delete all records.
Note that no triggers that may exist get fired. Also, do not do this to a
table that is a master snapshot.

Good luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Dec Unix - Error on create TS datafile
To: markfrancishaley@bigpond.com
Subject: Re: Dec Unix - Error on create TS datafile
Newsgroups: comp.databases.oracle.server
Reply-To: akaplan@interaccess.com

In article <33B8EA25.44B5@bigpond.com> you wrote:
: Hello.
: I hope someone out there has seen this problem and can offer some
: sugestions.  
: I have a Dec UNIX Alpha workstation ( one OS version down from most
: recent ) with Oracle 7.3.2 .  
: I attempted to create a new tablespace with a datafile of 200mb.  
: At 83mb of size the workstation crashed and I think generated a 
: core dump.  After reboot the datafile of 83mb existed but was not
: know by the database.  I deleted the file and ran the same create
: script with a 50mb datafile.  This succeeded.  I did notice that
: the system datafile was exactly 83mb ( seems like to much of a 
: coincidence to me)!  
: 
: I did not personally install the OS or Oracle but I examined the 
: install log files and they see fine.  A quick glance at Kernel
: parameters appears to be o.k.    Any suggestion? My next step is
: to reinstall Oracle and relink all the products.  
: 
: thanks for any help.
: 
: Mark Haley

Mark,

If you are using raw devices, then this could happen. If you or the UNIX admin
created a volume of 83 Megs, then when creating a 200M file (or anything > 83M
for that matter) it will crash at 83 Megs. If you create a smaller datafile
(50M in your case), it will still consume 83M of disk space, but only 50M of it
will be available to Oracle. The extra 33M will just be wasted.

So, make sure you are allocating the needed size if you are using raw partitions.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

integer division
Subject: Re: integer division
Newsgroups: comp.databases.oracle.server
References: <5p9chn$j4r@pelican.cs.ucla.edu>
Reply-To: akaplan@interaccess.com
Distribution: 

Daren Lee (dalee@pelican.cs.ucla.edu) wrote:
: hi
: does anyone know how to force integer division?
: 
: i'm subtracting 2 DATE types to get the number of
: days between them and then i need to divide by 7.
: e.g:
: to_char(date1,'j')-to_char(date2,'j')/7
: 
: thanks

Daren,

It looks like you are trying to find the number of weeks between two dates.
Oracle has a built-in date function for MONTHS_BETWEEN, but unfortunately none
for WEEKS_BETWEEN.

To do this, you can:

SELECT (TO_CHAR(date1,'j')-TO_CHAR(date2,'j'))/7 FROM dual;

This will return a number such as .285714286. If you want this to be an integer,
it is up to you to decide to round up/down. The TRUNC and ROUND functions will
suffice.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SQL*Plus / Windows NT / host commands
Subject: Re: SQL*Plus / Windows NT / host commands
Newsgroups: comp.databases.oracle.tools
References: <5p9k8o$2gq@agate.berkeley.edu>
Reply-To: akaplan@interaccess.com
Distribution: 

Ken Geis (kgeis@ucsee.EECS.Berkeley.EDU) wrote:
: 
: 	Hi.  I'm running Oracle Workgroup Server 7.3 on NT 4.0 and using
: SQL*Plus 3.3.  I have in a script to automate backups a line, 'host zip
: [zipfile] [datafile]'.  This should compress the database file into the
: zipfile.  So what happens is the zip command runs in the background, control
: returns to SQL*Plus, and the script takes the tablespace out of backup mode.
: So how do I get it to wait for the zip to complete?
: Thanks much,
: 
: 	Ken Geis
: 	kgeis@ucsee.eecs.berkeley.edu
Ken,

Don't run the zip command in the background. If for whatever reason you need to
run it in the background, then have the script wait until the zip process
finishes. You can do this by checking processes or by creating temporary lock
files.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Hanging ORACLE database
Subject: Re: Hanging ORACLE database
Newsgroups: comp.databases.oracle,comp.databases.oracle.server,comp.databases.oracle.tools
Followup-To: comp.databases.oracle,comp.databases.oracle.server,comp.databases.oracle.tools
References: <5pb7bi$f5m@scel.sequent.com>
Reply-To: akaplan@interaccess.com

 Vikas Gautam (gautam@sequent.com) wrote:
: Hi,
: 	I am having a consistent problem in my 7.3.2.3 ORACLE database on
: 	a UNIX machine (Sequent). The problem is that the database seems to 
: 	hang at non-deciphered times and the hanging is not due to a consistent
: 	set of jobs.
: 
: 	The symptoms are also misleading. At one time, I could not log on as 
: 	SYS. At other times, I have not been able to look into dba_ tables (
: 	but could get to the V$ views). At other times a select FIELD1 from 
: 	TABLE1 shows n-number of rows and then hangs.
: 
: 	To solve this problem, I was initially shutting down abort (immediate 
: 	was not doing the job) and then bringing up the database and then
: 	shutting it down and starting again. This solved the problem but
: 	the hanging repeated after a day or two again. The other approach I
: 	took was to "do nothing" and after returning the next day, the problem
: 	of hanging used to go away.
: 
: 	Now, there is NOTHING in the alert_logs or in the trace files. Called
: 	ORACLE and they started poking into ROLLBACK segments (I 
: 	changed the OPTIMAL to 200K from 10M). Nothing happened. 
: 	They have since not returned my call. Have looked into the operatin
: 	system also and seen nothing wrong. Have asked the Sequent
: 	Customer Service to look into the problem but no help.
: 
: 	Can someone give any pointers to help. I can email the init$SID.ora
: 	files to you if you are interested.
: 
: Thanks,
: Vikas
: gautam@sequent.com
: 	

Vikas,

It sounds like you are having problems archiving redo logs. I have
experienced similar symptoms in the distant past when there is no more
room in the archive destination. Any number of things could cause this:

1) The log_archive_dest is not a valid directory
2) The log_archive_dest is not owner by "oracle" or does not have correct
permissions
3) Someone other than "oracle" starts the database
4) There is no more room on the device that contains the log_archive_dest
5) The log_archive_format parameter is not set properly

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Using SQL*Load to load multiple files into one table
> 
> Hi Ari.
> I am tring to create a table, the value for the filed must be imported
> from two different flat files and part of a filed-value must be forced.
> How do i load this data.  I know i could
> use control file to read data form a fixed lenght file, but not sure on
> the (variable lenght + multiple files)  could you please advice.
> 
> 
Mary,

It is straightforward to load from one flat file into two or more tables.
What you need to do is trickier.

You will have to load into two temporary tables first, then do:

INSERT INTO real_table
SELECT temp_table1.column_1, temp_table1.column_2, 'FORCED VALUE',
       temp_table2.column_1, temp_table2.column_2
FROM Table1, Table2
WHERE (add where clause to join tables)
/

Hope this helps!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Ingres to Oracle
On Thu, 1 Jul 1999, hotman wrote:

> hi,Ari Kaplan
> 
>     I am from China,and i am in the position of having to upgrade from
> Ingres 6.4 to Oracle 7.3/8.0,The main problem i am worrying about is
> How to convert my data in Ingres with tables,views and constrains....to
> Oracle database.At present we just consider the data converting,not include
> applications.
> 
>     hotman@163.net
> 
>     Can you give me some suggestions?I cordially appreciate your help.thanks!
> 

"Nee How" from Chicago (I was in China last year)...

As for your question, I do not know Ingres. You will have to extract the
tables into an ASCII delimited file, so that it looks like:

column_1	column_2	column_3	column_4


Each column is separated by a {TAB}.
Then, you can use Oracle's SQL to create the table manually using CREATE
TABLE statements, such as the one below:

CREATE TABLE TABLE_1
        (column_1 varchar2(100),
         column_2 number,
         column_3 varchar2(200),
         column_4 varchar2(50))
TABLESPACE USERS;

Once the tables are created, use SQL*Loader to load the data into the
table. You will need to build a controlfile first. If you do not know
SQL*Loader, then there is lots of documentation with the Oracle software,
or in many books available worldwide (Oracle Black Book, Oracle8 How-To,
etc.)

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 305+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

table all_errors does not exist!
Subject: Re: table all_errors does not exist!
Newsgroups: comp.databases.oracle.server
References: <5pd4fr$gvv@news.Informatik.Uni-Oldenburg.DE>
Reply-To: akaplan@interaccess.com

Gerhard Moeller (Gerhard.Moeller@OFFIS.Uni-Oldenburg.de) wrote:
: Hi,
: 
: when I try to look up a compilation error from within SQL*Plus via
: "show error", I get an error that the table all_errors does not exist:
: 
: 	[...]
: 	ORCL> /
: 	Warning: Package Body created with compilation errors: 
: 	ORCL> show errors
: 	select to_char(line)||'/'||to_char(position) "LINE/COL", text
: "ERROR" from all_errors a where a.name = 'RMPATCH' and a.type =
: 'PACKAGE BODY' and a.owner = user order by line, position
: 
: *
: 	ERROR at line 1:
: 	ORA-00942: table or view does not exist
: 
: 	No errors.
: 
: How can I recreate the table all_errors and why am I missing it?
: 
: 	Thank you for your help, Gerhard.
: -- 
:  Dipl. Inform. Gerhard Möller -- Gerhard.Moeller@OFFIS.Uni-Oldenburg.DE
: 
: OFFIS                   | | | | | |       Tel.:   0441/9722-122
: Escherweg 2             | | | | | |       Sekr.:  0441/9722-113 oder -101
: D-26121 Oldenburg       |O|F|F|I|S|       Fax:    0441/9722-102

Gerhard,

Guten tag oder morgen,

Your all_errors view should have been created when your database was
created. Look in your create database log files for any error messages.

Regardless of how it was not created, you can recreate it by re-running
the catproc.sql script which is found in the $ORACLE_HOME/rdbms/admin
directory. Be sure to log in as the SYS user.

The catproc.sql script calls the catprc.sql script, which creates the
all_errors view (among other views for stored procedurs and triggers).

Since you had a problem with one view that should have been there, I would
recommend re-running the $ORACLE_HOME/rdbms/admin/catalog.sql script as
well to re-create all data dictionary views.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Two conditions with decode
> Hi Ari,
> 
> is it possible two check for two condition with decode
> 
> regards
> Sundeep
> 

Yes....

say you want to return "MALE" if the field is "M" ; "FEMALE" if the field
is "F" ; "UNKNOWN" if the field is neither M nor F. You can do:

SELECT decode(sex,"M","MALE","F","FEMALE","UNKNOWN")
FROM customers;

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 305+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Sequence Caches
Newsgroups: comp.databases.oracle
Subject: Re: Sequence Caches
References: <4rdsp4$1bea@mule2.mindspring.com>

jtdennis@atl.mindspring.com (John Dennis) writes:


>I'm trying to find how sequence are cached.  Specifically, are they
>per transaction or set of transactions.  So if a cache had a high
>cache size of 1000 with 5 users accessing the sequence would each user
>be given there own set of 1000 sequences or would the 5 users pull
>from the 1000?

>I'm trying to figure this out because I'd like to set my cache size
>high because I know that a session will use them but if each user pull
>this high amount then my sequence will increment quickly.

>Thanks for any input.

>Virtually,

>John Dennis

John,

The 5 users would all pull from the 1000 sequences. Otherwise, duplicate
sequence numbers might be generated for different users. Oracle will
allow all users pull from the sequences for data consistency.

Hope this helps, John.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Exporting part of a table
> Hi Ari
> 
> Hope you can help me.
> 
> Currently we are running Oracle Apps and is exporting some of the tables,
> including data, to an OLAP server. Is it possible to export only the new data
> instead of exporting all the data each time.
> 
> 
> I've read a question being asked by someone about datawarehousing that you
> replied on. That is how i found out about you.
> 
> e-mail  :  choppie.pieterse@tmb.co.za
> Thanks for your help. 
> Choppie
> 

Choppie,

Thanks for thinking of me to answer your question, and greetings from
Chicago. I am guessing that .za is in Africa, where I have always wanted
to visit.

Anyway, you can't export part of a table, unfortunately. Even with
"incremental" exports, if ONE record in a table has changed, the Export
utility exports the ENTIRE table. Pretty efficient, huh :)

The only suggestion I have is to convert the table to a partitioned table,
based on the date inserted. Then, you can export only the partitions are
defined on the "new" date. It's more headache and overhead, but it will
surely speed up your exports.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 305+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Improving Export/Import performance
> We are currently looking at OADW or DWBuilder toolsets. But we dont think
> the company will spend that amount of money for now.  Is there any other
> suggestions -  we are transferring 80 tables compressing them with the
> result being 800MB compressed file, which we then import into an 7.3.4
> database.
> 
> Timing of import is a problem for us.
> 
The suggestions I have to improve exports and imports:

* Export your data to a file on a drive separate from the datafiles and
redo logs to reduce disk contention
* Export tables concurrently with multiple exports such as the following
two commands:

exp tables=OWNER.TABLE1,OWNER.TABLE2,OWNER.TABLE3 userid=x/y file=file1.dmp &
exp tables=OWNER.TABLE4,OWNER.TABLE5,OWNER.TABLE6 userid=x/y file=file2.dmp &

* Import with COMMIT=Y and play with the BUFFER size to improve performance.
* Check your redo log size. I have changed redo logs alone to improve
imports by 200%!

Hope that this helps,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 305+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

how to solve it?
Subject: Re: how to solve it?
Newsgroups: comp.databases.oracle.misc
References: <33C1714B.331B@platinum.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Jean Xu (xu@platinum.com) wrote:
: I try to select some records from a table as following:
: 
: SELECT * from file
: where filename='file.sql';
: 
: It did not return any rows(there is one record satisfied this
: condition). I think the reason is the dot(.) in the filename. Can
: anybody tell me how to make it work?
: Thanks!

Jean,

The problem is not the dot in the filename. A few characters such as ' and % are
special cases, but not a dot/period.

First, you cannot have a table called "FILE". File is a reserved word, and
tables cannot be reserved words.

If your table is legitimate and you still have problems, just make sure that
there are no trailing spaces, and that the case of the text is correct.

Try the following:

SQL> select length(filename), filename from file;

Length(filename)	filename
----------------	--------------
10			file.sql
5			x.sql

2 records selected.



Notice that with the file.sql, the length is 10 when it should be 8.  This means
that there are two spaces appended to the filename and you must clean up your
data.

Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Writing ASCII data to Oracle DB, howto?
Subject: Re: writing ascii data to oracle DB,HOWTO?

Thilo Gelenk (TG@techsoft.de) wrote:
: Hi,
: I am in the first stage of developing an untility to 
: convert app. specific ascii data into an ascii file, 
: which data I want to "insert" into the ORACLE DB.
: 
: -Makes it sense to write the typical SQL commands like
:  "SELECT * FROM ..." in my ascii file around the data
:  I want to insert (names and floating point numbers) into the
:  ORACLE DB ?  Or are there nicer ways ?
: 
: -What have I to do to bring (half)automatically
:  this file into the ORACLE DB ?  
: Any smaller examples or hints would be GREAT !
: 
: Thank you very much 
: I would appreciate it,
: if you could email me also directly:
: --------------------------------------------------
: Thilo           Email: TG@techsoft.de
Thilo,

All you need to do is use the SQL*Loader utility. It comes with the Oracle
database. A full explanation is beyond the scope of an email, but you can learn
about it in the "Oracle7 Server Utility User's Guide".

It basically takes an ASCII file and loads it into Oracle tables, reporting any
errors in a nice, consistent format. The files are easiest to load if they are
in a tab/comma delimited format, or a fixed-length format.

The OS command is: sqlload keyword=value, keyword=value, ...
               or: sqlldr  keyword=value, keyword=value, ...

For example,
sqlldr userid=scott/tiger control=controlfile.ctl log=load.log

The other part is to have a control file. An example is:

load data infile data.txt
append into table TINO
fields terminated by "," optionally enclosed by '"'
(ID, Last_Name, First_Name, SSN, Eye_Color)


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 80+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to move a user's tables from one tablespace to another tablespace.
Subject: Re: How to move a user's tables from one tablespace to another tablespace.

Poon Chak Yau (cy_poon@ctil.com) wrote:
: Hello,
: 	I want to move a user's tables from SYSTEM table space to
: another table space. Can anyone tell me how to do it  without
: affecting operations?
: 
: Regards,

Poon Chak,

There are several methods to do this. You can either:

1) export the table, drop the table, create the table definition in the new
   tablespace, and then import the data (imp ignore=y).

2) Create a new table in the new tablespace with the "CREATE TABLE x AS
   SELECT * from y" command:

   CREATE TABLE temp_name TABLESPACE new_tablespace AS SELECT * FROM real_table;

   Then drop the original table and rename the temporary table as the original:

   DROP TABLE real_table;
   RENAME temp_name TO real_table;

After #1 or #2 is done, be sure to recompile any procedures that may have been
invalidated by dropping the table.

I prefer method #1, but #2 is easier if there are no indexes, constraints, or
triggers. If there are, you must
manually recreate them.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 80+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Is there a solution for varchar2 !
Subject: Re: Is there a solution for varchar2 !

Terrence Wong (mingjun@singnet.com.sg) wrote:
: Greetings.
: varchar2 have a limitation, in that they can be declared up to a maximum
: of 32K. I need to store a variable string that sometimes may be longer
: than  32K. Is there another solution to this. There are ways round it,
: but it is not elegant. Do shed your experiences.
: I am writing in PL/SQL for the web.
: 
: Thanks in advance.
: Trrence Wong
: Systems Developer
Terrence,

Varchar2 is limited to 2K, not 32K. You will need to use the LONG datatype
for anything over 2K. You could, on the other hand, break up the field into
several 2K chunks using the SUBSTR function, but this could be the "not
elegant" method you mentioned.

Don't forgret that Oracle8 will allow larger sizes, both in datatype and
number of columns in a table. Still, you will be limited to 4K for
varchar2.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 80+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-1041 Internal error HOSTDEF does not exist
Newsgroups: comp.databases.oracle
Subject: Re: ORA-1041 Internal error HOSTDEF does not exist
References: <4pn7ik$o47@gbc.gbrownc.on.ca>

ykanani@gbc.gbrownc.on.ca (Yousef Kanani) writes:

>Greeting All,
>A user was running a job whichs selects one record at a time
>and updates it this morning and got this error. We ruuning on Oracle
>V7.1.3 on AIX 3.2.5 SGA size is 33M shared_pool_size is 24M.
>Can any one tell why we got this error and what is the fix.
>Oracle Support could not help

>Thanks
>YK

Yousef,

In my documentation, the ORA-1041 is as follows:
01041: "internal error, hostdef extension doesn't exist"
* Cause: Pointer to hstdef extension in hstdef is null.
* Action: Report as a bug
________________________________________________________________________


If this is a bug, then Oracle Support should help you. Call them again 
and insist that it is a bug.

Best of luck.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Is Oracle the worst-documented product of all time?
Subject: Re: Is Oracle the worst-documented product of all time?

Leng Kaing (leng@oz.quests.com) wrote:
: Most arguments seems to say that Oracle is too complex - it requires too
: much time, dedication, consultancy, training etc. People from Access and
: the likes wants something just as easy to work with. Ok. I know how to
: use DOS, Windows 95, and NT. Not perfect, but I can work with it. Does
: that make me a Unix, VMS or MVS expert? NO! And you wouldn't want to
: take anyone on with that kind of experience to administer your o/s
: either. The same argument applies to Oracle. It is a large and complex
: product that calls for training, etc to be invested. 
: 
: Having worked with Oracle, Informix and Sybase previously, I can say
: that I picked up Oracle more easily than I did the other two. And the
: documentation for Oracle are also better than Informix and Sybase. I
: must admit that I had the hard copy to look at. Soft copy just doesn't
: work for me. I hate reading things on-line, except for emails and
: newsgroup articles. Yeah, and Oracle Book is no fun. Hopefully HTML will
: replace it soon!
: 
: Leng.

Just got Oracle8 - its documentation is in html format.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 80+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Size of physical datafiles ..URGENT!!!!!
Subject: Re: Size of physical datafiles ..URGENT!!!!!
Newsgroups: comp.databases.oracle.server
References: <33CA9075.68CD@ctp.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Soumitra Bose (sbose@ctp.com) wrote:
: Hi , 
: 
: ORacle popular wisdom suggests that in any unix environment if the size
: of the datafile goes beyond 1GB ,the performance drops down abruptly .
: Now generally the diskdrives in HP does not come below 2GB (at least).
: If I put in two datafiles there with 1GB , for all practical purposes it
: is just two logical data-files but phyisically it would look like one
: datafile with more than 1GB (in this case 2GB) size . Am i first of all
: correct in making the above assumption ???? 
: What is the best way of getting around it .
: I need a huge number of physical data mount points for the installation
: I am working on ...Any advice .  I guess the RAID 5 level or RAID Array
: architecture would not do any good , am I right ?>?????
: Please advise ..... 
: Thanks
Soumitra,

This is the first that I have heard that performance drops abruptly past 1GB in
Unix. This is not true in my experiences. Perhaps you should investigate the
performance of your drives/controllers.

Your next assumption is wrong. Two datafiles (1 gig each) will physically look
like two datafiles. In Unix, do an "ls" and you will see two files. However,
what I think you are getting at is that having them both on the same drive will
not effectively spread i/o. In this you are correct, and you should spread the
datafiles over different drives and if possible controllers.

RAID will help you. The best method of spreading files is by using Oracle's OFA.
Seperate system, temp, rbs, tables, indexes, etc. according to the OFA
guidelines.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 80+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Oracle EXPORT re: Tables only
Newsgroups: comp.databases.oracle
Subject: Re: Oracle EXPORT re: Tables only
References: <4s9sok$dmg@newsbf02.news.aol.com>

nat5735@aol.com (Nat5735) writes:

>Can anyone help on exporting only certain tables.  We are running under
>Sun OS 2.0 (soon to be Solaris 2.4) and Oracle 7.1.4 (soon to be 7.2.2.3).
> We need the ability to export only the data tables.  We also are running
>an HRMS  Peoplesoft database (4.0) and would like to export (and import)
>only the data tables, not the Peopletools tables (i.e. PSRECDEFN, etc).
>Any help will be much appreciated.

>Natalie Faino
>nfaino@hadco.com

Natalie,

The "export" utility is very flexible for what you want to do. Use the 
"TABLES=" option. For instance, try:

exp TABLES=data_table1,data_table2,data_table3

You can also type "exp help=y" for more options and syntax.
Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

HELP returning rows from stored proc
Subject: Re: HELP returning rows from stored proc

Marvin Frederickson (mfrederickson@kpmg.com) wrote:
: I'm trying to write a stored procedure to return rows, but not having
: any luck.
: In SQL Server, the rows from the last SELECT stmt in the stored proc is
: returned as data from the stored procedure.  How do I do this in Oracle?
: 
: Thanks.
: mfrederickson@kpmg.com
Marvin,

You will need to do two things. First, start the serveroutput:

ALTER SYSTEM SET SERVEROUTPUT ON SIZE 100k;

This will display the output buffer of stored procedures up to 100k. You
can change the 100k to suit your needs.

Next, in the stored procedure, use the DBMS_OUTPUT command:

DMBS_OUTPUT.PUT_LINE('The row is ...'||column_a||', '||column_b|| ... );

Note that no output will occur until the stored procedure has completed.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 80+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Export/Import to migrate platforms

> 
> 	I had a whole bunch of tables with some data in
> them on one Oracle 7.3 server on NT, I exported them out to
> a .dmp file, and imported them into a different 7.3 
> Oracle server on Solaris.  Now, I can do selects and
> everything else I want to do, in SQL Plus, but my Netscape
> LiveWire apps can't select on them.  I thought it could
> be a tablespace issue so I dropped one of the tables that
> didn't have any data in it and created it.  Now I can
> select on it from everywhere, including my LiveWire app.
> Could something be attached to the tables due to the
> export from NT into Solaris?
> 
> Puzzled in K.C.
> John
> -- 
> 
It sounds like permissions were not correctly carried over
from NT to Solaris. First, check the log files from both
the export and the import for any errors. Next, look at
the permissions on the LiveWire app:

SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTEE = 'LIVEWIRE';
SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE = 'LIVEWIRE';
SELECT * FROM DBA_TAB_PRIVS WHERE GRANTEE = 'LIVEWIRE';
SELECT * FROM DBA_ROLES;

See if there are any differences between the NT and the
Solaris from the above SQL statements.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 80+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Changing the database name
> 
> Hi! Ari 
> 
> How are u
> 
> I am a starter DBA and I want to change the name of my existing database
> how can i do this pls help me out.
> 
> thanks in advance
> 
> Susheel kumar
> susheelkr@hotmail.com
> 
Susheel,

There are two ways to do this:

1) Create a new database with the new name and datafiles.
   Export the old database.
   Import the old database into the new database.

2) Issue "alter database backup controlfile to trace" - this will create a
   "create controlfile" file in the ../udump directory. You will have to
   carefully modify this script, noting any changes in the location of files
   (which you may want to do to stay OFA compliant). Also, add the appropriate
   renaming command in the appropriate location (see the SQL reference manual).
   BACKUP THE DATABASE after shutting it down.
   Run the script after setting your ORACLE_SID environment variable to the
   new database name.

In both methods, be sure to modify the /etc/oratab (if in UNIX) and any
scripts that may reference the database name, such as backup scripts.

Best of luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Deleting duplicate rows
> 
> Hello Ari
> I would appreciate if I could get sql utility to delete duplicate rows
> from a table
> Thanks in advance 
> Suresh
> Sollala@Informatica.com  
> 
You will have to create a new SQL statement for each table, since the SQL will
depend on the structure of the table. Follow the example shown below:

Assume there is a table TABLE_A with column_a, column_b, and column_c.
I will assume that a "duplicate row" has the same data in all three columns.

To determine this, try:

SELECT column_a, column_b, column_c, count(*)
FROM table_a
HAVING count(*) > 1
GROUP BY column_a, column_b, column_c
/

This will show which columns are duplicated. You can delete ALL duplicates with
the following:

delete from table_name A where A.rowid >
   (select min(B.rowid) from table_name B where A.col = B.col);

or you can also try:

DELETE FROM x
WHERE rowid NOT IN
    (SELECT max(rowid) FROM x
     GROUP BY fieldname1,fieldname2,fieldname3..
     HAVING count(*)>=1)

You can delete just one of the duplicate sets with the following:

DELETE FROM table_a
WHERE column_a = 'XXX' AND column_b = 'YYY' and column_c = 'ZZZ'
AND rownum < 2
/

This will delete just the FIRST record with the duplicate data. You will have to
iteratively do this for all such data. There is probably a more elegant way
to do this but I can't think of any right now.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Limiting rows to the top X records meeting a condition

> Subject:
>         Limiting rows
>    Date:
>         Mon, 13 Jul 1998 14:14:10 +0200
>    From:
>         Stefan Bleicher 
>      To:
>         akaplan@interaccess.com
> 
> Hi  Ari,
> 
> I have a question about limiting  the rows being returned by a select
> statement.
> 
> I have a large table and want to get only some rows out of this table. I
> know the rownum clause, but this is not the
> solution to my problem, because I want to get the rows (in alphabetic order)
>  for example from row 3 to row 5, not
> from row 1 to row 5.
> 
> Example:
> 
> NAME
> 
> Alber
> Albrecht
> Ari
> Bleicher
> Black
> Miller
> Percy
> Robert
> Robin
> Walter
> 
> SELECT * FROM ... WHERE ROWNUM < 6 ORDER BY NAME    => All rows > 6  =>
> Alber, Albrecht,Ari,
> Bleicher, Black
> 
> But I want to get  the result Ari, Bleicher, Black (rows 3 to 5). Do you
> know the SQL-statement to get this.
> 
> Please answer to
> 
>     sbleicher@ibl.de
> 
> Thanks for your help
> Stefan
> 
Stefan,

As far as I know this is very hard if not impossible in SQL. This is because
ROWNUM is a pseudo-column and you can never have " ROWNUM > " in the WHERE
clause. There are two ways I can think of to do this:

FIRST METHOD:
Use PL/SQL:
1) open a cursor.
2) loop through the cursor keeping track of the record number with a variable.
3) output only the data when the variable is between 3 and 5.

SECOND METHOD:
1) Create a new table:
   CREATE table_b AS
   SELECT ROWNUM AS ROW_NUMBER, column_a, column_b, ...
   FROM table_a
   ORDER BY column_a
2) Your table (table_b) has a new column called ROW_NUMBER. You can select
   your records with:
    SELECT * FROM table_b
    WHERE ROW_NUMBER > 2 AND ROW_NUMBER < 6

Best of luck!


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

Performance Question
Subject: Re: Performance Question
Newsgroups: comp.databases.oracle.server
References: <01bc95eb$cffc8fa0$03e057cf@brianc>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

Brian Camper (brianc@cmhc.com) wrote:
: Please excuse the newbie question, but I am trying to monitor the
: performance of our Oracle 7.3.0.0 database but I do not know the best way
: to do this.  Does Oracle come with some tools to assist in this task, or
: are there other products we have to get?  Thank you in advance.
: 
: Brian Camper
: brianc@cmhc.com

Oracle 7.3 comes with some good monitoring tools. Server Manager can be
accessed by typing "svrmgrl" for a line-mode version and "svrmgrm" for a
GUI version. You can view and modify performance on dozens of areas.

Earlier versions of Oracle had SQL*DBA, accessed by typing "sqldba" for
a text-based "GUI-like" version, or "sqldba lmode=y" for a text-only
version.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Tablespace Creation trouble -- Help!
Subject: Re: Tablespace Creation trouble --Help!
Newsgroups: comp.databases.oracle.misc
References: 
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Jason Berryhill (speck@ecst.csuchico.edu) wrote:
: 
: I hope this is an easy question:
:  
:  I have just set up my first ORACLE db 7.3.2.0 on HP-UX 10.10 on a
:  9000/735.  The database is created.  I am trying to add tablespaces.  I
:  used the following command to create a rollback segment first:
:  CREATE ROLLBACK SEGMENT rbs_1
:          TABLESPACE SYSTEM
:          STORAGE ( INITIAL 3
:                    MINEXTENTS 121
:                    MAXEXTENTS 10240
:                    NEXT 10240
:                    PCTINCREASE 0)
:          OPTIMAL TO 250 K;
:  
:  I receive this error message:
: CREATE ROLLBACK SEGMENT rbs_1
:   *
:   ORA-00406: COMPATIBLE parameter needs to be 7.3.0.0.0 or greater
: 
: Does anyone know what this error message signifies?  I don't have a
: reference for SQL error messages yet, and I need to get this going for my
: developers.  The same message appears for when I tried to create a
: TABLESPACE.  ANY help is appeciated.  
: 
: Thanks much,
: Jason Berryhill

Jason,

The error signifies that the COMPATIBILITY parameter in the init.ora file is set
to a version too low for 7.3.0.0.0 to use. Allowing your CREATE ROLLBACK segment
will make your database incompatible with whatever your init.ora is set to.

To find out what you are, look in your init.ora or type:

select * from v$parameter where name = 'compatible';

On another note, you should avoid putting your rollback segments into the SYSTEM
tablespace. Make a separate rollback tablespace and put the rollback segments
there.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


: ====================================================================
: =Web Site:  http://www..ecst.csuchico.edu/~speck                   =
: =email: speck@ecst.csuchico.edu or jberryhill@cepo.csuchico.edu    =
: =                                                                  =
: =BASIS Support Team.  College of Business SAP R/3 class Spr 97     =
: =	California State University, Chico                           =
: =                                                                  =
: =  And He looked up and saw the rich putting their gifts into the  =
: =treasury.  And He saw also a certain poor widow putting in two    =
: =mites.  So He said, "Truly I say to you that this poor widow has  =
: =put in more than all;                                             =
: =  For all these out of their abundance have                       =
: =put in offerings to God, but she out of her poverty put in all    =
: =the livelihood that she had."                                     =
: ====================================================================
: 

Back to Ari Kaplan's Home Page

Migrating Oracle6 to Oracle7: straight from datafiles?
-----Original Message-----
Subject:	?Oracle Import of DBF'S?

I am not sure why you would want to help me... but here goes anyway...

We run Oracle 7.3 in-house and want to import data stored in Oracle6
dbf files. Is there an easy way to go straight from the DBF into Oracle 7
without first exporting the data to a DMP file.  (It would save us a ton of work
if we could).

The reason I am asking is because we don't have any Oracle Guru's in house
and I don't have any documentation on Oracle 6 format tables.

Thanks in advance.

JStauft (M.B.A.  B.A.Sc.)
The easiest way to copy the data is to export from Oracle6 and import into
Oracle7.
The other method, which is generally more tedious, is to make a database link to
the schema in Oracle6. Then, you can say:

CREATE TABLE X AS SELECT * FROM X@db_link;

You will have to repeat this for each table contained in the DBF file. You also
need to carry over indexes, grants, synonyms, constraints, triggers, and so on.
This is why I prefer the straight export/import.

-Ari

Back to Ari Kaplan's Home Page

How can I determine the size of my Oracle database?
Subject: Re: How Can I determine the size of My Oracle Database?
Newsgroups: comp.databases.oracle.tools
References: <19970724172301.NAA16649@ladder01.news.aol.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

SatarNag (satarnag@aol.com) wrote:
: How Can I determine the size of my Oracle 7.3 Database? Is thier a
: dictionary view that I can look at? Please Help me by E-mailing me at
: SatarNag@aol.com
: 
: Thank You in Advance for any help, 
: Satar Naghshineh
: 
The majority of the size comes from the datafiles. To find out how many
megabytes are allocated by ALL tablespaces, type:

select sum(bytes)/1024/1024 from dba_data_files;

Add to this the size (in megabytes) of your redo logs:

select sum(bytes)/1024/1024 from v$log;

The above two queries will show you how large your database is. Also, if
you are in archivelog mode, you will generate files in your archivelog
destination. Issue the following query to see where your archived redo
logs get placed:

select * from v$parameter where name = 'log_archive_dest';

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do TEMP segments get cleared out?
-----Original Message-----
From:	Moritz, Jean (JFMO) [mailto:JFMO@chevron.com]
Sent:	Friday, July 24, 1998 1:23 PM
To:	'akaplan@interaccess.com'
Subject:	Temporary Segments

>We have a 2Gb temp tablespace.  One of our reports created a temporary
>segment with 1969 extents (initial 1M, next 1M) and filled the
>tablespace.  After 24 hours, this segment had not disappeared.  To clear
>out the tablespace, I bounced the instance early this morning.  I
>thought Oracle would reuse temporary segments.  We think our problem is
>with the 'ORDER BY' clauses in the application and changing the instance
>OPTIMIZER_MODE to FIRST_ROWS.    The optimizer setting improved the time
>on the reports, but has caused huge temporary segments.  
>Some info from you was forwarded from another DBA.  
>
>Do temporary segments get freed by smon/pmon?  If not, is there a way to
>manually clear out these segments other than dropping the tablespace or
>bouncing the instance?
>
>Thanks so much.  I just checked your WEB page, but could not get to the
>server.
>
>Jean F. Moritz
>Chevron Information Technology Co.
>CTN  596-3276
>
Jean,

Yes, the TEMP segments (probably owned by SYS) do get cleared out, although it
sometimes takes a while. You just have to wait it out.
One reason for swapping is the SORT_AREA_SIZE is too small. Once Oracle uses
that space in memory, it has to swap out to disk.

To improve performance, it sounds like you should change your default storage
for your TEMP tablespace:

ALTER TABLESPACE TEMP DEFAULT STORAGE (INITIAL 100M NEXT 100M);

That way, there would have been only 20 extents instead of 1969.

Best of luck,

-Ari

Back to Ari Kaplan's Home Page

rescuing index
Subject: Re: rescueing index
Newsgroups: comp.databases.oracle.misc,comp.databases.oracle.server,comp.databases.oracle.tools,comp.databases
Followup-To: comp.databases.oracle.misc,comp.databases.oracle.server,comp.databases.oracle.tools,comp.databases
References: <33D8EDA8.32DC@lingocd.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

Raul Sanchez (rsanchez@lingocd.com) wrote:
: Hi,
: 
: while loading in direct load state my index got locked after
: I kill the job.  I killed the session by using the alter
: system utility.  I managed to alter the system, but the index
: still remained in direct load state.  How can I rescue the index
: without having to truncate or drop the table?  Any ideas?  Thanx
: in advance!
: 
: --jchook :P

Don't drop or truncate the table! You can just rebuild the index. I don't know
what version of Oracle you are using,

so I will describe one method to rebuild an index:

1) Find out the columns of the index:
   SELECT COLUMN_NAME
   FROM USER_INDEXES
   WHERE INDEX_NAME = 'index_name';

2) Find out the storage parameters of the index:
   SELECT UNIQUENESS, TABLESPACE_NAME, INITIAL_EXENT, NEXT_EXTENT, MIN_EXTENTS,
          MAX_EXTENTS, PCT_INCREASE, PCT_FREE
   FROM USER_INDEXES
   WHERE INDEX_NAME = 'index_name';

From the above two steps, you can create a "CREATE INDEX" SQL statement.
Drop the index and recreate it with your SQL statement.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

NEWBIE: file structure for ORACLE

Newsgroups: comp.databases.oracle
Subject: Re: NEWBIE: file structure for ORACLE
References: <31F91991.41C6@interport.net>

Alan Macaluso  writes:

>Howdy all,

>I'm relatively new to SQL/Oracle.  I understand a bit of SQL.  I've
>recently installed Oracle (Solaris) but have not configured it
>completely.

>Although it's not completely configured, I am going to have to start
>capturing user data (name, address, phone, etc) -- most likely some kind
>of delimited file (tab, semi-colon....).  

>My question is this: is there some standard/prefered way to structure
>the file for import into Oracle??

>Any help, tips, suggestions would be GREATLY appreciated.

>Alan Macaluso

Alan,

There is no standard way to structure the file for loading into Oracle. The
SQL*Loader program is flexible enough to be used with any delimeter, be it
spaces, tabs, commas, etc.

The best delimiter is a character that is not contained in any field. For
instance, if one field is a name, such as "Alan Macaluso" or an address, such
as "23 Broadway Ave", then a space would not be ideal as a delimiter.

You can specify when loading the delimiter by commands such as 
TERMINATED BY ","
TERMINATED BY WHITESPACE (spaces and tabs)
ENCLOSED BY '"'

See the Oracle Utilities User's Guide for more specifics on SQL*Loader.

My personal preference is comma-delimited fields, with a line feed after each
record.

Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Help!! Object does not exist

Newsgroups: comp.databases.oracle
Subject: Re: Help!! Object does not exist
References: <31F8EA23.763F@worldnet.att.net> <4tam8a$12g0@watnews1.watson.ibm.com>

mlanda@vnet.ibm.com writes:

>In <31F8EA23.763F@worldnet.att.net>, Joe Brouillette  writes:
>>I am stumped.
>>
>>A developer used a MS/Access internal procedure to generate a temporary
>>table and now we cannot remove the table from the database.
>>
>>when logged on as the user and query user_tables The table is listed, but
>>when we try to drop the table Oracle states that the object does not
>>exist.
>>
>>I have logged on as sys and the owner & table is present in the
>>dba_tables view, but I cannot drop the table as sys either, I also
>>receive the same message of the Object does not exist.
>>
>>Thanks for your assistance.

>Does the table's name have mixed or lower case letters?  If so, you will have
>to reference it by surrounding it with quotes. For example:

>  drop table Temp_Table;    -- will not work

>  drop table "Temp_Table";  -- will work



>M.Landa

M.Landa and Joe,

There is a good chance that specifying the table in quotes for lower-case 
will work. If, however, it doesn't, there are two things to check:

1) Make sure that you are logged in as the user. When you were logged in as
SYS and tried to drop another user's table, it failed. Try:
DROP TABLE username.TABLENAME;

2) The object might be a view and not a table. Try:
DROP VIEW username.VIEWNAME;

Hope this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

> 
> Hi Ari,
> 
> I am a big fan of your home page ( especially the part in which your
> trouble shoot all the DBA problems.)
> 
> 	Ari, I was an Oracle developer for 3 years and I am entering
> the DBA areana slowly. Eventhough the transformation is not seamless
> I am trying my best. Recently I have tried to recreate a TEMP
> tablespace. I have removed the datafile instead of droping the
> tablespace first, now I am unable to drop the tablespace because it
> it asking for the file. I tried creating an index with this problem
> and had a DBWR error. When I tried to restart the database it is 
> asking for the removed datafile with ora 1157 error.
> If you have a few minutes for me could you please advise me what to do.
> 
> Thank you in advance for saving my job.
> Kishore................kxa@qsun.att.com
Kishore,

I hope this saves your job.... :)

Do the following steps and you will be able to restart your database:

1) Connect to SQL*DBA or Server Manager and issue "shutdown abort"
2) Issue "startup mount" command
3) Issue the following command, substituting the correct datafile
   (such as /u01/oradata/temp01.dbf):

   alter database datafile '/u01/oradata/temp01.dbf' offline drop;
4) alter database open;
   (Your database is now up!!!)
5) drop tablespace TEMP including contents;

Good luck on the DBA job!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

[Q] how to find how many rows in each table in the database?
Subject: Re: [Q] how to find how many row in each table in database?
Newsgroups: comp.databases.oracle.server
References: <33DDEE18.5C465511@hkstar.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Larry Leung (llarry@hkstar.com) wrote:
: hello everyone,
: 
: i just wonder is there a better way to find out how many row of each
: table in
: the database. It is because i am assigned a job to refresh our
: development
: database from the production one.
: 
: by 'select count(*)' from each table seems time consuming.
: 
: thanks in advance
: larry
Larry,

What you should do is make a SQL script that creates another SQL script
containing all tables.

Try the following:

SET HEAD OFF
SET PAGESIZE 0
SET FEEDBACK OFF
SPOOL SCRIPT.SQL
SELECT 'select count(*) from '||OWNER||'.'||TABLE_NAME||';'
FROM ALL_TABLES
SPOOL OFF

At this point, there will be a script called "SCRIPT.SQL" that contains all
"SELECT COUNT(*)" statements you will need.

To find the results of this script, do the following:

SET ECHO ON
@SCRIPT.SQL

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

I see you work at the Hong Kong Star. Did you know that the McDonalds at the
Star Ferry Terminal is the second most visited (behind Moscow's)

Back to Ari Kaplan's Home Page?

Rollback tablespace fragmentation
>      Hi Ari,
>      
>      I had a quick question.  Have you ever seen where the tablespace for 
>      rollback segments becomes so fragmented that a rollback segment can't 
>      get the next extent?
>      

The tablespace could get fragmented, but should never cause a rollback segment
to fail to extend. The only cases where this should happen are with

* Rollback segments with PCTINCREASE > 0
* Rollback segments of different INITIAL/NEXT sizes within the same tablespace

Try to coalesce the free space in the rollback tablespace:

Oracle 7.3:
----------
* alter tablespace RBS coalesce;

Before Oracle 7.3:
-----------------
* alter tablespace rbs default storage (pctincrease 1);
  (wait 15 minutes)
* alter tablespace rbs default storage (pctincrease 0);
This causes the background process to coalesce the free space when it wakes up.



-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SYS tables are chaining...
> 
> Hi Ari,
> 
> Question:
> 
> I have a new database that has an Oracle block size of 8092, and I have
> chaining of SYS tables COL$, IND$, IDL_UB1$, IDL_UB2$, and IDL_SB4$.
> 
> Should I have made the db_block_size larger? Is this something that I
> even need to worry about?
> 
> Thanks.
> 
> Mike Killough
> 
Hi Mike,

When you say "chaining", it typically refers to records
spanning more than one data block. I can understand the IDL% views because
they contain LONG RAW columns, which would probably chain regardless of the
block size if you have large enough values for your data dictionary (which
includes and packages/stored procedures, among other items).

If you meant that they grew to several extents, then you have fragmentation,
not chaining. This is typical in many sites, especially those that have many
stored packages/procedures. Oracle specifically acknowledges that they may
grow in extents, but cautions not to change their INIT/NEXT storage parameters.

So basically my advice is not to worry about the data dictionary tables, and
8K block sizes are fine for them.

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 175+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Working with \121 character and other irregular characters
-----Original Message-----
From:	Wayne Tomasi [mailto:wtomasi@mailcity.com]
Sent:	Wednesday, July 29, 1998 7:00 PM
To:	akaplan@interaccess.com
Subject:	HELP - write character 'Ñ' to forms/sql

Hi,
  Please do help me find a way to save a record with the character 'Ñ'
  (alt-1-6-5) in it.
  Is there a way of writing it on Forms 4.5 and SQL?
  Can I retrieve the same record with the character in question from the database?

Thanks.

-----Reply Message-----
Wayne,

You can use CHR(209) to represent the Ñ character. So, if you want to say
"MAÑANA", you can do:

INSERT INTO table_a VALUES
('MA'||CHR(209)||'ANA');

Yes, you can retrieve the same record with no additional changes.

Best of luck,

-Ari Kaplan

Back to Ari Kaplan's Home Page

Segment and free space allocation
-----Original Message-----
From:	bret.higginbotham@nationsbank.com [mailto:bret.higginbotham@nationsbank.com]
Sent:	Tuesday, July 28, 1998 10:53 AM
To:	        -         (052)akaplan(a)interaccess.com
Subject:	

Ari Kaplan,

Scenario:

I have a database containing a few records and I need to change storage
allocation parameters so I drop and recreate all objects in the schema.  After
recreating the objects with new storage parameters and before any data is
inserted, I go into OEM and check the tablespaces and datafiles in data storage
manager. The "used" column in data storage manager shows 42 MB used for the
primary data TS and there's no data in the tables.

Questions:

Are the extents pre-allocated, causing 42MB of datafile usage to show ?

If so why does the usage go down to 37MB after the initial data is inserted
into the database ?

I ran analyze on all tables in the schema and queried the DBA_TABLES view to
get another picture of data  usage. Looking at this information, I saw that
blocks were only allocated to tables actually containing data so I was even
more confused by the initial reading of 42MB used immediately after the storage
parameters had been changed.

Any ideas, your feedback is greatly appreciated,

Thanks,

Bret Higginbotham
NationsBank
(formerly of  Grant Thornton and painful VBA participant).

Bret.Higginbotham@NationsBank.com

------ Reply ------
Hi Bret,

As for your question, Oracle pre-allocates extents, meaning that it grabs chunks
of database blocks from the free space for a tablespace, and then fills in the
allocated blocks with data. When all blocks are filled, it allocates another
extent.

Why the usage goes down is a mystery. It probably is due to reading the wrong
data dictionary tables. Look at:

SELECT *
FROM DBA_EXTENTS
WHERE SEGMENT_NAME = 'table_x';

This will tell you how much is allocated.

SELECT SUM(BYTES)/1024/1024 Megs
FROM DBA_FREE_SPACE
WHERE TABLESPACE_NAME = 'tablespace_x';

This will tell you how much is free in the tablespace.

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

How to determine free memory in Oracle
Subject: Re: how to determine free memory in Oracle
Newsgroups: comp.databases.oracle.misc
References: <5rnfqt$a50@simba>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

Gregory Bronevetsky (bronevet@beast.Trenton.EDU) wrote:
: I'm writing a Web front for an Oracle database. To do this, I need to
: create and keep a lot of views and since a lot of people may be using the
: system at the same time, I need to know how much memory the database
: server has left for my views so that I can know if creating another view
: will go over the memory limit. Is there any way to get this information?
: --
:                         Greg Bronevetsky                                
To see what memory you have, type:

select * from v$sga;

For a more detailed analysis, type:

select * from v$sgastat;

The item for "free memory" shows the free memory. One thing though -
adding a view will not really affect the memory. Objects are phased out of
memory to a LRU algorithm. To adjust memory in Oracle, adjust the three
parameters: sort_area_size, shared_pool_size, and db_block_buffers.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Inserts too slow
> Hi Ari,
> 
> I have a question about performance, the situation is the following, we
> have a lot of insert into our database( some tables) , sometime the
> function ( Proc*C)
> that do insert take between  12 to 20  seconds, i looked to see if there
> is any freelist contention, 
> the result was good, so i decided to put that table on a seperate disk
> and also the indexes, 
> and the result ( insert took the same amount of time ) still the same.
> 
> Where should i concentrate the search for that problem? 
> 
> Thanks for the help.
> 
> Hanna
Hanna,

Glad you checked freelist contention. Other areas to look at:

1) Excessive object extents. If an object has more than 4 extents, performance
   degrades. Issue the following SQL:

SELECT * FROM DBA_SEGMENTS WHERE EXTENTS > 5;

If any have the EXTENTS column large, then re-create the object (export/import
with compress=y works well).

2) Look at indexes. The more indexes there are, then the longer an insert
will take.

3) Look for triggers on the table. If there is a trigger, then untold amounts
of processing may be taking place.

4) Make sure your rollback tablespace, redo logs, and archived log destination
(if you are in archivelog mode) are on separate disk drives (and if possible
controllers).


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

ORA-01555 snapshot too old?

March 27, 1996
Newsgroups: comp.databases.oracle
Subject: Re: ORA-01555 snapshot too old? / NetWare-Database crashes
References: <3159B621.4813@pz-oekosys.uni-kiel.d400.de>

Friedel Hosenfeld  writes:

>Hi,					Kiel, 27-MAR-1996

>I am experiencing a strange problem. One of our databases
>is a Oracle7 (7.0.16.6.0) running on a Novell Netware (3.11)
>server. We must use that old release because of some
>compability reasons.

>Since some days ago the database export doesn't work,
>giving instead the message "ORA-01555: snapshot too old (rollback segment
>too small)".

>When I retrieve some tables, I get at some point (some particular
>users) that message. Some other users are fine.

>Very often - when I shut down and restart the database -
>not only the database but the whole NetWare-Server crashes.
>Sometimes the database crashes without any user action.

>It's a very small database. I enlarged the tablespaces and
>rollback segments but that didn't change the situation.

>In the manual 4 reasons can be found, but only
>the first two could be responsible in my case:
>1. Insufficient Rollback Segments
>   -> but I increased them
>2. Corrupted Rollback Segment

>Because of the frequent crashes, I think that might be
>the reason. How can I check that? Is there somebody
>with experiences with that error message?

>I will probably call the hotline but any hints are
>welcome.

>Thank you,
> friedel


>-- 
>    Friedel Hosenfeld         http://www.pz-oekosys.uni-kiel.de/~friedel
>Ecosystem Research Centre            friedel@pz-oekosys.uni-kiel.d400.de
> Schauenburger Str. 112		          
>  D-24118 Kiel *  FRG                         blue in the face?

Friedel,

What you found in your manual may not fully explain the problems you have 
been having. The most likely cause IS that your rollback segments are too 
small. Specify larger INITAL and/or NEXT EXTENT sizes for your rollback 
segments. Considering that only some users get the error message, it seems 
that those users attached to that segment get the error, while the users 
attached to other segments do not get the error. Also be sure to set the 
OPTIMAL parameter of the rollback segment (if you are using Oracle7).

Another problem could be caused while using Trusted ORACLE. If your 
interval between checkpoints is too small in a secondary database, you
can get this error. Oracle recommends decreasing the value of the
LOG_CHECKPOINT_TIMEOUT parameter in your "init.ora" file.

As to your system crashing, I can't help you there. You could have a
legitimate bug.

If you are worried about corrupted rollback segments, then drop and
recreate them as soon as possible!

Good luck.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> EMAIL            :  akaplan@interaccess.com                      <->
<-> Visit my WEB PAGE:  www.arikaplan.com                            <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

DB_BLOCK_SIZE: Possible Misinformation
Subject: Re: DB_BLOCK_SIZE: Possible Misinformation
Newsgroups: comp.databases.oracle.misc
References: <19970801153801.LAA18307@ladder02.news.aol.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

SatarNag (satarnag@aol.com) wrote:
: In regards to changing the DB-Block_Size without re-creating your
: database, I must have been misinformed, Upon looking up in my
: documentation, it says it must be done on the creation of the database. I
: have just completed the Oracle DBA master's coarse (Oracle 7.3), offered
: by Oracle....And in my notes, i wrote down that the Block Size can be
: changed and that the database will start useing the new size and will
: adjust accordingly...I wrote this down cause I thought it was nice that it
: can be done. Maybe it still can be done, and that it's not documented in
: the books. I apoligize if I am mistaken. Maybe it's in Version 8??? 
: 
: Satar Naghshineh

Satar,

db_block_size can only be defined at database creation. Once the instance is
created, the datafiles are "hard-coded" with the blocks allocated, and this
cannot be altered. I just checked my Oracle8 docs and the same is true for
Oracle8.

Maybe you were thinking of db_block_buffers?

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

What happens if...
Subject: Re: What Happens if...
Newsgroups: comp.databases.oracle.server
References: <19970731233501.TAA00701@ladder02.news.aol.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

SatarNag (satarnag@aol.com) wrote:
: Hi Again ;)
: If I was archiving to a tape device, what would happen if I changed the
: tape without turning the archiver off? does it stay in a buffer till
: another tape is replaced? If so, what is the name of the buffer? or does
: the transactions that I am updateing/deleting/ect...spew to nowhere?
: 
: Satar Naghshineh 
: 
Satar,

What will happen is that your database will function normally until it
attempts a redo log switch. At that point, it will try to archive the redo log
to tape. Since there is no tape available, the database FREEZES (except for
SELECT statements) until it can properly archive to tape.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 90+ Oracle tips, visit my Web Page:                       <->
<->                                                               <->
<->              www.arikaplan.com                                <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Oracle 8 on HP/UX 10.x
Subject: Re: Oracle 8 on HP/UX 10.x
Newsgroups: comp.databases.oracle.misc
References: <33E2906E.3EAA1BAC@genesyslab.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

georget (georget@genesyslab.com) wrote:
: Where can I get it?
: Thanks,

You have to call Oracle Corp (or see them at www.oracle.com). They can
sell you a copy. If you already have Oracle7, you may be eligible for a
free or lower-cost upgrade. This will depend on your service agreement.

For HP/UX, you need 10.2 for Oracle8 to work.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How to display date and time from 'Select Sysdate...'
Subject: Re: How to display date and time from 'Select Sysdate...'
Newsgroups: comp.databases.oracle.server
References: <19970802191800.PAA13226@ladder02.news.aol.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

JYF 3 (jyf3@aol.com) wrote:
: Hi, Helper :
: My target is to display system date and time at same time.
: I can do this on MSSQL Server without any problems.
: But, I can't do it on ORACLE with sentence like this:
: SELECT SYSDATE FROM DUAL;
: unexpected output 
: 01-AUG-97
: expected output
: 01-AUG-97 12:35AM.
: 
: If you know how to change system default datetime format, please give me a
: help.
: Thanks !
: JYF3

You will need to use the TO_CHAR function. For your needs, type:

SELECT TO_CHAR(SYSDATE, 'DD-MON-YY H:MIPM') FROM DUAL;

You will get a response like

04-AUG-97 10:19AM

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Default value of pct_increase
Subject: Re: Default value of pct_increase
Newsgroups: comp.databases.oracle.misc
References: <33E6D420.2DB1@alcatel.be>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

Marc Billiet (Marc.Billiet@alcatel.be) wrote:
: It may be a very basic question, but according to the Oracle manual 
: (Oracle 7 Server SQL Language Reference Manual), the default value of 
: pct_increase is 50. When I create a table, pct_increase is always set to 
: 0. Is it possible that the default has changed somehow (can the dba have 
: done this ?).
: To check this, I did the following in SQL*Plus :
: SQL> create table marc (x number);
: 
: Table created.
: 
: SQL> select pct_increase from user_tables where table_name = 'MARC';
: 
: PCT_INCREASE
: ------------
:            0
: 
: Is there any reason why it is always set to 0 (not only in this example) 
: ? 
: The Oracle version is 7.3.2.3.0 on HP-UX.
: 
: Thank you for your time,
: 
: Marc Billiet

The most likely reason that your tables are being created with a
PCT_INCREASE of 0 is that the default storage parameter of the tablespace
is set to 0. To find out, try:

SELECT * FROM DBA_TABLESPACES WHERE TABLESPACE_NAME = 'tablespace_name';

When an object such as a table is created in this tablespace, it will take
the default storage parameters if not supplied in the CREATE TABLE
command.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Oracle long field attribute - length
Subject: Re: Oracle long field attribute - length
Newsgroups: comp.databases.oracle.misc
References: <33E61B34.7093@mit.edu>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Steven Neiterman (wade@mit.edu) wrote:
: Anyone know of a way to determine the length of an attribute defined as
: a long?
: The length function does not work with the long attribute.
: Thanks in advance,
: ..Steve
: (wade@mit.edu)
Steven,

You cannot do string functions on LONG columns with regular SQL. You will
have to use PL/SQL. Look at the following example:

SET SERVEROUTPUT ON SIZE 10000;
DECLARE
long_var LONG;
BEGIN
SELECT text_column INTO long_var
FROM table_with_long
WHERE rownum < 2;
DBMS_OUTPUT.PUT_LINE('The length is '||LENGTH(long_var));
END;
/


Basically, you define a variable as the LONG type, then SELECT the column
INTO the variable. Finally, it is output to the user. SET SERVEROUTPUT ON
SIZE 10000 allows spooling from the PUT_LINE to go to the screen.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Shutdown NORMAL not working
> 
> 
> hi ari ,
> i am a recent graduate into DBa we run oracle 7.3 on windows nt4.0
> platform i am enclosing my pfile with this mail please help me in
> changing it or to correct it as i have problems in shutting down the
> database. i can shut down in immediate and abort options but if i do
> shut down in normal its taking lot of time i.e hours so i had to do a
> immediate shut down.so please help me  and an advance thanks
> 
The reason that your SHUTDOWN in normal mode is taking so long does not have
to do with your pfile. The reason is that when you do a SHUTDOWN normal,
the database waits until ALL users logout of the database. If even one user
remains on, the database will not shut down. I always use SHUTDOWN IMMEDIATE.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
> 
> pfile
> 
> db_name = oracle
> db_files = 20
> control_files = (H:\ORANT\DATABASE\ctl1orcl.ora,
> H:\ORANT\DATABASE\ctl2orcl.ora)
> 
> compatible = 7.3.0.0.0
> 
> #db_file_multiblock_read_count =  
> # db_file_multiblock_read_count = 8                                  
> # SMALL
>   db_file_multiblock_read_count = 16                                 
> # MEDIUM
> # db_file_multiblock_read_count = 32                                 
> # LARGE
> 
> #db_block_buffers =                                # INITIAL
> # db_block_buffers = 200                                             
> # SMALL
>   db_block_buffers = 550                                             
> # MEDIUM
> # db_block_buffers = 3200                                            
> # LARGE
> 
> #shared_pool_size =                            # INITIAL
> # shared_pool_size = 3500000                                         
> # SMALL
>   shared_pool_size = 6000000                                         
> # MEDIUM
> # shared_pool_size =10500000                                         
> # LARGE
> 
> log_checkpoint_interval = 10000
> 
> #processes =                                             # INITIAL
>   processes = 50                                                     
> # SMALL
> # processes = 100                                                    
> # MEDIUM
> # processes = 200                                                    
> # LARGE
> 
> #dml_locks =                                              # INITIAL
> # dml_locks = 100                                                    
> # SMALL
>   dml_locks = 200                                                    
> # MEDIUM
> # dml_locks = 500                                                    
> # LARGE
> 
> transactions = 40
> 
> global_names = true
> 
> open_links = 4
> 
> job_queue_processes = 2
> 
> job_queue_interval = 10
> 
> job_queue_keep_connections = false
> 
> #log_buffer =                                             # INITIAL
> # log_buffer = 8192                                                  
> # SMALL
>   log_buffer = 32768                                                 
> # MEDIUM
> # log_buffer = 163840                                                
> # LARGE
> 
> #sequence_cache_entries =                   # INITIAL
> # sequence_cache_entries = 10                                        
> # SMALL
>   sequence_cache_entries = 30                                        
> # MEDIUM
> # sequence_cache_entries = 100                                       
> # LARGE
> 
> #sequence_cache_hash_buckets =       # INITIAL
> # sequence_cache_hash_buckets = 10                                   
> # SMALL
>   sequence_cache_hash_buckets = 23                                   
> # MEDIUM
> # sequence_cache_hash_buckets = 89                                   
> # LARGE
> 
>   audit_trail = true            # if you want auditing
>   timed_statistics = true       # if you want timed statistics
>   max_dump_file_size = 10240      # limit trace file size to 5 Meg each
> 
>   log_archive_start = true      # if you want automatic archiving
>   log_archive_dest = h:\orant\test #log archive destination 
>   log_archive_format = 't%ts%s.arc' 
> 
> # define directories to store trace and alert files
>   background_dump_dest=H:\RDBMS73\trace
>   user_dump_dest=H:\RDBMS73\trace
> 
> db_block_size = 2048
> 
> snapshot_refresh_processes = 2
> 
> snapshot_refresh_interval = 60
> 
> snapshot_refresh_keep_connections = false
> 
> remote_login_passwordfile = shared
> 
> text_enable = true
> 
> bye
> ===
> Nagesh Pillarisetti

Back to Ari Kaplan's Home Page

Invalid status after successful run of procedure
Subject: Re: Invalid status after successful run of procedure
Newsgroups: comp.databases.oracle.server
References: <33E7A5EB.5684@usa.net>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

Avinash Kumar (avinash_kumar@usa.net) wrote:
: Hello everybody,
: 
: I have procedure, which gets invalid after a successful run
: i.e. desc procedure_name   --  shows status invalid.
: 
: The procedure first drops an existing view and then immediately
: creates the view using dbms_sql and later uses the newly created
: view.
: The procedure runs fine, except that it gets invalid after successful
: run. Every object that it uses is still valid. Surprisingly,
: doing an  " alter procedure p_name compile " sets it fine again.
: Any suggestions why ?
: 
: Thanks in advance,
: 
: Avinash Kumar

Avinash,

What is happening is that while the procedure runs, it is dropping an
existing view. At that point, Oracle marks the procedure as invalid, since
it references the view that was dropped. Creating the view again does not
re-validate the procedure.

You should look at the DBA_DEPENDENCIES view for a list of all objects
that the procedure "depend" on. If any of these objects are dropped or
become invalid, then your stored procedure will also become invalid.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

NT vs. NetWare performance

-----Original Message-----
From:	Ronald L. Perrett [mailto:rperrett@nacs.net]
Sent:	Thursday, August 06, 1998 2:10 AM
To:	akaplan@interaccess.com
Subject:	Platform Choice

Electronic greetings, and may I say your bevy of Oracle "stuff" is
excellent!

I must offer ongoing technical consulting to users of our company's
software.  My fantisy is 3 guru's (one each Novell, Microsoft, Oracle)
locked into a well provisioned test lab with no hope of escape until
meaningful answers were agreed upon... to ponder the NT vs NetWare
Oracle Server question:  i.e.) 2 identical machine configurations,
dedicated only to Oracle service...  one on Oracle for NetWare, the
other Oracle for NT.

Q: is one offering better than the other in performance or reliability?
If so, in what way/s?  Is there perhaps some treasured document or
Shoot-Out technocratic information bulletin available that you might
know of?

We could let the HP rep unlock the door and announce the results.  I
look forward to hearing from you at your convenience.

Thanks again for an informative site!
rperrett@nacs.net

---------- Reply ------------
Hi Ronald,

There are plenty of whitepapers comparing technical performance on various
operating systems on both www.oracle.com and www.orafaq.com. As for myself, I
am partial to Windows NT (I just completed the upcoming book "NT5: The Next
Revolution"). If you are a large enterprise with many domains (offices around
the world) I recommend Novell for now, but for its networking features and not
Oracle handling.

Regardless, if you go with NT4, NT5 will be out soon which will blow the socks
off of Novell, so it's worth going to NT4 and upgrading to NT5 in 8 months.
Also, all 3rd-party software vendors support NT and not all support Novell, so
you have additional products available with NT.

As for performance, I believe NT can scale to more processors (4) , and NT5
will be able to scale to 8 initially and 16 in about a year. This will help
with parallel queries as well as supporting a larger number of users while
maintaining a decent performance. For a more technical comparison, check out
some of those whitepapers.

Hope this helps,

-Ari

Back to Ari Kaplan's Home Page

Import/Export and INITIAL extent sizes

-----Original Message-----
From:	joachim.uppenberg@seinf.mail.abb.com [mailto:joachim.uppenberg@seinf.mail.abb.com]
Sent:	Friday, August 07, 1998 8:49 AM
To:	akaplan@interaccess.com
Subject:	Import tables with smaller initial extent info

Hey,  you seems to be a Hero in der Oracle gebit.
Here is a tricky one. Oracle version 7.3.4

How to import tabels without the data and the initial extent information.
I don't want huge tables with no data. Iwant small ones with no data.

I think I have tried every possible option on the import and export
command.
I have managed to get huge tables without data. But how to shrink'em.

If it's not possible with the imp/exp utility do you know some workaround.
Please, help.


regards
//Joachim

----------- Reply ----------------

Joachim,

There are a few things you can do for your imp/exp question. First, you can
export with COMPRESS=N. By default, COMPRESS=Y, which takes all of your tables
add combines all extents into one big extent. However, your imported tables will
still be the size of each INITIAL extent from when it was exported.

So, if your original INITIAL extent sizes are too big for the empty tables, you
will have to go outside of export/import. The easiest way is to use a
third-party tool such as Platinum's TSREORG. You can change the INITIAL/NEXT
pretty much on the fly.

If you do not have a third-party tool for this, then you will have to drop and
recreate each table with smaller extents. This is a pain because you also have
to recreate indexes, triggers, constraints, comments, and grants, as well as
recompiling procedures/packages. You can either reverse-engineer the CREATE
statements with an ER tool. The other way to do it is "IMP username/password
SHOW=Y LOG=create_all.sql", which will generate all CREATE statements into the
"create_all.sql" file. The only problem is that Oracle cuts lines in half and
adds quotation marks, etc. You will then also have to modify the INITIAL extent
of each CREATE statement to the size you desire. The advantage of using IMP to
do this is that it also generates the GRANTs and constraints. I've done it
before and it's work, but it does the job.

Best of luck,

-Ari Kaplan
akaplan@interaccess.com
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Password after installation???
Subject: Re: Password after installation???
Newsgroups: comp.databases.oracle.server
References: <33EB217F.6A51@antwerpes.de>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com

Dirk Pogrzeba (dirk@antwerpes.de) wrote:
: I downloaded Oracle 7 Server (140MB via WWW - puh!) and 
: installed it. After the installation I tried to start the
: enterprise manager and was I asked for a password I didn't 
: define during the installation. So - what's that? I cannot 
: open my software bacause of some password someone else created.
: 
: I couldn't find anything about such a default log-in in the 
: documentation.
: 
: Please help me with the following information:
: 
: - What user id and password must be typed in to log in?
: - What service must be typed in?
: 
: Regards,
: 
: Dirk Pogrzeba

The default usernames and passwords (which should be in the documentation)
are:

SYS		change_on_install
SYSTEM		manager
SCOTT		tiger

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Setting large storage parameters
-----Original Message-----
From:	smurthy@venatorgroup.com [mailto:smurthy@venatorgroup.com]
Sent:	Tuesday, August 11, 1998 2:58 PM
To:	akaplan@interaccess.com
Subject:	Initial, next, min and max extents

Mr. Kaplan,
You have been a tremendous help to almost all DBAs.  I have request for
you.  Hope you can give us light ASAP.

We have a tablespace that is 18GB in size.  It has several tables.  Some of
the tables are growing very quickly to 5GB and even the Index is also
growing to 5GB.  In this situation, to have efficient performance  and less
fragmentation what should be the storage parameters for these large
tables..  Row size for one table is 52, approximate rows are 10 Million.
Row size for the second table is 101, approximate number of rows are 33
million.  There are some smaller as well as medium sized tables also in the
same tablespace.  If you can suggest the storage parameters for the above
two tables I would greately appreciate.

Table 1     -  Total number of rows   10 Million, row length is 52.
Table 2    -   Total number of rows   33 Million, row length is 52.
Tables are growing and growing everyday.  Tables are not created in
parallel.  Oracle Version 7.3.3 running on IBM RS6000/AIX.

Thanks,
Sita K. Murthy.


-------------- Reply --------------------
Sita,

What you need depends on two other factors:
1) What is your db_block_size?
2) What is the table usage? Is it mostly inserts, updates, deletes, and/or
   selects?

The amount of updates (or the combination of deletes and inserts) whereby the
size of the row changes should determine the PCTFREE/PCTUSED.
The INIT/NEXT should be determinant on this answer in conjunction with the
db_block_size. Also, you want to size the table for expected future growth. Do
you want to prepare for 6 months of growth? 1 year?

You can see how large your tables are:

SELECT SUM(BYTES)/1024/1024 MEGS
FROM USER_EXTENTS
WHERE SEGMENT_NAME = 'table_name':

This will give you the current total size allocated for the table.

Assuming that the records are not updated, or deleted often, I'll assume a
PCTUSED 90, PCTFREE 10. Also, I'll assume an 8K block size. So, for both table
1 and table 2, each block would contain about 120 records. Table 1 has 10
million rows, so it should be 10 million / 120 = 83,333 blocks. This comes out
to 651 Megs. Table 2 has 33 million records, and is thus 3.3 times the size,
and should be 2.148 gigabytes.

Remember, adjust this according to #1 and #2 above.

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Moving Datafiles
Subject: Re: Moving Datafiles
Newsgroups: comp.databases.oracle.server
References: <01bc9a4a$b0499140$990548a6@37055.NAC.PW.COM> <01bc9b28$b6868e80$741337a6@hercules> <33F1359D.96255D2C@cyberway.com.sg>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

John Li (johnli@cyberway.com.sg) wrote:
: Is it possible to recreate the control file with the new locations of
: the data files?
: 
: ie. after connecting as internal, run "alter database backup controlfile
: to trace". This will create a .trc file in the log directory. Can I then
: edit this file after moving the data file/s and then use this file to
: recreate the control file?
: 
: I have only tried this method to increate the value of maxdatafiles but
: not to relocate datafiles and I've always wonder whether it can be done
: that way.
: 
: John

Yes, this is one of the best features of the "create controlfile" script.
Simply modify the locations of the datafiles and run the script. I have
done this many times.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 100+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Getting ROWID information
-----Original Message-----
From:	Faranak Z. [mailto:faranak@egeporcan.com.tr]
Sent:	Thursday, August 13, 1998 7:57 AM
To:	akaplan@interaccess.com
Subject:	HOW TO RETRIVE ROWID

Dear Ari,
I'm a Computer Engineer. I'm new at Oracle and Developer/2000. I have a
master/detail block in developer/2000 1.5. I want to use ROWID of any
record in the master block and update the related detail data in the detail
block (I want to use that ROWID as a unique number in my detail table). 
My problem is that I don't know how to retrive the ROWID of any specific
record.
Any help from you will be highly appreciated. 

Best regards,

PS: By the way I found your web page very useful....
Faranak Z.

-----Reply--------------
Farank,

If you have a table like the following:

SERVICE
NAME		VARCHAR2(30),
STATUS	VARCHAR2(30)

To get the ROWID with each row, type:

SELECT ROWID, NAME, STATUS FROM SERVICE;

The result will include the ROWID, which will look like:
ROWID				NAME			STATUS
_____________________	_______________	________
AAAAkmAAFAAADm/AAK	PIN Service Object	10100

AAAAkmAAFAAADnAAAA	PIN Service Object	10100

AAAAkmAAFAAADnAAAB	PIN Service Object	10100


In Oracle7, the ROWIDs look different. If you have Oracle8, you can look into the DBMS_ROWID package to convert to Oracle7 format.

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

What is the BECOME USER privilege?
-----Original Message-----
From:	Devinder Pal Singh [mailto:Devinder_Pal.Singh@pharma.novartis.com]
Sent:	Tuesday, July 07, 1998 3:27 PM
To:	akaplan@interaccess.com
Subject:	becoming another user

Hi Ari,
The dba role has one system privilege, 'becoming another user', can you
give me some insight as to how this thing works.
Thanks in advance.
Devinder

-----Reply------
The "BECOME USER" is used when you use the Export and Import utilities. It is a mandatory privilege for when you export from one user schema and import it into another schema.

Regards,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

BECOME USER privilege; rename a column; row chaining/migration
Mr. Kumar,

I will answer each question below:

> We have read a privilege called 'Become User' in your 
> 'Oracle 8.0 How To' hand book. But we are not able to use this 
> privilege. Kindly let us know more detail about this command and
> how to use it?.

The "BECOME USER" is used when you use the Export and Import utilities. It is a mandatory privilege for when you export from one user schema and import it into another schema.

> And also we would like to rename the column in the existing tables
> with out copying to the another table. Is it possible ? How?.

You cannot do this. You MUST create another temporary table if you wish to
maintain any data, drop the original table, create it with the new column name,
and then copy the data back from the temporary temp. When I say temporary I mean
a regular table that exists only for the exercise of renaming columns. The other
alternative is to use the third-party tool such as Platinum's TSReorg.

> What is row chaining and migration of rows?

Row chaining is when one record is stored in two or more physical data blocks.
For example, if you have a record with a LONG column that takes up 10K and the
db_block_size is 4K, this one record will span 3 physical database blocks.

> Kindly acknowledge and send email.
> Thanking you.
> regards.
S.KISHORE KUMAR

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Performance of a procedure

-----Original Message-----
Dear Akaplan,
I have a processing program which will use to run a large range of 
records. This process including insert,delete ,update and select the 
various tables. 
	
Initially, I put the procedure in a program itself, I find it is very time 
consuming and take long long time to complete. Later, I extract a 
procedure into a stored procedure. It seems that, the performance 
is still the same.

Please help me.

Thanks in advance.

Regards

CKWAN (Malaysia)

----------------------------------------------------------------
CL COMPUTERS (M) SDN. BHD.  [Reg. No. 145416W]
Lot 401, Box No.13, 3rd Floor, Wisma Penchala,          
50, Jalan Penchala, 46050 Petaling Jaya, Malaysia.
Tel : 603-7930700    Fax : 603-7930708            
----------------------------------------------------------------

----- Reply ------------
There is not much specific advice I can give you, because your program and
database may be set up in many ways. What you should do is look at the program,
and then run an "Explain Plan" on each SQL statement. It could be that you have
bad SQL or are missing an index that should be there. Aside from that, if you
are running in Cost-Based Optimizer mode, make sure that your statistics are
current. You can do this with:

EXECUTE DBMS_UTILITY.ANALYZE_SCHEMA.('SCHEMA_NAME','ESTIMATE');

Insert the Schema that you wish to gather statistics for SCHEMA_NAME above.

If you still have problems, then you should do a wider database tuning. There
are countless books that cover this topic, or you can hire a consultant to look
at your system ;)

Best of luck,

-Ari

Back to Ari Kaplan's Home Page

The difference between a row and ROWID

-----Original Message-----
From:	manish [mailto:m_chavan@hotmail.com]
Sent:	Friday, August 14, 1998 6:49 PM
To:	akaplan@interaccess.com
Subject:	dba_stuff

Ari,
	i have recently taken the job of a DBA for our project. I am not so
knowlegeble about the dba stuff .
	can u please tell me the difference between a row and row id. What are
row pieces ? please site an example to clarify it ?
Regards 
amaresh.
email: amr38974@trishul.icil.co.in

-------Reply------------------------
A row specifies one "record" of data. Suppose there is a table:

EMPLOYEES:
-------------------
EMP_ID		NUMBER,
LAST_NAME		VARCHAR2(40),
FIRST_NAME		VARCHAR2(40),
DEPT_NO		NUMBER

The table contains many rows ("records"), such as the following:

SELECT EMPID, LAST_NAME, FIRST_NAME, DEPT_NO FROM EMPLOYEES;

EMPID		LAST_NAME	FIRST_NAME	DEPT_NO
---------		------------------	-------------------	---------------
123123		KAPLAN	ARI		201
123124		KAPLAN	TODD		201
123125		SMITH		JOHN		203
12126		PARKER	FRANCIS	803

In Oracle there is a Pseudo-column called ROWID that is used by the Oracle
engine to define the file, block, and record within the block.
You can see it with:

SELECT ROWID, EMPID, LAST_NAME, FIRST_NAME, DEPT_NO FROM EMPLOYEES;

For more information, read up on the DBMS_ROWID package. As for a row piece, I
believe this is when a row is stored in more than one database block. Each
portion of the row is called a "row piece".

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

DBA responsibilities
-----Original Message-----
From:	Philippe Hamel [mailto:hamelph@videotron.ca]
Sent:	Friday, August 14, 1998 8:33 AM
To:	akaplan@interaccess.com
Subject:	Career move

 Good morning Mr. Kaplan.  Sorry to disturb you but I have a question.  I'm
trying to find out as much as I can about the duties of a DBA.  I'm
currently applying for a position as a C/C++ programmer but the HR guy at
the company is trying to sell me on the idea of becoming a junior DBA. (I
guess they're hard up)  I wonder if I'd be as happy doing the work of a DBA
as I am programming.  I've checked http://www.orafaq.org/faqdbacv.htm but
I'd like more details if possible.  From my snooping around, I seem to
understand that there is some sort of programming involved to tweak and
improve the DB and create/link applications for/to the DB.

Thank you for your time.  Any help would be greatly appreciated.

Regards,

Philippe Hamel
Courriel 1 : philippe.hamel@apiiq.qc.ca
Courriel 2 : hamelph@videotron.ca
WWW : http://pages.infinit.net/hamelph

------- Reply -----------------------
The page at "http://www.orafaq.org/faqdbacv.htm" had the following to say:



DBA Responsibilities:

* Installation, configuration and upgrading of Oracle server software and related products 
* Evaluate Oracle features and Oracle related products 
* Establish and maintain sound backup and recovery policies and procedures 
* Take care of the Database design and implementation 
* Implement and maintain database security (create and maintain users and roles, assign priveledges) 
* Do database tuning and performance monitoring 
* Do application tuning and performance monitoring 
* Setup and maintain documentation and standards 
* Plan growth and changes (capasity planning) 
* Work as part of a team and provide 7x24 support when required 
* Do general technical trouble shooting and give consultation to development teams 
* Interface with Oracle Corporation for technical support. 

This is a pretty accurate description of Oracle DBA duties. The programming comes into play with the backup and recovery scripts. As for tuning, this is a huge thing in itself, and may contain programming responsibilities. Overall, a good knowledge of SQL is required. For a great discussion on this, see "Oracle8: A Beginners Guide" by Oracle Press.

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Searching for the asterisk (*) in a string
-----Original Message-----
From:	Matt Watson [mailto:loren@purdue.edu]
Sent:	Friday, August 14, 1998 4:30 PM
To:	akaplan@interaccess.com
Subject:	access database SQL question

I'm trying to use the like command in a query to distinguish between
variables where the only difference is an * at the beginning.  Normally
this wouldn't be a problem but in Access the * is the wildcard.  I
assume there is some kind of sytax, such as backslashes or underscores
that will make * actually mean * instead of wildcard when using 'like'.
Would you happen to know how to achieve this?

Thanks,
Matt Watson
PC Network Support Tech.
Wellman Thermal Systems, Corp.


---- Reply -----------------
In SQL*Plus, you need to set the Escape value. It can be whatever you want. Look at the following example:

SQL> SET ESCAPE ^

SQL> SELECT '^%' FROM DUAL;

%

1 row selected.

SQL> SELECT * FROM TABLE_A WHERE COLUMN_A LIKE '^*HELLO';

*HELLO

1 row selected

SQL>

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

NUM_ROWS statistic incorrect
> 
> Ari,
> 
> I "stumbled" on your website and found much useful information.  Thanks
> for the time and effort .... the site is great.  I have a question of my own
> that I hope you will be kind enough to answer:
> 
> We run Oracle 7.2.2.4 on HP-UX 10.20.  I queried user_tables logged on
> to SQL*Plus as the user who owned the tables I wanted to look at.  In the
> field num_rows a value was returned that in many cases differed from
> the number of rows I would get by directly querying the specific table
> with the "select count(*) from tablename" query.  Can you explain the
> descrepancy?  My email address is hkaufman@co.new-castle.de.us. 
> Thanks.
> 
Harry,

Thanks for giving the positive feedback on my web page. I do not get money from it, but do it to help ther Oracle community in general.

The reason that you are getting a different number in the NUM_ROWS column in
the USER_TABLES (or ALL_TABLES or DBA_TABLES) views than the actual value
is that NUM_ROWS is updated only when you analyze the table.

For example, if your table has 1000 records and you issue:

ANALYZE TABLE table_name COMPUTE STATISTICS;

The NUM_ROWS column at that point will be 1000.

At this point, if you insert 1000000 records, and do NOT analyze the table
again, you will have 1100000 records, but NUM_ROWS will still be 1000.


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

SERVEROUTPUT is limiting me from looping in PL/SQL
Hi,
     Could u please suggest how to resolve this problem.
I was opening cursor with 10,000 record and looping. Initially i could able
to loop only 1000 records. Then i added
set serveroutput on size 1000000 because of that i could able to loop 3000
records. what could be the reason ?
Thanks 
Jagadesh

-------------------------- Reply ---------------------
Jagadesh,

The SERVEROUTPUT controls how large the buffer for displaying the results of
a PL/SQL routine is. Before you set it, it was taking the default size, which
could only show your 1,000. Now with the new size, it can show 3000 records.

It all has to do with the functionality of the SERVEROUTPUT. There is an
upper limit that you will hit, so if you need more than that you can use the
UTL_FILE built-in package to spool your output to a file from within Oracle.
With UTL_FILE, the size of the output is limited only by your hardware.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 200+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How can I find out who is currently using the DB?

Newsgroups: comp.databases.oracle
Subject: Re: How can I find out who is currently using the DB?
References: <4vhvp7$68a@huitzilo.tezcat.com>

dosa@tezcat.com (**Kim Dosa**) writes:

>This is a very simple question.
>But how can I find out who is currently using Oracle DB?
>Thanks,
>ben.

>-- 
>***************************************************************
>*	Byungsoo Ben Kim	    United Stationers, Inc.    *
>*	(847) 699-5000 Ext) 2984    Database Analysis	       *
>*	E-mail		            dosa@tezcat.com	       *
>***************************************************************

Ben,

There are several ways to find who is using the database:
1) SELECT * FROM sys.v$session;
   This is the best table for what you probably are looking for. It 
includes schema user name, OS username, OS machine name, OS terminal 
name, ORACLE username, etc.
   For ease of reading, you can enter:
   SELECT username FROM v$session;

2) SELECT * FROM sys.v$process;
   This table shows the processes, usernames, OS terminal identifier, etc.

3) If in UNIX, you can type:

   ps -ef |grep {ORACLE_SID}

  This option lists the processes, and may not be all-inclusive if
   users are logging on through SQL*Net, Tuxedo, or other TP's.

Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Creating two instances on the same server
-----Original Message-----
From:	Marcelo Feldman [mailto:Marcelo_Feldman@metrogas.com]
Sent:	Monday, August 24, 1998 3:56 PM
To:	akaplan@interaccess.com
Subject:	Databases creation

We want to know how we can create two databases in the same server. We want
      to create each databases with one instance.
      The server Operating System is Windows NT and the Oracle version is
      7.3.4.0.
      Other issue, could the instances run at the same time? and,  ,how can
      we access to the instance from the server manager?.

      Thank you for your help. We are looking forward to your answer.



-----Reply Message---------
You will need to get familiar with OFA: Optimal Flexible Architecture.
Basically, you need to keep the directories of each database separate. For
example, assume you have drives /u01, /u02, and /u03, and databases db1 and db2.
You should keep the Oracle datafiles and redo logs in

/u01/oradata/db1
/u01/oradata/db2
/u02/oradata/db1
/u02/oradata/db2
/u03/oradata/db1
/u03/oradata/db2

Also keep your $ORACLE_BASE/admin/db1/bdump, cdump, udump, etc. directories
separate from $ORACLE_BASE/admin/db2/bdump, cdump, udump, etc.

In UNIX you would need to specify separate ORACLE_SID environment variables. In
NT I don't recall which variable keeps track of this. Also, use SQL*Net easy
config to add your new database to your sqlnet.ora, listener.ora, and
tnsnames.ora.

Basically, yes you can have multiple databases on the same server. For Server
Manager, you can enter the connect string to specify which database to connect
to. "db1" or "db2".

Best of luck!

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Extents, Blocks, etc. - can anyone point me to help?
Extents, Blocks, etc. - can anyone point me to help?
Newsgroups: comp.databases.oracle.server
References: <3401FF3C.64F@utopia.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Simon,

A great explanation is in the Oracle "Concepts Guide". Basically, a table
(or index or cluster) is stored within a tablespace. A tablespace is a
collection of one or more datafiles, which are physical files on the
computer's disks. To find which tablespaces you have, type:

SELECT TABLESPACE_NAME FROM DBA_TABLESPACES;

To find out which data files you have (and their locations), type:

SELECT FILE_NAME, TABLESPACE_NAME, BLOCKS FROM DBA_DATA_FILES;

The "BLOCKS" column in the DBA_DATA_FILES shows how large the data file is
in BLOCKS. How many bytes the BLOCKS have depends on how the database was
created. To find out, type:

SELECT VALUE FROM V$PARAMETER WHERE NAME = 'db_block_size';

Within each BLOCK is header information, actual data, and space reserved
for data growth. A table is made up of several blocks. For instance, if a
table is 40k in size, and a block is 4k in size, this means that a table
is stored in 10 blocks.

Extents are simply a portion of a table (or index or cluster). The reason
they are important is that Oracle pre-allocates tables/indexes/clusters.
For example, when you create a table, you tell Oracle that initially 40K
should be allocated for the table. Oracle will create the table, grabbing
40K (10 blocks in length for a 4k block size). Even if there is one record
in the table, 40k will be allocated. The more records you add, the more of
the 40k will be filled. Once 40k worth of data is in the table, Oracle
grabs another EXTENT and reserves it for exclusive use by the table. The
size of this next extent may be different than the size of the first
extent.

Hope this helped!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Simon Rakov (srakov@utopia.com) wrote:
: Hi,
: 
: I've had a lot of trouble lately with Oracle extents and blocks. None of
: the books I've seen on the subject seem to make any sense to me.  Can
: anyone point me to a good one, or to an FAQ about the topic?  What are
: extents, how do they work, what do they do; what are blocks, what size
: are they, and how does one manage tables that are running into their
: maximum number of extents?  How do table extents differ from tablespace
: extents?  Where are they related?
: 
: You can see that I'm a little confused.  Any help would be greatly
: appreciated, particularly help that would point me to a resource that
: would explain all of this.  I've tried "Oracle Unleashed," "The Oracle
: DBA Survival Guide" and "Tuning PL/SQL" all to no avail, although the
: "DBA Survival Guide" is a good book.  It's just not explaining things
: simply enough.
: 
: Thanks very much for any information.
: 
: yours,
: Simon Rakov
: USWeb Utopia

Back to Ari Kaplan's Home Page

export table a 10 gig table
Subject: Re: export table a 10 gig table
Newsgroups: comp.databases.oracle.server
References: <340315A7.6987@erols.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

tenghsu (tenghsu@erols.com) wrote:
: Hi,
: 
: How can I export a 10 gig table when the max UNIX file size is 2 gig?
: Thanks.
: Tenghsu

If you have Oracle8, you can partition the table and export each partition
individually. Otherwise, check out the tip from Oramag (http://www.oramag.com/code/tip01168.htm):


TIP OF THE WEEK

January 16, 1998 


Exporting a Database That's More Than
2GB When Compressed

This Tip of the Week entry comes from Devarajan Sundaravaradan, a Senior
Consultant for Leading Edge Systems, Inc. in Edison, New Jersey. 

In HP-UX, there is a 2GB limit on file sizes of 2GB. Many of us have reached
this limit when exporting files and the most common solution is to do a filesystem
compression of the export dump using named pipes and then store the compressed
file. But what if the compressed file itself passes the 2GB limit? There is solution
to this, too. 





---------------- Export Section

# Create new Named pipes.

mknod -p /dev/split_pipe

mknod -p /dev/compress_pipe    # You can use the existing named pipe 
                          # itself, instead of creating new.

======================================================================
Create a shell script under a file, named Split_export.sh
======================================================================

# -b1000m indicates to split command to split the input file into every 1000 MB size. 

# As it splits, the split command will suffix aa, ab, ac, ad ... upto zz to the file name specified.

# The export file name is expfile.

nohup split -b1000m < /dev/split_pipe > /DumpDir/expfile & 

nohup compress < /dev/compress_pipe > /dev/split_pipe &

exp username/password full=y file=/dev/compress_pipe and other parameters for export.

=======================================================================
After saving the above three commands in split_export.sh, execute the following.
=======================================================================

chmod a+x split_export.sh

nohup split_export.sh > /tmp/split_export.log 1>&2 &

=======================================================================
After a few minutes you should see files in the export dump directory.
=======================================================================


------------------ IMPORT Section

======================================================================
Create a shell script with the following command under the file name split_import.sh.

After creating provide execution permission to this script as follows: 
======================================================================

Chmod a+x split_import.sh

# The import script assumes in this example that the above export script created 2 split files  

# called expfileaa and expfileab. The order of the file for the cat command is very important.

nohup cat /dumpdir/expfileaa /dumpdir/expfileab > /dev/split_pipe & 

# sleep 3 seconds

Sleep 3

nohup uncompress < /dev/split_pipe > /dev/compress_pipe &

#Sleep at this point is very important as some time is needed to uncompress the file and send it to the pipe.

sleep 60

imp username/password file=/dev/compress_pipe and other parameters for export.

nohup split_import.sh > /tmp/split_import.log 1>&2 &

=======================================================================
Wait for the import to finish.
=======================================================================

Back to Ari Kaplan's Home Page

Finding the "NEXT" and "PREVIOUS" records in a table
-----Original Message-----
Ari,

A while ago I asked your help with embedded C programming and you were
kind enough to reply with a very helpful answer. At the risk of going
once to often to the well, I'd like to ask another, more complicated
question. After scouring the literature, I haven't been able to find a
reliable answer to this.

We are converting a large legacy application to Oracle, and the first
stage (we've determined) is to write an emulator for the existing
database calls. Later, at our leasure, we will convert each module (out
of  nearly 1000) directly to Oracle. One of the old database calls is a
routine that returns the row (record) which is exactly next in logical
key order to a given key.

I have attempted to formalize the problem as shown below. If you have
any ideas or suggestions for study I'd be very grateful.

Bion

bions@usa.net


PROBLEM: Retrieve the NEXT key (step through an index/primary key
row-by-row)

STATEMENT: Given a table with a multiple-column primary key, say,
columns A, B and C taken in that order, is there a way (efficiently,
which presumably rules out cursors) to retrieve the single NEXT row in
key order after a specified key? That is, construct some kind of select
statement with the specific column values A1, B1 and C1, and get in
return just the one row with the key X, Y, Z which is the NEXT logical
key after A1, B1, C1. (NEXT logical would be defined as ((X = A1 and Y =
B1 and Z >> C1) OR (X = A1 and Y >> B1) OR (X >> A1)) where the symbol
>> means the least value greater than. Parsing (and/or row selection) is
assumed to go from left to right and to stop at the first instance when
the result is TRUE.

This can be done in a klugey way with cursors, however, cursors require
Oracle to manipulate lots of rows, and in this application we often want
only one row. Cursors (and arrays) would seem to be very inefficient.
The application requires the equivalent of "stepping through" an index,
row by row, similar to this:

     SET KEY TO starting_key;
    WHILE(not_done) {
                ROW = row_with_next_key_after(KEY);
                 process(ROW)
                KEY = key_of(ROW);
                 }

------------- Reply -------------
It never hurts to ask. I get about 10 questions a day and can usually have time
to answer 2-3. If you ever get a "sorry, I'm too busy" message you'll understand
why.

As for your question, my first thought was using cursors for greater control.
For example, you can use the IF-THEN-ELSE clauses which would be helpful for
finding the next value.
Aside from cursors, you can add a column that has the NEXT key along with each
key. This way you can use Oracle's heirarchy SQL statements (PRIOR, NEXT, and
so on). If you are not familiar with these commands, there are explanations
wherever you read about the EXPLAIN PLAN options. They can even be used to
generate a visual tree structure. You are probably looking for something
simpler for your needs, so this should be sufficient.

Best of luck,

-Ari Kaplan

Back to Ari Kaplan's Home Page

SQL question: Views

blair  writes:

>Is there any way to construct a view in SQLplus with derived columns
>where you get to determine the length of the datatype. It seems
>that in the construction of our view our dervied columns are being
>set as varchar2(2000). However our columns only use up 10 spaces. 
>We get a problem with buffer overflow, and we don't want to reduce 
>arraysize and we are operating on Oracle7 so MAXDATA doesn't make 
>any differenc.
>Any Answers
>Blair

Blair,

There is a way to do this. Suppose the base table is as follows:

desc TEST_TABLE;
A    VARCHAR2(10),
B    VARCHAR2(2000),
C    VARCHAR2(2000)

To create a view where each column is length 10, do the following:

CREATE VIEW test_view AS
SELECT a, SUBSTR(b,1,10) B, SUBSTR(c,1,10) C
FROM test_table;

This will create a three-column table with types VARCHAR2(10).
Be sure to include column aliases in the view to correspond with the base 
table's column names.

Good luck.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Copying data among tables
-----Original Message-----
Subject:	Oracle problem

Dear Mr. Akaplan,
    Hi, How are you doing? I wonder how do you copy the data from one
table to another using Oracle 8.0.4 . Thank you!

Yours faithfully,
Kinny


----------------- Reply -------------------
Kinny,

Assume you have TABLE_A with data, and TABLE_B without data:
TABLE_A
--------------
NAME		VARCHAR2(50)
ADDRESS	VARCHAR2(50)
CITY		VARCHAR2(30)
STATE		CHAR(2)
PHONE		VARCHAR2(20)

TABLE_B
--------------
NAME		VARCHAR2(50)
PHONE		VARCHAR2(20)

To get the name and phone information from TABLE_A to TABLE_B, issue the following SQL:

INSERT INTO TABLE_B (NAME, PHONE) SELECT NAME, PHONE FROM TABLE_A;

Best regards,

-Ari Kaplan


Back to Ari Kaplan's Home Page

How to set default initial extent when creating new table
Subject: Re: How to set default initial extent when creating new table
Newsgroups: comp.databases.oracle.server
References: <5u50dq$3te$1@news.minn.net>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

dtang@minn.net wrote:
: Hi:
: I  get a probelm about Oracle V8 on NT. When Oracle creates new table
: , if initial size of extent is not specified, ORACLE sets initial
: exetent to  1M. It will waste a lot space for a small temporary table.
: But the intance's  db_block_size = 8k. How to set default initial size
: of extent.
: 
: Please e-mail me at dtang@minn.net
Dong,

What you need to do is alter the DEFAULT storage parameters for the tablespace that
the table is created. If you do not specify storage clauses when a table is created,
Oracle looks at the defaults for the tablespace. You can type something similar to:

ALTER TABLESPACE USER_DATA DEFAULT STORAGE (INITIAL 10K NEXT 5K);

Good luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

When is it unsafe to IMPORT data in DIRECT mode? How to drop a database? What is the ConText option?
> Hi Ari,

>  This site is great. Your answers are very clear for all levels. Can you
> please answer couple of questions.


> 1) Threre is an option in IMPORT call DIRECT. Book says, if we use this
> command it skips BUFFER parameter and it also improves performance.
>    Now i do lots of Export and Import is it always safe to use DIRECT.
> Can you please put some light on this.


According to the Oracle documentation: "Direct path Export cannot be used to
export data from tables that contain column types that were introduced in
Oracle8. Those column types are REF, LOB, BFILE, or object type columns (which
include VARRAYs and nested tables). If a table contains any of these objects,
only the table definition is exported, not the data, and a warning message is
given. "

Also, you can't use the interactive mode of Export/Import with DIRECT mode. This
is the set of prompts for you to enter username/password, T>able, F>ull, O>wner,
and so on.


> 2) I want to drop my database and re-build from export file. When i
> Issue drop database db_name. Database is not dropping. Why?

This is because "DROP DATABASE db_name" is not a valid SQL statement. There is no SQL to destroy a database. If you want to remove a database, then shut it down and physically remove the datafiles, redo logs, and control files.


> 3) What is Oracle ConText Option. How it is used?


The ConText Option is used to creatively search through text for values. If
you've ever used a Web search-engine, it is similar to them. You can search for
keywords, using AND, OR, etc. conditions. You can also search for words with
similar meanings (Thesaurus), words with similar spellings (Dictionary), and so
on. There is a good chapter in "Special Edition: Using Oracle8" by Que that
describes how to use the ConText option.



> Thank you very much
> Sanjeev

My pleasure. Best of luck,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 205+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

EXPORTing from a higher Oracle version and IMPORTing into a lower Oracle version

-----Original Message-----
Hi ARI,

I guess I have a silly question for you ....

I had orginally created the tables in personal oracle 8 and now
I need to import the tables to oracle 7 installed in the server.

IS IMPORT TO A LOWER VERSION POSSIBLE FROM A HIGHER VERSION ?

THANKS IN ADVANCE......

gayatri

___________ Reply ___________________________________________

From what I have experienced, the only way to do it is shut down the database,
change the init.ora parameter COMPATIBILITY to the version you have in Oracle7,
start up the database, and do the export. Otherwise make a database link and do
many SQL statements in the Oracle7 database such as:

CREATE TABLE table_a AS SELECT * FROM table_a@ORACLE8DB;

Replace "ORACLE8DB with the name of the Oracle8 database.

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

How do you reset a sequence?

-----Original Message-----
Dear Mr.Akaplan,
    How are you? How do you re-set a sequence ie.initial value? Thank
you!

Best regards,
Kinny


-------- Reply -----------
Kinny,

Let's say that you create and increment a sequence:

SQL> CREATE SEQUENCE X;
Sequence created.
SQL> SELECT X.NEXTVAL FROM DUAL;
1
SQL> SELECT X.NEXTVAL FROM DUAL;
2
SQL> SELECT X.NEXTVAL FROM DUAL;
3
SQL> SELECT X.NEXTVAL FROM DUAL;
4
SQL> SELECT X.NEXTVAL FROM DUAL;
5

To reset the value:

SQL> alter sequence x increment by -4;
Sequence altered.
SQL> SELECT X.NEXTVAL FROM DUAL;
1
SQL> alter sequence x increment by 1;
Sequence altered.
SQL>

There you have it. By changing the INCREMENT BY clause, you can change the value
of the sequence to anything you want.

Best regards,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Running utlbstat and utlestat in a non-SYS account
-----Original Message-----
Ari, I have a question about running bstat and estat, Is there any reason
why you can't run these utilities with a different user instead of sys, as
long as that user has select on any table? I would like to create the begin
and end stat tables in a different tablespace besides the system tablespace.
Will doing this skew the report for estat?  I'm concern running these on
periodic basis using sys will 
fragment the system tablespace.

You wed site is great, there a lot of great tips!

Thanks
page.richard@mccg.org 

---- Reply -----------
Your assumptions are correct. You can use bstat and estat from any user account,
as long as they can see the v$ views and everything else that is used with bstat
/estat. It's a good idea; I never thought of doing it outside of the SYSTEM
tablespace myself.

Thanks for the comments.

-Ari

Back to Ari Kaplan's Home Page

SYSDATE - Time slow to update?

cwc@sound.net (Cary Coulter) writes:

>I am using SYSDATE like:

>	 TO_CHAR ( SYSDATE, ''Month DD, YYYY HH:MM AM')

>to format a date/time string.  The time doesn't update as it should.
>The time may be over an hour old at times.
<< posting cut here, will continue at bottom... >>


Cary,

You want to have:

TO_CHAR ( SYSDATE, 'Month DD, YYYY HH:MI AM')

Note that 'MM' is the month in a 01=JAN 02=FEB 03=MAR, etc format.
'MI' is the correct format for Minute.
The reason that the time wasn't changing was that what you thought was a 
MINUTE was the MONTH.

Hope this solves the problem.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


<>

>We are using Forms 4.5.  It doesn't seem to have anything to do with
>the time Forms was loaded, exiting all Oracle applications on the
>workstation (Win95) and re-loading them doesn't always change the
>date.  The server is on NT 3.51.

>Anybody seen anything like this??  Any ideas??

>TIA
>Cary

Back to Ari Kaplan's Home Page

ORACLE Import
Subject: Re: ORACLE Import
Newsgroups: comp.databases.oracle.misc
References: <5ujmnr$97f$1@news.enterprise.net>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

Oscar,

First, if the table already exists and you are using the IGNORE=Y clause of the import
command, then the default tablespace storage parameters will not be used.
Otherwise, it looks like the table will be 50k initial, 50k next. Since you are running
out of extents at 50, your table will be at least 50k*50 = 2.5M, if not more. So, change
the storage parameters to 3M initial 3M next and try again. You should create the table
with the appropriate size and no data, then import with IGNORE=Y

You can set the MAXEXTENTS to UNLIMITED if you have Oracle 7.2 or higher, but having lots
of extents is bad for performance and maintenance.

You could also export the table with the COMPRESS=Y option. That way, when you import the
table, the INITIAL extent will sufficient for the entire table.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Oscar Ssentoogo (impala@enterprise.net) wrote:
: 
: I am trying to import loads of records to an ORacle table but keep having
: the error (in .log file)
: ' ORA-01631: max # extents (50) reached in table TRAINS_DATA
: LOAD discontinued'
: 
: The maxextents parameter is set to 50  for this table. Can I set Maxextents
: to unlimited?
: 
: Is there a problem with the size of the table itself or INITIAL etc
: settings? What about PCTINCREASE?
: 
: Here is the create table statement:
: 
: CREATE TABLESPACE boxsheet
: 	DATAFILE '/oradata/boxt/box_data' size 100M
: 	DEFAULT STORAGE (
: 		INITIAL 50K
: 		NEXT 50K
: 		MINEXTENTS 2
: 		MAXEXTENTS 50
: 		PCTINCREASE 0)
: 	ONLINE;
: 
: Thanks
: 
: Oscar

Back to Ari Kaplan's Home Page

I can't describe a table that I know exists!
-----Original Message-----
Dear Ari:
        After importing a table from MS Access into ORACLE 8.0 through
ODBC, I can
see the table name exists by a "select table_name from user_table"
command. However
When I issue an "Desc tablename" for the new imported table, I encounter
a ORA-04043 :object company does not exist. And, "ORA-00942: table or
view does not exist" if a SELECT command is launched.

Please Help!

This is a nice Web site.

Bob Tsai

-------- Reply --------------
Sometimes ODBC will create lower-case table names. This gives the symptoms that
you describe: the table is in USER_TABLES, ALL_TABLES, DBA_TABLES, USER_SEGMENTS,
USER_EXTENTS, and so on. However, you cannot SELECT, DESCRIBE, or do other
commands against it.

To remedy this, you need to recreate the table with an upper-case table name, or
you will have to enclose your DML commands in double-quotes, such as:

SELECT * FROM "table_a";

DESCRIBE "table_a"

Best regards,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Finding duplicate rows in a table
Subject: Re: Finding duplicate rows in a table
Newsgroups: comp.databases.oracle.server
References: <34142F08.768F@worldnet.att.net>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

chris (x@worldnet.att.net) wrote:
: I don't know how, but when I try and copy one of my tables to another
: server across the net, I get a constraint violation on the primary key.
: How can I find the rows in the original table that have duplicate
: primary key information (the primay key consists of two columns).
: 
: chris
You are most likely getting the primary key constraint violation because:
1) You already have data in the table you are inserting into
2) You do not have a primary key in the remote table, and there are
duplicate values in it.

To see the duplicate records, follow the example below:

You are inserting records from TABLE B into TABLE A, and the primary key
on both tables is COLUMN A and COLUMN B. Issue the following query to
find thte duplicate records:

SELECT * FROM TABLE_B
WHERE (COLUMN_A||COLUMN_B) IN
      (SELECT COLUMN_A||COLUMN_B
       FROM TABLE_A);

To find if there are any duplicate values in TABLE_B alone (if there is a
primary key then there will be no duplicates) type the following:

SELECT COUNT(*), COLUMN_A, COLUMN_B
FROM TABLE_B
GROUP BY COLUMN_A, COLUMN_B
HAVING COUNT(*)>1;

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

How do I select the 1st, 500th, and 1000th rows - ROWNUM is not working!
-----Original Message-----
Hi Ari,
Iam a big fan of your homepage. Iam a oracle developer.I have a 
question, hope you would reply me.Thanks in advance for your time.
 Question :
  
  I have a table with 5000 records in it. I need to query the 1st,    
the 500th, and the 1000th rows. I tried using RowNum in a where clause,  
I tried the following query  :
 
 SELECT * FROM table_name
 WHERE ROWNUM=1 or ROWNUM=500 or ROWNUM=1000
 ORDER BY ordering_column;

 But the above query did not work. It is retrieving only 1st row and not 
showing 500th and 1000th rows.
Can you please help me in solving my problem.
Thank you,
Durga

______________________ Reply  ______________________________________________
(NOTE: See John Lennon's message after Ari's for another solution)

Your query is not working because of the nature of ROWNUM. The ROWNUM is really
a pseudo-column that Oracle generates each time the query is run for the RESULTS
of the query only, not the data in the table. Using it in a WHERE clause is
meaningful only if you have a LESS-THAN (<) clause, or you have WHERE ROWNUM=1,
or have ROWNUM=1 AND ROWNUM=2, and so on.

What you could do is make a PL/SQL routine. Open a cursor and use a variable as
a counter. Display the row only if the counter = 1, 500, or 1000.

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 205+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

______________________ John Lennon's Reply  _________________________________
SQL> desc member_list
 Name                            Null?    Type
 ------------------------------- -------- ----
 E_MAIL                                   VARCHAR2(50)
 NAME                                     VARCHAR2(50)

  I have a table with 5000 records in it. I need to query the 1st,
the 500th, and the 1000th rows. I tried using RowNum in a where clause.

select e_mail from (select rownum row_num, e_mail from member_list)
where row_num in (1,500,1000)

Regards
John
------------------------------------------
John C. Lennon
Database Consultants Inc.
7201 W Lake Mead Blvd, Suite 203
Las Vegas NV 89128
Tel: (702) 498 4990
Fax: (702) 871 4318
e-mail: johnlennon@ieee.org
Website: http://members.aol.com/jomarlen/

Back to Ari Kaplan's Home Page

Capturing SQL commands


chuckh@dvol.com (Chuck Hamilton) writes:

>Is there a way to capture users' SELECT commands for later analysis?
>--
>Chuck Hamilton
>chuckh@dvol.com

>This message delivered by electronic sled dogs. WOOF!

Chuck,

Very simple. While in SQL*Plus or SQL*DBA, and before typing the statements 
which you wish to capture, type:

SPOOL filename.lst

When you have finished typing the SELECT (or other) commands, type:

SPOOL OFF

Then you can view the "filename.lst" file.

Good luck.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Back to Ari Kaplan's Home Page

ORA-1658: Cannot create INITIAL extent in TEMP tablespace
-----Original Message-----
Hi Ari,

I'm trying to run Oracle Expert, but I'm getting the following error:

(image included)

Please help.

Regards
Marius de Beer
ATIO Corporation

---- Reply --------
You were getting the ORA-1658 error: unable to create INITIAL extent for segment
in tablespace TEMP.
This means that your TEMP tablespace is too small/fragmented or your default
storage parameters for the TEMP tablespace is too large.

1) To see the size of TEMP:

SELECT * FROM DBA_DATA_FILES WHERE TABLESPACE_NAME = 'TEMP';

2) To see the default storage of TEMP:

SELECT * FROM DBA_TABLESPACES WHERE TABLESPACE_NAME = 'TEMP';

3) To see fragmentation of TEMP:

SELECT * FROM DBA_FREE_SPACE WHERE TABLESPACE_NAME = 'TEMP';

If there are many "FREE SPACE"s then you can try coalescing the contiguous free
space:

ALTER TABLESPACE TEMP COALESCE;

Try #3 again to see if the number of "FREE SPACE"s has been reduced.

Also, if the size of the INITIAL EXTENT in #2 is greater than the size of the
smallest datafile in #1, then you can either decrease the INITIAL size or
increase the tablespace size. To decrease the INITIAL:

ALTER TABLESPACE TEMP STORAGE (INITIAL 2M);

(or replace 2M with what is appropriate)

To increate the tablespace size:

ALTER TABLESPACE TEMP ADD DATAFILE '/u01/oradata/DB/temp02.dbf' SIZ E 500M;

You will have to specify the correct path and size.

Best of luck,

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

DELETE COMMAND
Subject: Re: DELETE COMMAND
Newsgroups: comp.databases.oracle.misc
References: <34193E02.C1F327BD@djttd.com>
Organization: InterAccess, Co. - Chicagoland's Full Service Internet Provider
Reply-To: akaplan@interaccess.com
Distribution: 

vishal (vdoshi@djttd.com) wrote:
: Hi,
:    Does anybody know about the DELETE command where when you issue a
:    delete * from table it does not go into the rollback segment but gets
: deleted
:    immediately and cannot be recovered.
:   thanx
: 
: Please email me.
: bu756@torfree.net
: vishal
: 
Vishal,

Use the TRUNCATE command. This will skip all triggers, rollback segments,
redo logs, etc.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Can I examine the contents of the archive log file?
-----Original Message-----
Ari,

   A quick question I hope.  We have a system running an Oracle database
that is generating an exceptionally large archive logs as compared to other
installations of the system.  Is their a way we can examine the contents of
the archive log file to determine exactly what tables are being changed to
cause this?  Or some other method?

Thanks in advance,
Pete


-----------------
Peter W. Baljet
Manager Integration Services
ICC/GR Software
voice: 404-255-8336
fax:   404-250-0602
baljetp@genrad.com


---- Reply --------------
Peter,

Two things usually cause extra redo usage:
1) If your tablespaces are in hot-backup mode, then extra redo activity is
   generated for the tablespaces in hot-backup mode.
2) If SQL_TRACE is true, then there may be more activity in the database.

To determine the top SQL statements, you can do:

(For most rows processed:)
SELECT SQL_TEXT, ROWS_PROCESSED FROM V$SQLAREA ORDER BY 2;

(For most disk reads - not a redo causing problem :)
SELECT SQL_TEXT, DISK_READS FROM V$SQLAREA ORDER BY 2;

As for examining the redo logs, in UNIX you can issue:

strings -a  |more

This will give you some cryptic data. If you can analyze it, let me know and
I'll share it on my webpage!

Best regards,

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 210+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->



Back to Ari Kaplan's Home Page

Are OPS$ accounts bad for security?
-----Original Message-----
Ari,

Question about Oracle if it's ok. 

Is it a security risk to use ops$accounts? I personally like them
because the users password is never on the command line visible through
a ps -ef command. And we as application developers do not have to get
the users to provide their passwords to run the Oracle applications.

I've never heard anything bad about them, but someone new around here
seems to think different. 

Thanks,
Jim

----- Reply -------------
Jim,

There is a security risk with OPS$ACCOUNTS. It bypasses the underlying OS
security and allows you to connect to the database once you are logged in to the
server. However, you can "fake" a username and get in to the database without a
password. For example, if there is a "JIM" account, then someone changes the
name of their PC to "OP$JIM" then they can enter SQL*Plus with no password from
a client. The only security against this is that someone must know enough Oracle
to know how to do this, and they must know the name of an OPS$ account. Of
course people can make "crack" programs that guess usernames, but I have not
seen this.

-Ari

Back to Ari Kaplan's Home Page

Example EXPORT script file, please...
-----Original Message-----
hi ari,
             been to your homepage and i just wanted to know whether you
could send me a copy of an export script file. It would help me a great
deal.
                      
	
Adam

----- Reply -------------
Adam,

I have written some good examples of this in the "Using Oracle8" and "Special Edition Using Oracle8", both by Que.

Oracle can give you the syntax by typing "exp help=Y" or "exp80 help=Y" (depending on your OS):

exp help=y


Export: Release 8.0.5.0.0 - Production on Thu Sep 17 17:11:20 1998

(c) Copyright 1998 Oracle Corporation.  All rights reserved.



You can let Export prompt you for parameters by entering the EXP
command followed by your username/password:

     Example: EXP SCOTT/TIGER

Or, you can control how Export runs by entering the EXP command followed
by various arguments. To specify parameters, you use keywords:

     Format:  EXP KEYWORD=value or KEYWORD=(value1,value2,...,valueN)
     Example: EXP SCOTT/TIGER GRANTS=Y TABLES=(EMP,DEPT,MGR)
               or TABLES=(T1:P1,T1:P2), if T1 is partitioned table

USERID must be the first parameter on the command line.

Keyword  Description (Default)        Keyword      Description (Default)
--------------------------------------------------------------------------
USERID   username/password            FULL         export entire file (N)
BUFFER   size of data buffer          OWNER        list of owner usernames
FILE     output file (EXPDAT.DMP)     TABLES       list of table names
COMPRESS import into one extent (Y)   RECORDLENGTH length of IO record
GRANTS   export grants (Y)            INCTYPE      incremental export type
INDEXES  export indexes (Y)           RECORD       track incr. export (Y)
ROWS     export data rows (Y)         PARFILE      parameter filename
CONSTRAINTS export constraints (Y)    CONSISTENT   cross-table consistency
LOG      log file of screen output    STATISTICS   analyze objects (ESTIMATE)
DIRECT   direct path (N)
FEEDBACK display progress every x rows (0)
POINT_IN_TIME_RECOVER   Tablespace Point-in-time Recovery (N)
RECOVERY_TABLESPACES    List of tablespace names to recover
VOLSIZE  number of bytes to write to each tape volume


So, an example could be:

exp userid=system/manager full=y

This will export the entire database.

exp userid=system/manager owner=ADAM tables=EMPLOYEE log=export.log

This will export the EMPLOYEE table from the ADAM schema, and maintain a log of the export session in the export.log file.

Hope this helps!

-Ari Kaplan
www.arikaplan.com                       

Back to Ari Kaplan's Home Page

Installing with raw devices
-----Original Message-----

hi 

I saw your web page, I was impressed on that and am sending my problem 
to you.

I need some information regarding oracle installation

if you have time and familiar with this please send me or inform where 
can i get the related information. I used install oracle on solaris.

I want to install Oracle 7.3 on solaris release 5.5.1 on raw devices

can you plase send me the exact procedure to do this including, how to 
prepare raw devices. 

thanks in advance

- kishore

--------- Reply ----------
I don't know the UNIX commands off-hand, you'll have to check your UNIX guides.

As for Oracle, it is very easy. You first create the raw volumes in UNIX. Then, you use the CREATE DATABASE and CREATE TABLESPACE commands, appending the REUSE clause. That is all.

Example:

CREATE TABLESPACE TEMP DATAFILE '/u01/oradata/ORACL/temp01.dbf' size 500M REUSE;

Best regards,

-Ari Kaplan

Back to Ari Kaplan's Home Page

New century - URGENT

: We have various programs (PL/SQL, SQL, FORMS/3 and REPORT/1), that we
: must to convert to year 2000.
: Same tests were done, but the results were not good.
: Anybody knows how we can work with the function to_date, that dates are
: stored with 2 positions for year, and convert for 4 positions.
: Please, send us a answer.......
: Address: amsantos@intra.singer.com.br

Angela,

To convert a string to a date format (for inserting into a DATE field), use:

TO_DATE(string,'DD-MON-YYYY')

To convert a date field (such as SYSDATE) to a string, use:

TO_CHAR(date_field,'DD-MON-YYYY')

This will assume a date in the format of "18-SEP-1997". There are other options for
formatting. See my web page more much more information on this subject.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

DESC tables

Michael's method does not work for the DESC command. The description of a table or
view (or procedure, etc.) will scroll off of the screen even if PAUSE is set.

The only method I use is to SPOOL to a file, do the DESCRIBE, and then SPOOL off. You
can then view the contents of the file.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Michael Serbanescu (mserban@postoffice.worldnet.att.net) wrote:
: Try this:
: 
: SET PAGESIZE 23
: SET PAUSE "Press Return to continue"
: 
: To see the next screen, press Return.
: 
: Hope this helps.
: 
: 
: 
: Michael Serbanescu
: ---------------------------------------------------------------------
: Vinay Gidwani wrote:
: > 
: > From the SQL> prompt, I type in desc tablename to describe a table and the
: > table description scrolls on the screen. Is there a way such that  the
: > table is displayed one screenful  at a time?
: > 
: > Any pointers would be helpful.
: > 
: 
: > Thanks
: > 
: > Vinay.

Back to Ari Kaplan's Home Page

How do I put a & in a varchar2?

David,

Use the "SET DEFINE" option in SQL*Plus to allow a & to be inserted. Look at the
following example:

SQL> SET DEFINE '^'
SQL> SELECT '&TEST' FROM DUAL;

&TEST
-----
&TEST

SQL>

Hope this helps!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

David Kramer (Dskramer@concentric.net) wrote:
: 
: 
: This sounds stupid, but I can't find this in three different Oracle books.
: 
: If I use a & in my insert, it thinks I'm defining a variable.  In fact,
: I'm inserting a URL into a field in my database.  How do I escape it?
: 
: TIA.
: 
: 
: -------------------------------------------------------------------
: DDDD    David Kramer                        dskramer@concentric.net   
: DK KD                           http://www.concentric.net/~dskramer
: DKK D   
: DK KD   "Time's fun when you're having flies."  -- Kermit the Frog
: DDDD    
: 
: 

Back to Ari Kaplan's Home Page

Clearing rollback segments

Brad,

Since you are using Oracle 7.3, use can use the SHRINK option to remove excess
rollback space and shrink them back to their optimal size.

First, the OPTIMAL clause must be set for your rollback segments. This should be set
to the size you would like the rollback segments to normally be.

Second, issue a command such as:

ALTER ROLLBACK SEGMENT rbs07 SHRINK;

Good luck!

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 105+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

: I am running Oracle Server 7.3 on WinNT 4.0.  I have an application trying
: to update 1 field each in 500,000 rows.  After about 10 minutes, I receive
: an error saying I'm out of rollback space.  5 of the 15 rollback segments
: are maxed out (a total of 30 mb).  How can I clear those 5 rollback
: segments?
: 
: Brad

Back to Ari Kaplan's Home Page

Decoding Oracle password

Oracle compares the encoded passwords on each database. If there were an
algorithm to decode the passwords, we'd all be in trouble.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 110+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Cezariusz Marek (Cezariusz.Marek@comarch.pl) wrote:
: Hi,
: 
: I wonder how does work database links without "connect to" clause. 
: 
: Documentation says, that in such situation Oracle uses current user's
: login and password. So Oracle either can decode the password from
: sys.user$ or can connect using encoded password?
: 
: Regards,
: 

Back to Ari Kaplan's Home Page

Triggers on data dictionary; SGA swapping
> Dear sir,
> Greetings from India.
> 
> I'm Samir Oracle DBA from Birla COnsulancy India.  I got your E-mail ID from
> your papers at Orapub.  I have few questions for u to ask.  (Well I'm aware of
> your busy schedule... but in case if u have little time for us we will be more
> than happy)
> 
> 1. How to get SCN number of every transcation including DDL.(for DML yes we
> can get it momentarily from V$transaction If the trasaction is in progress.
> But what about DDL) Is this possible in first place.
> 
> 2. Do we have any control on SGA swapping on the hard disk either in unix or
> on Windows NT. i.e. Is there any way with which we can control which part of
> the sga should be swapped on the hard disk.
> Is it possible ?
> 
> 3. Can we write triggers on x$ and fet$, USer$ kinda tables.
> I want this information in sys tables to be inserted into my own tables for
> monitoring purpose.
> 
> Thanx in advance
> 
> Samir Lad.
> 
> Pl reply to : samlad@usa.net OR skgoyal@bom5.vsnl.net.in OR
> jhunjhunu@hotmail.com
> 
> ************************************************************
> Samir Lad
> (Oracle DBA).
> 
> E-4/Shanti-306,
> Sarvodaya Nagar,
> Jain Mandir Road,
> Mulund (W),
> Mumbai- 400080.
> India.
> Tel- 91-22-5679159
> ************************************************************
Namaste from Chicago, America.

Thanks for thinking of me to help answer your question.

I will try to answer your questions....

1. I do not know how to do this for DDL.
2. As far as I know, the swapping is handled strictly by the underlying
   operating system. The only thing I can think of is to pin packages into the
   SGA. The pinned packages may still swap, though. The bottom line, though,
   is to make sure that you buy more memory to avoid swapping, as it hurts
   performance alot.
3. Although Oracle recommends against fooling around with data dictionary
   objects, it doesn't hurt any if you write triggers on them. So, I'd say
   go ahead and make the triggers.

If you need any more help on these three questions, I would suggest either
contacting Oracle support (if you have it), or posting your question on the
internet (comp.databases.oracle.misc). You can also post it on the newsgroup
via "www.dejanews.com".

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 225+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Updating rows which may return multiple values
> 
> Ari,
> 
> I came across you web site which had a lot of useful information. What I could
> not find, nor can I figure out or find elsewhere on the seb is how to update
> rows which may/maynot return multiple row values.
> 
> For example:
> 
> Col1	Col2	Col3	Col4
> ----	----	----	----
> a
> 	d
> b
> 		c
> g
> 	a
> 
> Where Col4 is filled with the value of either Col# where Col3 IS NOT NULL.
> 
> Regards,
> Jim Finerfrock
> GeoComm International Corp.
> 

Jim,

I am hoping that I understand your question. Try this:

UPDATE TABLE xxx SET COL4=
decode(COL1,null,COL2,COL1)
WHERE COL3 IS NOT NULL;

Best regards,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 230+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Recovering in ARCHIVELOG mode
> 
> Hello Ari 
>     I am writing to you for the first time. I am working as a DBA with Oracle
> 8.0.4. in archivelog mode.  I have a particular problem. One of my users
> deleted a few thousand rows about three days back. How do I recover the same. 
> 
> Waiting for your quick reply
> 
> Raj Kumar Varma
> 
------ Reply -----
Raj,

It depends on how you have been backing up your database. IF you are using
EXPORT, then you can import just that one table with the deleted rows. Be
sure to check if there are any other tables with depenent data. If so, import
those tables or risk having inconsistent data.

If you did not use EXPORT, then you will have a tougher time. If it is ok to
recover the entire database to three days ago, then simply recover the database
since the last complete backup and apply archived redo logs until three days
ago.

If you must keep all other database data except the one table and do not have
an EXPORT, then you must recover the database onto a second server from three
days back. Then, take an export of the table, ftp the export to the original
server, and import the table. Again, be sure that there are no other related
tables or you must import those tables as well.

If you have more specific questions on the steps to take, I recommend getting
the "Oracle Backup and Recovery" which has step-by-step instructions on how
to recover databases. It's by Oracle Press.

Best of luck,


-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 230+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Back to Ari Kaplan's Home Page

Creating a table with a condition that DECODE cannot handle

Ari,

Thanks for the SQL info it worked great. I had another question if you had time.
I want to create a single row table that contains a year. The year value would
be the (SYSDATE + 1) if the SYSDATE month/day is greater then or equal to July
1, else the just (SYSDATE).

example: in if,then,else format

If select to_char(SYSDATE,'MM/DD') >= '07/01' then
    create table FY as (select to_number(to_char(SYSDATE,'YYYY') + 1)
      from dual);
else
    create table FY as (select to_number(to_char(SYSDATE,'YYYY'))
      from dual;

Please let me know if you have enough info for this. I have been trying to get
this to work with decode, but so far no luck.

Best Regards,
Jim Finerfrock

-----  Reply -----

This cannot be done in straight SQL. First, decode will not work because it is a
function, and can return values only. It cannot execute SQL based on values,
especially DDL such as CREATE TABLE. Second, straight SQL cannot do the IF THEN
ELSE structure.

What you will need to do is create a PL/SQL routine. What you are trying to do
is very easy, and you already have the logic set-up. PL/SQL can handle the IF
THEN ELSE logic flow, and so on. If you do not know PL/SQL I recommend getting
Steve Feuerstein's book from O'Reilly and Associates.

One thing in the CREATE TABLE statement is that you should make an alias (such
as COLUMN_A) for the column, shown below:

create table FY as (select to_number(to_char(SYSDATE,'YYYY') "COLUMN_A")
      from dual;

Best regards,

-Ari Kaplan
Independent Oracle DBA
www.arikaplan.com                       
-------------------------------------------------------------------
NOTE: The following was suggested from a browser of this page. His comments
follow...

From: Victor Yu 
To: akaplan@interaccess.com
Subject: From Victor

Hi, Ari,
  This is Victor from Boston, MA. I do DBA works for more than 3
years. I've read all the tips in your website. They are very useful.
  I have a suggestion on question #235. Please look at the 
following SQL:

create table FY as
  (select to_number(to_char(add_months(sysdate,6),'yyyy')) "COL1" from dual)
 
  Thanks for your attention.
---------------------------------------------------------------------
NOTE: This is my response:
Victor,

Glad to see that you enjoy my web page...so much that you read all of the tips!
Thanks for your comment. I put it on the web page if that's ok. The syntax
of your SQL needs a few small changes. Aside from that it's great!

create table FY as (select to_number(to_char(SYSDATE,'YYYY')) "COLUMN_A"
from dual);

-Ari

Back to Ari Kaplan's Home Page

Analyze Question

Sudheer,

The avg_row_len does include header data. I did an experiment:

1) Create a table with one column, varchar2(100)
2) Insert 1000 records with a five-character string "xxxxx"
3) Analyze the table
4) Select the avg_row_len from all_tables

What I found was that the average length was 9. The string was 5
characters, so there were 4 additional "overhead" bytes.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 110+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Sudheer Tummala (sut@ordinal.micro.lucent.com) wrote:
: I am using ANALYZE TABLE  COMPUTE STATISTICS;
: and then selecting table_name, avg_row_len from dba_statistics to get
: the average lrow length in each table.
: 
: What I want to know is, does the avg_row_len column in dba_tables inlude
: Header space per row also?
: 
: 
: -- 
: ***********************************
:   Sudheer Tummala
: ***********************************

Back to Ari Kaplan's Home Page

Comparing two databases
Newsgroups: comp.databases.oracle
Subject: Re: Comparing two databases
References: 

BEERYR  writes:

>Any suggestions or third party tools that will compare objects in one
>database to another database.  This would include: tables, indexes, 
>triggers, stored procedures, database links, grants, synonyms, views,
>constraints, sequences, and user definitions.  Basically, anything 
>that makes one database different from another.

>This would be used to compare development to production
>or a customized db to the plain vanilla db.  Or a pre-upgrade
>db to a post-upgrade db.

_____________Ari's Comments follow____________________________________________
Ron,

There is an elegant way to compare objects in two databases. Create a 
database link from one to the other. Then you can type something like:

SELECT TABLE_NAME FROM ALL_TABLES
minus
SELECT TABLE_NAME FROM ALL_TABLES@instance2;

SELECT TABLE_NAME FROM ALL_TABLES@instance2
minus
SELECT TABLE_NAME FROM ALL_TABLES;

You will then get a list off all tables in one instance that is not in
the other. You can also do this for sequences (ALL_SEQUENCES), procedures
(ALL_SOURCE), etc.

Best of luck to you,

-Ari Kaplan
Independent Oracle DBA Consultant
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

_________________Ron's Article Continues...___________________________________
>In my mind's eye, it would be nice if a before image could be stored.
>Thus, take a before picture, developers do their stuff or run an
>upgrade, take an after picture, then compare.  Rather than needing
>both db's running together.


>Another idea would be take an export full=y rows=n of both db's
>then have a unix script to compare them.  But, optionally, ignre 
>differences due to extent sizing and such.

>Any ideas.

>Ron Beery
>NCR
>"Everything is computerized.  What could possibly go wrong?"

Back to Ari Kaplan's Home Page

About database setup... Urgent

Satish,

The best approach would be to look in your alertSID.ora file for any
additional error messages. Also look in your trace directories for trace
files.

My best guess is that there still are memory semaphores associated with
your old database that are locking resources. To be sure, if you are on a
UNIX platform, type:

ipcs -a |grep oracle

You should do a SHUTDOWN ABORT to clear all memory processes, then try to
start up your database.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> For 110+ Oracle tips, visit my Web Page:                      <->
<->                                                               <->
<->             www.arikaplan.com                                 <->
<->                                                               <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->


Satish S.Narasimha (somasatish@hotmail.com) wrote:
: Hello,
: 
:     I had taken a backup of the database and restored from the
:   tape back in  the /home1 directory.
: 
:    After restoring in started the database giving connecting as
:    sqldba
:    
:    giving  the startup command  the syystem is saying 
:      background process PMON not started...
:    Can anybody help on this how to solve.....
: 
: Thanks in advance. 
:   E-Mail : somasatish@hotmail.com

Back to Ari Kaplan's Home Page

Whacko SQL*Net Errors

Newsgroups: comp.databases.oracle
Subject: Re: Whacko SQL*Net errors
References: <3169E34A.1CF5@its.csiro.au>


(Original article included after my comments).

In my documentation, I have a description of your errors:

TNS-12204:"TNS:Received data refused from an application"
// *Case: The application using the Interchange refused the connection
// at the listener.
// *Action: Make sure that the application listener at the destination is
// functioning correctly. If it is and the problem persists, contact
// Worldwide Customer Support.

TNS-12564:"TNS:connection refused"
// *Cause:The connect request was denied by the remote user (or TNS software).
// *Action: Not normally visible to the user. For further details, turn on
// tracing and reexecute the operation.

Information on tracing is in the Oracle Network Products Messages Manual.

Good luck, Steve.

-Ari Kaplan
Independent Oracle DBA Consultant

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
<-> Visit my Web Page: www.arikaplan.com                          <->
<->             email: akaplan@interaccess.com                    <->
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

Steve Green  writes:

>Greetings,

>I am a newbie Oracle person who is trying to setup a system called "AutoSys" thta uses Oracle to
store 
>it's data.

>I'm pretty certian I've got the Oracle/SQL*Net stuff working correctly.

>TNSPING, SQLPLUS, etc works just fine.

>However, when I run one of the AutoSys applications ( gatekeeper ) I get the following:

>Fatal OSN connect error 12500, connecting to:
> (description=(connect_data=(sid=asys)(server=dedicated)(CID=(PROGRAM=)(HOST=aln
>itak)(USER=autosys)))(ADDRESS_LIST=(ADDRESS=(PROTOCOL=ipc)(KEY=alnitak))(address
>=(protocol=tcp)(host=alnitak)(port=1521))))

>  VERSION INFORMATION:
>        TNS for SVR4: Version 2.0.15.0.0 - Production
>        Unix Domain Socket IPC NT Protocol Adaptor for SVR4: Version 2.0.15.0.0
>- Production
>        Oracle Bequeath NT Protocol Adapter for SVR4: Version 2.0.15.0.0 - Produ
>ction
>        TCP/IP NT Protocol Adapter for SVR4: Version 2.0.15.0.0 - Production
>  Time: 09-APR-96 15:08:26
>  Tracing not turned on.
>  Tns error struct:
>    nr err code: 12204
>    TNS-12204: TNS:received data refused from an application
>    ns main err code: 12564
>    TNS-12564: TNS:connection refused
>    ns secondary err code: 0
>    nt main err code: 0
>    nt secondary err code: 0

>I cannot find any error 12204 or 12564 in the SQL*Net manual and certainly not in the main errors
and 
>codes manual.

>So I'm kinda stuck!

>Anybody got any ideas?

>Thanks in advance.

>Steve

Back to Ari Kaplan's Home Page

L>