- Ari Kaplan

advertisement
1.
Subject: Whacko SQL*Net errors
Q -- I am a newbie Oracle person who is trying to setup a system called
"AutoSys" that uses Oracle to store it's data.
I'm pretty certain 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=alnitak)(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 Adapter for SVR4: Version 2.0.15.0.0
- Production
Oracle Bequeath NT Protocol Adapter for SVR4: Version 2.0.15.0.0 - Production
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.
A -- 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.
2.
Subject: ORA-01555 snapshot too old? / NetWare-Database crashes
March 27, 1996
Q -- 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 compatibility 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?
A -- 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!
3.
Subject: How to use " in Oracle data
MARCH 21
Q -- We are encountering db values that contain both double quotes and
apostrophes. Has anyone found a work-around for this situation?
A -- In order 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!
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 occurrence of a character to whatever
new character you choose within a string.
4.
Subject: Insufficient Privileges with SYS for SQL*DBA
MARCH 20
Q -- 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?
A -- 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.
5.
Subject: Cannot do 'connect internal' to do system shutdown
Q -- 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???
A -- 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.
6.
Subject: Export a table from Oracle to ASCII File
Q -- Is there anybody who knows how to export a table from ORACLE to an
ordinary ASCII file?
I know there is an EXP command in Oracle that writes an archive dump 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?
A -- 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:
http://homepage.interaccess.com/~akaplan/oracle.html page 1
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.
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.
10.
Subject: ORA-3113 errors, suddenly
APRIL 18
Q -- After a year of relatively trouble-free Oracle running, first on 7.1.3 and lately
Subject: Need help with simple SQL syntax
on 7.1.6, I started getting ORA-3113 errors today. I don't know if it's relevant, but I
APRIL 24
recently upgraded my RS/6000 AIX from 3.2.5 to 4.1.4, and then, just a few days
Q -- Please bear with me, I always thought I knew SQL - now I have my doubts. ago, moved all applications and data to a new physical server, still running 4.1.4.
Simple interactive query to access records with a particular VMS date field being at I'm getting the errors on both server "batch" processes, and also on client PC
least 14 days in the past. What is the correct syntax?
applications running SQLNET 1. What exactly does this 3113 error mean?? The
(Oracle Rdb, former DEC Rdb)
error text says "end of file on communications channel" or something. Is the Oracle
SQL> select * from myTable where timeField < 'today - 14 days'
connection being lost? What should I do to fix this, or at least to isolate the problem.
How do I correctly specify 'today - 14 days'?I get all sorts of error messages.
This is becoming a serious issue quickly.
A -- There is a simple solution for your question. Oracle references today as
A -- The "ORA-3113" error is defined as you said as "end of file on
SYSDATE. So, to reference 'today - 14 days', you can type:
communications channel", which means that the process has suddenly been killed.
SELECT * FROM myTable WHERE timeField < SYSDATE - 14;
For example, you type "Ctrl-C" during a query, or someone issues a "kill session"
command.
8.
However, you should be aware that this error is known to be misleading, and is
Subject: How do I do a simple directory listing of my available Oracle 7 tables frequently a "catch-all" error, similar to the "ORA-600" error. Sometimes if Oracle
APRIL 24
has a problem, it reports a "ORA-3113" even if that is not the true cause.
Q -- How can I do a simple directory listing of my Oracle7 tables using SQL. I am For example, I have received the ORA-3113 error when using the "analyze table x
ODBC connected and can query any one table. I just don't know how to create a
estimate statistics;" command. This surely does not have to do with SQL*Net or
list of the tables. I've read all the docs I have and it doesn't flash out at me.
anything associated with Oracle communications protocols. Since you get this error
A -- If you have a dba account, type:
even when running server "batch" processes, it may not be a SQL*Net problem.
SELECT * FROM DBA_TABLES;
Check to see if you use SQL*Net even when running server-only batch jobs.
If you have a non-dba account, type:
Try to isolate the problem. Look for any other error messages on the error
SELECT * FROM ALL_TABLES;
message stack. Check your "alert_SID.log" file to determine what was occurring
To limit your selection, use the WHERE clause. For instance, to find all tables with during the problem(s). Also, look for any trace files that may have been generated.
the name "PERSON" in it, type:
SELECT * FROM ALL_TABLES
11.
WHERE TABLE_NAME LIKE '%PERSON%';
Subject: Set instance 2: command
Q -- I have 3 instances running... but I can't seem to get the "Set instance 2:
9.
[SID]" command working when I get into SQLDBA.
Subject: Error - ORA-01652
I'm running in a Unix environment.
APRIL 24
A -- Look at the Oracle7 Server Utilities Guide, Pages 12-21, 12-23, and 12-25.
Q -- I have just started working with Oracle (two days ago). The error ORAFor those comp.database.oracle people that don't have the guide, it basically says
01652: unable to extend temp segment by 5412 in tablespace TEMPJCREW, was
that the SET INSTANCE changes the DEFAULT instance for SQL*DBA sessions. It
occurring before I started, and I am wondering what it means, as I can not find it in
does NOT connect you to the database. The default instance "is used for the
any of the manuals.
STARTUP, SHUTDOWN, and CONNECT commands when no instance is
I am really an application programmer, but in my new position I am currently also specified."
acting as the DBA. We are using version 7.1 on Solaris 2.5. The error occurs after
The syntax is as follows: node name, hyphen, database name:
doing a rather large select.
INSTANCE home_office-main_database
We have the following tablespace set up:
If all you wanted to do was use SQL*DBA for your different SIDS, there is a much
create tablespace tempjcrew datafile 'temp01.tab' size 2000m;
easier method. Simply type:
alter tablespace tempjcrew add datafile 'temp02.tab' size 1000m;
export ORACLE_SID=sid-name
alter tablespace tempjcrew add datafile 'temp03.tab' size 500m;
(substitute "sid-name" with the actual ORACLE_SID).
alter tablespace tempjcrew add datafile 'temp04.tab' size 500m;
Then, go into SQL*DBA and connect!
alter tablespace tempjcrew default storage (pctincrease 1 next 10m);
temp01.tab and temp02.tab are on separate disks.
12.
From what I have read, the pctincrease has no affect in version 7.
Subject: Dead SQL*Net process
We are selecting approximately 20 million records. Are we just running out of
April 7, 1996
space. Do we need to create another tablespace?
Q -- Are there any script or way to kill all dead processes? Should I use
A -- I want to wish you good luck on your new DBA role. There is much to learn, SHUTDOWN ABORT instead of SHUTDOWN IMMEDIATE in order to kill all
and two days is not enough to get up to speed. This message should hopefully help processes remaining?
get you going.
A -- If you have dead, or "zombie" processes, then sometimes shutting the
First of all, make sure that the user has 'TEMPJCREW' as the TEMP tablespace
database down will not get rid of the processes. This includes either SHUTDOWN
in the user profile. To do this, type:
ABORT or SHUTDOWN IMMEDIATE.
ALTER USER username TEMPORARY TABLESPACE tempjcrew;
To get rid of the dead processes that cannot be stopped from SHUTDOWN, first
Your problem could be as simple as not having this set, and the processing of the try a "kill -15 {process-id}". Substitute the process-id with {process-id} in the
20 million records is taking place in another smaller tablespace (SYSTEM,
examples included here.
perhaps?)
If that fails, then try "kill -9 {process-id}". Make sure that you logged in as the
Also, the pctincrease DOES have an effect in Oracle7. You have it set to 1. I
owner of the process (most likely it will be the "oracle" id).
would recommend setting it to a more even number, such as 0 or 100. This will
Now, if the process still exists after a "kill -9 {process-id}", then do one of the
depend on how many extents you expect, how large your smallest datafile is (500m following:
in your case), and so on. I would recommend starting at pctincrease 0. If it turns out 1) login as root and kill the process.
that you run out of extents, then simply make the default INITIAL extent for the
2) Physically shut down the system and restart.
tempjcrew tablespace larger.
13.
To find out if you DO need more space in the "tempjcrew" tablespace, issue the
Subject: SQL Query
following statement while running the 20 million record query, preferably several
May 15, 1996
times during the execution and right before the ORA-1652 error:
Q -- How to write the SQL like the following?
SELECT b.file_name, a.tablespace_name, a.bytes, a.blocks
select * from test where name like 'hel[ply]'
FROM dba_free_space a, dba_data_files b
it will return the records which name is help, hell or hely. Sybase can do exactly like
WHERE a.file_id = b.file_id
the above. I do not think the Oracle supports the [ ].
AND a.tablespace_name = 'TEMPJCREW';
A -- One way to do this:
7.
http://homepage.interaccess.com/~akaplan/oracle.html page 2
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.
14.
Subject: Using alter table add constraint syntax ?
Q -- 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 can’t work out the alter table add syntax to create it somewhere else!! Can
anybody help ?
A -- 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.
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.
17.
Subject: Comparing two databases
Q -- 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.
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, ignore differences due to extent sizing and
such.
A -- 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 of all tables in one instance that is not in the other. You can
also do this for sequences (ALL_SEQUENCES), procedures (ALL_SOURCE), etc.
18.
Subject: Performens - empty blocks, 7.1 Unix
Q -- 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.
15.
The symptom is: the rollback/delete completes, and everything seems okay, but
Subject: Question: How to handle duplicate table names?
subsequent inserts into the table, is about 10-20 times slower than normal (even
Q -- I would appreciate hearing from anyone who has any insight into handling the without any load, processing ONE record in ONE insert takes more than 1 second).
use of duplicate table names. In the production version of the application this will
This does not happen when the table is FRESH, or if I truncate the table after a
not be a problem as the tables will be accessed via SQL*Net thus having different
rollback, or instead of deleting a lot of rows. All inserts are done from PL/SQL remote database extensions.
either directly in a PL/SQL block or via a package. SELECTS also take forever
The problem is that we are building a prototype using one database. While it is
(Oracle somehow scans all empty blocks??).
possible to place the tables into separate table spaces, I have not come across any
Does anyone know of this problem? Is it a 7.1 bug, fixed in 7.2 or is it possible to
mechanism for specifying which table space to look for a table. The only
be a platform specific problem? It seems to me, to be some kind of "freepointer"
differentiation mechanism that I can find in Oracle is the use of the table owner as a problem, when PCTUSED gets below default settings ????
prefix to the table name.
A -- I have had the same symptoms myself (both Oracle 7.0.16 and 7.1.3). You
i.e.
GROUP1.STATUS_CODES
are correct in that the internal pointers indicate a table at its largest state in its
GROUP2.STATUS_CODES
history. So, if you load and delete records, the internal pointer will indicate the
With this approach we would have to transform all of the table names in the
largest size of the table.
application programs when we port them to the actual production server. i.e.
Look at the number of extents on the table. Whenever a new extent is created, it
GROUP1.STATUS_CODES --> STATUS_CODES@SITE1 etc...
is never de-allocated, unless you TRUNCATE or EXPORT/IMPORT the table.
A -- Oracle does not allow two tables to have the same name and the same
In your INSERT statement, if you have a constraint that needs to check the table
owner. There are ways to get around it for what you want to do.
for integrity reasons, it might be scanning the empty blocks, explaining the longer
You should make SYNONYMS for the owner.table that you want to reference.
times you have been getting.
Then, when you move to the production server, you do not need to change your
Oracle support confirmed this to me a while ago.
code. The actual base tables would always be the same, but you can change the
19.
synonym easily to point to whichever owner or table you like.
Subject: Backup of Oracle databases
For more information on synonyms, check the Oracle documentation.
Q -- I need some information about backing up Oracle databases. I want to
16.
perform a file level backup of an oracle database whilst the database is running.
Subject: Import/Export facility
Whilst this backup is being performed there will be no updates. Is there any way of
Q -- I can successfully export and import any size of table, but can only import a locking the database so no updates can be performed but reads are still allowed. If
very small table. I have tried increasing the 'pctincrease' from 0 to 50, which the
there is is this a safe way of performing the backup.
manual recommends, but I realize it is not a good idea to do this anyway. Currently A -- The safest way to allow the database to be available for reads during a
the max extents is set to 99.
backup is to perform a "hot backup" of the database. Not only can the users read
The error messages I receive are as shown below.
data, they can update, insert, and basically do everything they normally can do.
IMP-00003: ORACLE error 1556 encountered
During that period, all database files can be backed up to tape.
ORA-01556: maximum number of 99 extents exceeded
A discussion of hot backups is beyond the scope of a posting - several books
IMP-00021: operating system error - error code (dec 2, hex 0x2)
contain descriptions on how to do this. My favorite is "ORACLE Backup and
IMP-00028: partial import of previous table rollbacked: 1834 rows
Recovery Handbook" by Oracle Press.
rollbacked
Another option you might want to think about is exporting the database while it is
Import terminated successfully with warnings.
up. Simply use the "consistent=y" option. Remember, however, that exports cannot
This is all run under Oracle 6.
recover to a point-in-time after the export, while image backups can recover to the
A -- It is not sufficient in your case to increase the PCT_INCREASE parameter.
point of a crash.
Since you have exceeded the 99 extents, it is clear that your extent sizes are not
20.
large enough.
Set the INITIAL and/or NEXT extent to a larger value (at least 99 times what they Subject: starting a job at specified intervals
Q -- We have a simple database in ORACLE and each record contains a date of
are now to even have a chance of fitting in only one extent).
insertion. Now we want to automate the process of removing records after a certain
http://homepage.interaccess.com/~akaplan/oracle.html page 3
time following their insertion. Is there a way to tell oracle to monitor the database
and remove records that are too old.
A -- 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
21.
Subject: How do I reclaim index space?
Date: 19 Jun 1996 16:56:42 -0500
Q -- 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?
A -- 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.
exp TABLES=data_table1,data_table2,data_table3
You can also type "exp help=y" for more options and syntax.
26.
Subject: Object does not exist
Q -- 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.
A1 -- 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
A2 -- 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;
27.
Subject: file structure for ORACLE
Q -- 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/preferred way to structure the file for
22.
import into Oracle??
Subject: Delete without rollback?
A -- There is no standard way to structure the file for loading into Oracle. The
Q -- I have this one table, which I need to empty every now and then during my
SQL*Loader program is flexible enough to be used with any delimiter, be it spaces,
development. It's not too big, about 10000 rows. But when I do a complete delete
tabs, commas, etc.
(Delete * from mytable) it always fails and complains that the size of the rollback
The best delimiter is a character that is not contained in any field. For instance, if
was exceeded (or something like that). Ok, I can understand that. But I wouldn't
one field is a name, such as "Alan Macaluso" or an address, such as "23 Broadway
want to increase the size of the rollback-segment as this delete operation is not
Ave", then a space would not be ideal as a delimiter.
going to be used in production, just for my testing.
You can specify when loading the delimiter by commands such as
So, is there a way to do a "permanent" delete at once, so that Oracle wouldn't use
TERMINATED BY ","
any space in the rollback-segment?
TERMINATED BY WHITESPACE (spaces and tabs)
A -- Using the "TRUNCATE" command will bypass the rollback segments when
ENCLOSED BY '"'
deleting records. For example, "TRUNCATE TABLE too_many_rows;" will delete all
See the Oracle Utilities User's Guide for more specifics on SQL*Loader.
records.
My personal preference is comma-delimited fields, with a line feed after each
Note that no triggers that may exist get fired. Also, do not do this to a table that is record.
a master snapshot.
28.
23.
Subject: How can I find out who is currently using the DB?
Subject: Sequence Caches
Q -- How can I find out who is currently using Oracle DB?
Q -- I'm trying to find how sequence are cached. Specifically, are they per
A -- There are several ways to find who is using the database:
transaction or set of transactions. So if a cache had a high cache size of 1000 with 1) SELECT * FROM sys.v$session;
5 users accessing the sequence would each user be given their own set of 1000
This is the best table for what you probably are looking for. It includes schema user
sequences or would the 5 users pull from the 1000?
name, OS username, OS machine name, OS terminal name, ORACLE username,
I'm trying to figure this out because I'd like to set my cache size high because I
etc.
know that a session will use them but if each user pull this high amount then my
For ease of reading, you can enter:
sequence will increment quickly.
SELECT username FROM v$session;
A -- The 5 users would all pull from the 1000 sequences. Otherwise, duplicate
2) SELECT * FROM sys.v$process;
sequence numbers might be generated for different users. Oracle will allow all users This table shows the processes, usernames, OS terminal identifier, etc.
pull from the sequences for data consistency.
3) If in UNIX, you can type:
ps -ef |grep {ORACLE_SID}
24.
This option lists the processes, and may not be all-inclusive if users are logging on
Subject: ORA-1041 Internal error HOSTDEF does not exist
through SQL*Net, Tuxedo, or other TP's.
Q -- A user was running a job which selects one record at a time and updates it
this morning and got this error. We are running on Oracle V7.1.3 on AIX 3.2.5 SGA 29.
size is 33M shared_pool_size is 24M. Can any one tell why we got this error and
Subject: SQL question: Views
what is the fix. Oracle Support could not help
Q -- Is there any way to construct a view in SQLplus with derived columns where
A -- In my documentation, the ORA-1041 is as follows:
you get to determine the length of the datatype. It seems that in the construction of
01041: "internal error, hostdef extension doesn't exist"
our view our derived columns are being set as varchar2(2000). However our
* Cause: Pointer to hstdef extension in hstdef is null.
columns only use up 10 spaces. We get a problem with buffer overflow, and we
* Action: Report as a bug
don't want to reduce arraysize and we are operating on Oracle7 so MAXDATA
If this is a bug, then Oracle Support should help you. Call them again and insist
doesn't make any difference.
that it is a bug.
A -- There is a way to do this. Suppose the base table is as follows:
desc TEST_TABLE;
25.
A VARCHAR2(10),
Subject: Oracle EXPORT re: Tables only
B VARCHAR2(2000),
Q -- Can anyone help on exporting only certain tables. We are running under Sun
C VARCHAR2(2000)
OS 2.0 (soon to be Solaris 2.4) and Oracle 7.1.4 (soon to be 7.2.2.3). We need the
To create a view where each column is length 10, do the following:
ability to export only the data tables. We also are running an HRMS PeopleSoft
CREATE VIEW test_view AS
database (4.0) and would like to export (and import) only the data tables, not the
SELECT a, SUBSTR(b,1,10) B, SUBSTR(c,1,10) C
PeopleTools tables (i.e. PSRECDEFN, etc).
FROM test_table;
A -- The "export" utility is very flexible for what you want to do. Use the
"TABLES=" option. For instance, try:
http://homepage.interaccess.com/~akaplan/oracle.html page 4
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.
30.
Subject: SYSDATE - Time slow to update?
Q -- 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.
A -- 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.
31.
Subject: Capturing SQL commands
Q -- Is there a way to capture users' SELECT commands for later analysis?
A -- 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.
32.
Subject: Rollback segments
Q -- Trying to delete all the data from a table (6000 records) I received 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?
A -- 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 OSDependent 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 specifically set the transaction to use
the same rollback segment each time in order to get the effects you described
above.
33.
Subject: "ORA-01555 snapshot too old and ORA-01658 unable to create
Q -- 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.
A -- 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.
34.
Subject: problems with temp file
Q -- 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 pro*C 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...
A -- 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 tablespace_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.
35.
Subject: SQL*Net message from SQL*Plus
Q -- 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.
A -- 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.
36.
Subject: more extents needed!
Q -- I know this is a basic question, but the database is complaining that it can't
allocate extents while a user tries to update. How do I do this? I am using Oracle 6
for Netware, and we need more extents ASAP!
A -- 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).
37.
Subject: ANALYZE %
Q -- 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.
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');
A -- 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).
http://homepage.interaccess.com/~akaplan/oracle.html page 5
38.
Subject: "ORA-01555 snapshot too old and ORA-01658 unable to create
Q -- 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.
A -- 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.
39.
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?
A1 -- 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.
A2 -- 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.
42.
Subject: REDO log shifts are blocking for DB updates !!!
Q -- 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.
Subject: ROLLBACK SEGMENTS: Some basic questions
THE PROBLEM !!!
Since transaction also contains updates, the REDO log file fills up and are
more concerned about performance and data loss is not really a concern.
switched on regular basis. During the switch the update statements are
2. I have a rather complicated PL/SQL script that works on a table that has
stalled/delayed for the same amount of time as it takes to switch REDO log file.
140,000 rows in it. The script is deleting rows based on a set of rules. The process Why ?????
after 30 minutes aborts and reports the following :
On average an update takes 25 milliseconds, but during the REDO log shift it is
BEGIN
delayed for 3 SECONDS!!!!
* ERROR at line 1:
This has to be a 'classical' problem in 'this' database 'community' ??
ORA-01562: failed to extend rollback segment number 1
Are there any ways of configuring the instance (init.ora) such that LGWR will
ORA-01628: max # extents (100) reached for rollback segment R01
continue writing while DBWR and CKPT completes their tasks during the REDO log
I thought I had taken care of all my rollback segment blues when I created the
shift?
following rollback segment :
HW/SW CNFIGURATION:
create public rollback segment r01 tablespace RBS
Running Oracle Server 7.3.2.2
storage (initial 500K NEXT 500K OPTIMAL 10M
AlphaServer 4100 (2 CPUs), 1 GB RAM, 6 x 2.1 GB disks
MINEXTENTS 15 MAXEXTENTS 100) ;
OpenVMS 7.1
I dropped all the other rollback segments intentionally to help me debug this
WHAT ALREADY HAS BEEN TESTED OUT!!!
problem. I am now thinking that maybe I should increase the maxextents to 200 or -Different sizes of REDO log files.
some such number and maybe add another rollback segment with identical
-Multithreaded REDO log files.
settings. But I am not sure if that is going to solve my problem.
-The ALERT log does not contain any incomplete CHECKPOINT messages,
A -- The reason that your transaction failed is that your INITIAL/NEXT sizes are
indicating that CHECKPOINTS are accumulated up, until the REDO log shift.
too small for what you are trying to do. Since you ran out of extents (100 maximum), -Most init.ora parameters has been tested out. such as:
you need more than 500kx100=50M of rollback to complete your transaction.
-db_block_buffers
Unfortunately, your statement failed and so it is impossible to tell how much
-shared_pool_size,
rollback you truly need. The best solution is to recreate the rollback segment with:
-log_checkpoint_interval,
CREATE PUBLIC ROLLBACK SEGMENT R01 TABLESPACE RBS
-log_checkpoint_timeout,
STORAGE (INITIAL 10M NEXT 5M OPTIMAL 20M
-log_checkpoint_to_alert=YES,
MINEXTENTS 3 MAXEXTENTS 100);
-db_block_checkpoint_batch,
If you still wanted MINEXTENTS to be 15, you can decrease the initial and next
-db_file_simultaneous_writes,
accordingly.
-log_buffers.
Run the query again and monitor how much rollback space was used. With
-REDO log size has been tested out for the range 25K -> 10 MB, and we are
MAXEXTENTS 100, you will have 505M to use. Be sure that your tablespace is
currently 'stuck' on 3 MB.
large enough as well.
An attached WORD file will show the delay graphically. Both axis are in
One final note...if you have an environment where there are both large
milliseconds.
transactions/reports (such as the one you describe) AND short transactions, then
A -- I have experienced the same behavior as what you describe. What you need
make several small rollback segments and one or more large rollback segment(s)
to do is make sure that all of your redo logs and archive directory are on separate
such as the one I described. For the large transactions/reports, you can say (after
devices.
COMMIT or ROLLBACK):
Otherwise, when there is a redo switch, the archiver process copies the previously
SET TRANSACTION USE ROLLBACK SEGMENT RB_LARGE01;
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
40.
during each switch.
Subject: Oracle Server Manager
Q -- I tried to shutdown a running database with the ServerManager svrmgrl (line 43.
mode tool) but it was only possible to stop the database with 'shutdown abort'.
Subject: SQL*Plus spooling problem
No other db client had connected the database and it's also impossible to stop
Q -- I'm spooling data from a select statement to a file in SQL*Plus on an old
with 'shutdown immediate".
Oracle 5 database (not my database!). The problem is with too many rows in the
Our database version is 7.3.2.2.
data file. The data looks OK, but the select count(*) and the wc on the file never
A -- There are only a few reasons why the Oracle database will not "shutdown
match. Why would Oracle split up each row into multiple rows in the file?
immediate". First, if a user is in the process of logging in, the database will wait for
I have tried:
"logins to complete." For example, this will happen if someone types "sqlplus" and
select a, b, c from table1
leaves the computer at the "Username:" prompt.
select * from table1
Also, some "zombie" UNIX processes will hold the database up. Otherwise, you
select a||b||c from table1
have an Oracle bug and should contact support.
None work as I expect...1 line per row of data.
The first thing that you should investigate is for any trace files in the bdump,
A -- This problem will occur not only in Oracle 5, but in 6 and 7 as well. What is
cdump, udump directories. The alert_{SID}.log could also have the reason included. 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
41.
linesize larger. For example,
Subject: Functions becoming invalid
SET LINESIZE 120
Q -- I administer a system which makes heavy use of stored functions and one in
Do this in SQL*Plus before the select statement. Simply make the linesize as
particular is required for several key reporting views. For some reason, this function
large as you need.
becomes invalid periodically and almost always after the database is shutdown for
Q -- 1. Is there a way to have a transaction not use any rollback segment ? I am
http://homepage.interaccess.com/~akaplan/oracle.html page 6
44.
48.
Q -- Can anyone tell me why this is happening and what can be done to rectify
Q -- Does anyone know how to format the output for the dbms_output.put_line.
Subject: SQL Statement
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 executes very quickly. However, if the subselect returns more than ~8000 rows, the primary select goes into a sweep. The
DBAs don't know why this is happening! Is there something at the ORACLE side
that needs to be set (e.g. 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 (i.e. the original results are not held in the buffer).
A -- 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.
45.
Subject: Adding Users
Q -- What is the best way of adding users to Oracle in bulk on Unix?
A -- 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...
46.
Subject: core dump while querying large tables
Q -- When I do a select with some clauses on a large table, Oracle generates a
core dump and the process is stopped. Can anyone explain what the problem is
here ? ( I am using Oracle 7 on IRIX 5.3)
A -- 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.
47.
Subject: DB_FILE_MULTIBLOCK_READ_COUNT
Q -- 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.
A -- It is in Oracle blocks. Usually it is set to 8 for online TP and up to 32
for DSS/Warehousing/batch.
Subject: Fixed format output
Or possibly another function that will do fixed format output.
A -- 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.
49.
Subject: Am I running out of extents (fragmentation)?
Q -- Two tablespaces are giving problems to a user who cannot create more
tables. I ran the following query
>> query missing?!?!?!?!?<<
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? 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 will have one
contiguous block of free space. I think there's no need to drop the tablespace.
A -- 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;
50.
Subject: "Product user profile information not loaded"? Why?
Q -- 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?
A -- 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.
51.
Subject: start services/database
Q -- 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 (automatically 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.
A -- 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) but 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.
52.
Subject: ORA-0729 on HP
Q -- 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.
A -- 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
too 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
53.
Subject: Ora-600 Space Leak...Explain, causes
Q -- Got the following error reported to my alert log...
Tue Apr 1 14:54:52 1997
http://homepage.interaccess.com/~akaplan/oracle.html page 7
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.
A -- 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.
54.
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
/
Q -- I have a problem about deadlocks in ORACLE V7.1.4. Could anybody help
57.
Subject: How can I find deadlocks?
me, about how to find them?
A -- 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.
Subject: limiting rows returned ?
Q -- 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 ?
A -- Use the ROWNUM clause:
SELECT * FROM ... WHERE ROWNUM < 2;
55.
58.
Q -- Being a DBA currently moving our systems from Sybase to Oracle I have a
Q -- Is there a non Oracle Manual for PL/SQL? other than the one that comes
Subject: Case insensitive searching
newbie question concerning sort ordered.
Is it possible to configure an Oracle Database/Instance with a case insensitive
sort order?
A -- 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);
56.
Subject: Question on tablespaces and table spaces
Q -- 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.
A -- 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
Subject: PL/SQL manuals?
with the standard set of oracle manuals?
A1 -- 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.
A2 -- 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
59.
Subject: Poor performance after large delete
Q -- 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.
A -- 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.
http://homepage.interaccess.com/~akaplan/oracle.html page 8
60.
64.
Q -- What are the implications of having the system tablespace and the temp
Q -- Oracle claims the following with the message "ORA-06571: Function XXX
Subject: System and temp tablespace
tablespace files on the same physical disk. Does that, in any way, affect
performance?
A -- 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 to put the TEMP and
SYSTEM together 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.
61.
Subject: How can I find how many instances in a server
Q -- 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.
A -- 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).
62.
Subject: How do you determine free space in DB?
Q -- 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.
A -- 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
/
63.
Subject: Help on how to get decode the resource id
Q -- 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 particular record that is being locked by a particular
process when I see the id1, id2. does id1, id2 point to a table/row or can it be any
other resource.
A -- 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.
Subject: ORA-06571
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 ORA06571.
A -- According to my documentation
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.
65.
Subject: Scheduled Hot Online Backups
Q -- 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 Listener had red
crosses through them so I couldn't schedule a backup job.
I rang Oracle support, who suggested that I set up a schedule 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.
A -- 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 stop and start your database for the parameters to
take effect.
66.
Subject: dbms output causing problems
Q -- 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.
A -- 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.
http://homepage.interaccess.com/~akaplan/oracle.html page 9
67.
72.
Q -- We're running Oracle 7.1.6 and 7.3.2 on HPUX and need some help with
Q -- Does Oracle support Generators (gen_id) to get unique Integers for Primary
Subject: Tablespace Fragmentation
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.
A -- 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.
68.
Subject: How to change password in SqlPlus/Net?
Q -- 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.
A -- In SQL*Plus, type:
alter user USERNAME identified by PASSWORD;
This will change the user’s password (assuming you are the user or have DBA
privileges).
69.
Subject: Question about check constraint
Q -- 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
A -- There are several ways to do this:
In the check constraint clause,
1) instr(upper(translate(column_name,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()"-_=+[]/?;:,.',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0000000000000000000000000000000000
0')),'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%' ...
....
....
Subject: Generators for Primary Keys
Keys?
If not, how do People get unique Integers for Primary Keys?
A -- 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;
73.
Subject: ROWID Arithmetic
Q -- Is it possible to do a sort of "rowid arithmetic". 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.
A -- 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 separated 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)".
74.
Subject: PLS-00323 error
Q -- 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
Subject: How to copy LONG column
I tried recompiling the database package header and body after changing the
Q -- I need to copy a long varchar from one table to another using UPDATE tab1 procedure name hoping it would work... no luck!
SET longcol = (SELECT longcol2 FROM tab2 WHERE tab1.key=tab2.key); But I
A -- According to my documentation, the Oracle PLS 323: subprogram 'name' is
get an error that this is an invalid use of a LONG column. How do I insert or update declared in a package specification and must be defined in the package body
a long column by copying a value from another column?
A -- The only way I have been able to do this is to use PL/SQL. Define a variable Cause: You placed a subprogram specification in a package specification, but
as LONG and open a cursor into the variable. From here you can manipulate the
neglected to place the corresponding subprogram body in the package body. The
variable in ways you cannot with straight SQL. Things such as substr, rtrim, instr,
package body implements the package specification, so the package body must
length, etc.
contain the definition of every subprogram declared in the package specification.
I hear Oracle8 will be able to handle LONG manipulations in SQL.
Action: Check your spelling of the subprogram name. If necessary, add the missing
71.
subprogram body to the package body.
Subject: PCTUSED - How can I display the value of a table?
Q -- Just a question regarding displaying some details about the table. How can I 75.
display the actual values of a table XYZ? I want to see PCTUSED, PCTFREE.
Subject: How to reconfigure shared-memory segment size in Sun Solaris
A -- You can do the following select:
2.5.1 kernel (SPARC)
SELECT owner, table_name, pct_used, pct_free
Q -- I am running Oracle 7.3.2 on a Sun SPARC 10. While setting up for the first
FROM all_tables
Designer/2000 repository, I modified the following init.ora parameters for a
WHERE table_name = 'XYZ';
particular database server instance to the values shown:
shared_pool_size = 18000000
db_block_buffers = 1000
global_names = FALSE
open_cursors = 200
70.
http://homepage.interaccess.com/~akaplan/oracle.html page 10
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?
A -- 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.
76.
into the operating 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.
A -- 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 owned 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
80.
Subject: table all_errors does not exist!
Q -- 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:
[...]
Q -- I have a Dec UNIX Alpha workstation ( one OS version down from most
ORCL> /
recent ) with Oracle 7.3.2 .
Warning: Package Body created with compilation errors:
I attempted to create a new tablespace with a datafile of 200mb.
ORCL> show errors
At 83mb of size the workstation crashed and I think generated a core dump. After
select to_char(line)||'/'||to_char(position) "LINE/COL", text
reboot the datafile of 83mb existed but was not known by the database. I deleted
"ERROR" from all_errors a where a.name = 'RMPATCH' and a.type = 'PACKAGE
the file and ran the same create script with a 50mb datafile. This succeeded. I did BODY' and a.owner = user order by line, position
notice that the system datafile was exactly 83mb ( seems like too much of a
*
coincidence to me)!
ERROR at line 1:
I did not personally install the OS or Oracle but I examined the install log files and
ORA-00942: table or view does not exist
they seem 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.
No errors.
A -- If you are using raw devices, then this could happen. If you or the UNIX
How can I recreate the table all_errors and why am I missing it?
admin created a volume of 83 Megs, then when creating a 200M file (or anything > A -- Your all_errors view should have been created when your database was
83M for that matter) it will crash at 83 Megs. If you create a smaller datafile (50M in created. Look in your create database log files for any error messages.
your case), it will still consume 83M of disk space, but only 50M of it will be
Regardless of how it was not created, you can recreate it by re-running the
available to Oracle. The extra 33M will just be wasted.
catproc.sql script which is found in the $ORACLE_HOME/rdbms/admin directory.
So, make sure you are allocating the needed size if you are using raw partitions.
Be sure to log in as the SYS user.
The catproc.sql script calls the catprc.sql script, which creates the all_errors view
77.
(among other views for stored procedures and triggers).
Subject: integer division
Since you had a problem with one view that should have been there, I would
Q -- Does anyone know how to force integer division? I’m subtracting 2 DATE
recommend re-running the $ORACLE_HOME/rdbms/admin/catalog.sql script as
types to get the number of days between them and then I need to divide by 7.
well to re-create all data dictionary views.
e.g:
to_char(date1,'j')-to_char(date2,'j')/7
81.
A -- It looks like you are trying to find the number of weeks between two dates.
Subject: writing ASCII data to oracle DB,HOWTO?
Oracle has a built-in date function for MONTHS_BETWEEN, but unfortunately none Q -- I am in the first stage of developing an utility to convert app. specific ASCII
for WEEKS_BETWEEN. To do this, you can:
data into an ASCII file, which data I want to "insert" into the ORACLE DB.
SELECT (TO_CHAR(date1,'j')-TO_CHAR(date2,'j'))/7
-Makes it sense to write the typical SQL commands like "SELECT * FROM ..." in
FROM dual;
my ASCII file around the data I want to insert (names and floating point numbers)
This will return a number such as .285714286. If you want this to be an integer, it into the ORACLE DB ? Or are there nicer ways ?
is up to you to decide to round up/down. The TRUNC and ROUND functions will
-What have I to do to bring (half)automatically this file into the ORACLE DB ? Any
suffice.
smaller examples or hints would be GREAT !
A -- All you need to do is use the SQL*Loader utility. It comes with the Oracle
78.
database. A full explanation is beyond the scope of an email, but you can learn
Subject: SQL*Plus / Windows NT / host commands
about it in the "Oracle7 Server Utility User's Guide".
Q -- I'm running Oracle Workgroup Server 7.3 on NT 4.0 and using SQL*Plus 3.3. It basically takes an ASCII file and loads it into Oracle tables, reporting any errors
I have in a script to automate backups a line, 'host zip [zipfile] [datafile]'. This
in a nice, consistent format. The files are easiest to load if they are in a tab/comma
should compress the database file into the zipfile. So what happens is the zip
delimited format, or a fixed-length format.
command runs in the background, control returns to SQL*Plus, and the script takes
The OS command is: sqlload keyword=value, keyword=value, ...
the tablespace out of backup mode. So how do I get it to wait for the zip to
or: sqlldr keyword=value, keyword=value, ...
complete?
For example,
A -- Don't run the zip command in the background. If for whatever reason you
sqlldr userid=scott/tiger control=controlfile.ctl log=load.log
need to run it in the background, then have the script wait until the zip process
The other part is to have a control file. An example is:
finishes. You can do this by checking processes or by creating temporary lock files.
load data infile data.txt
append into table TINO
79.
fields terminated by "," optionally enclosed by '"'
Subject: Hanging ORACLE database
(ID, Last_Name, First_Name, SSN, Eye_Color)
Q -- 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- 82.
deciphered times and the hanging is not due to a consistent set of jobs.
Subject: How to move a user's tables from one tablespace to another
The symptoms are also misleading. At one time, I could not log on as SYS. At
tablespace.
other times, I have not been able to look into dba_ tables ( but could get to the V$
Q -- I want to move a user's tables from SYSTEM table space to another table
views). At other times a select FIELD1 from TABLE1 shows n-number of rows and
space. Can anyone tell me how to do it without affecting operations?
then hangs.
A -- There are several methods to do this. You can either:
To solve this problem, I was initially shutting down abort (immediate was not
1) export the table, drop the table, create the table definition in the new tablespace,
doing the job) and then bringing up the database and then shutting it down and
and then import the data (imp ignore=y).
starting again. This solved the problem but the hanging repeated after a day or two 2) Create a new table in the new tablespace with the "CREATE TABLE x AS
again. The other approach I took was to "do nothing" and after returning the next
SELECT * from y" command:
day, the problem of hanging used to go away.
CREATE TABLE temp_name TABLESPACE new_tablespace
Now, there is NOTHING in the alert_logs or in the trace files. Called ORACLE and
AS SELECT * FROM real_table;
they started poking into ROLLBACK segments (I changed the OPTIMAL to 200K
Then drop the original table and rename the temporary table as the original:
from 10M). Nothing happened. They have since not returned my call. Have looked
DROP TABLE real_table;
RENAME temp_name TO real_table;
http://homepage.interaccess.com/~akaplan/oracle.html page 11
Subject: Dec Unix - Error on create TS datafile
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.
83.
Subject: Is there a solution for varchar2 !
Q -- 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.
I am writing in PL/SQL for the web.
A -- 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 forget 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.
84.
Subject: Is Oracle the worst-documented product of all time?
Q -- Most arguments seems to say that Oracle is too complex - it requires too
A -- 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.
88.
Subject: Performance Question
Q -- 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?
A -- 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 textbased "GUI-like" version, or "sqldba lmode=y" for a text-only version.
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!
A -- Just got Oracle8 - its documentation is in html format.
89.
85.
I receive this error message:
CREATE ROLLBACK SEGMENT rbs_1
*
ORA-00406: COMPATIBLE parameter needs to be 7.3.0.0.0 or greater
Subject: Size of physical datafiles
Q -- 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
physically 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 ?>?????
A -- 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.
Separate system, temp, rbs, tables, indexes, etc. according to the OFA guidelines.
Subject: Tablespace Creation trouble
Q -- 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;
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.
A -- 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.
90.
Subject: How Can I determine the size of My Oracle Database?
Q -- How Can I determine the size of my Oracle 7.3 Database? Is there a :
dictionary view that I can look at?
A -- The majority of the size comes from the datafiles. To find out how many
86.
megabytes are allocated by ALL tablespaces, type:
Subject: returning rows from stored proc
select sum(bytes)/1024/1024 from dba_data_files;
Q -- I'm trying to write a stored procedure to return rows, but not having any luck.
Add to this the size (in megabytes) of your redo logs:
In SQL Server, the rows from the last SELECT stmt in the stored proc is returned as
select sum(bytes)/1024/1024 from v$log;
data from the stored procedure. How do I do this in Oracle?
The above two queries will show you how large your database is. Also, if you are
A -- You will need to do two things. First, start the serveroutput:
in archivelog mode, you will generate files in your archivelog destination. Issue the
ALTER SYSTEM SET SERVEROUTPUT ON SIZE 100k;
following query to see where your archived redo logs get placed:
This will display the output buffer of stored procedures up to 100k. You can change
select * from v$parameter where name = 'log_archive_dest';
the 100k to suit your needs.
Next, in the stored procedure, use the DBMS_OUTPUT command:
91.
DMBS_OUTPUT.PUT_LINE('The row is ...'||column_a||', '||
Subject: rescuing index
column_b|| ... );
Q -- While loading in direct load state my index got locked after I kill the job. I
Note that no output will occur until the stored procedure has completed.
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
87.
having to truncate or drop the table? Any ideas?
Subject: Export/Import to migrate platforms
A -- Don't drop or truncate the table! You can just rebuild the index. I don't know
Q -- I had a whole bunch of tables with some data in them on one Oracle 7.3
what version of Oracle you are using, so I will describe one method to rebuild an
server on NT, I exported them out to a .dmp file, and imported them into a different index:
7.3 Oracle server on Solaris. Now, I can do selects and everything else I want to
1) Find out the columns of the index:
do, in SQL Plus, but my Netscape LiveWire apps can't select on them. I thought it
SELECT COLUMN_NAME
could be a tablespace issue so I dropped one of the tables that didn't have any
FROM USER_INDEXES
data in it and created it. Now I can select on it from everywhere, including my
WHERE INDEX_NAME = 'index_name';
LiveWire app.
2) Find out the storage parameters of the index:
Could something be attached to the tables due to the export from NT into
SELECT UNIQUENESS, TABLESPACE_NAME, INITIAL_EXENT,
Solaris?
NEXT_EXTENT, MIN_EXTENTS, MAX_EXTENTS,
http://homepage.interaccess.com/~akaplan/oracle.html page 12
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.
92.
Subject: Database can’t start - missing datafile!
Q -- Recently I have tried to recreate a TEMP tablespace. I have removed the
datafile instead of dropping the tablespace first, now I am unable to drop the
tablespace because it is 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.
A -- 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;
93.
Subject: How to find how many rows in each table in database?
Q -- 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.
A -- 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
96.
Subject: how to solve it?
Q -- 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?
A -- 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.
97.
Subject: how to determine free memory in Oracle
Q -- 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?
A -- 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.
94.
98.
Q -- Have you ever seen where the tablespace for rollback segments becomes
Q -- We have a lot of inserts into our database( some tables); sometimes the
Subject: Rollback tablespace fragmentation
so fragmented that a rollback segment can't get the next extent?
A -- 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.
95.
Subject: Inserts too slow
function ( Proc*C) that does inserts takes 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 separate 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 an answer to that problem?
A -- 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).
Subject: select and update by row number
99.
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.
A -- 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;
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 using 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 apologize if I am mistaken. Maybe it's in Version 8???
A -- 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?
Q -- I am taking a CMIS course on databases. I am trying to update and query my Subject: DB_BLOCK_SIZE: Possible Misinformation
database by row number. I have a table with 12,410 records in it. I need to query
Q -- In regards to changing the DB-Block_Size without re-creating your database,
100.
Subject: What Happens if...
Q -- 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?
http://homepage.interaccess.com/~akaplan/oracle.html page 13
If so, what is the name of the buffer? or does the transactions that I am
updating/deleting/etc...spew to nowhere?
A -- 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.
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.
106.
Subject: Invalid status after successful run of procedure
Q -- 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
Subject: Oracle 8 on HP/UX 10.x
using dbms_sql and later uses the newly created view.
Q -- Where can I get Oracle 8 on HP/UX 10.x?
The procedure runs fine, except that it gets invalid after successful run. Every
A -- You have to call Oracle Corp (or see them at www.oracle.com). They can sell object that it uses is still valid. Surprisingly, doing an " alter procedure p_name
you a copy. If you already have Oracle7, you may be eligible for a free or lower-cost compile " sets it fine again.
upgrade. This will depend on your service agreement.
A -- What is happening is that while the procedure runs, it is dropping an existing
For HP/UX, you need 10.2 for Oracle8 to work.
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.
102.
You should look at the DBA_DEPENDENCIES view for a list of all objects that the
Subject: How to display date and time from 'Select Sysdate...'
procedure "depend" on. If any of these objects are dropped or become invalid, then
Q -- My target is to display system date and time at same time. I can do this on
your stored procedure will also become invalid.
MSSQL Server without any problems. But, I can't do it on ORACLE with sentence
like this:
107.
SELECT SYSDATE FROM DUAL;
Subject: Password after installation???
unexpected output
Q -- I downloaded Oracle 7 Server (140MB via WWW - puh!) and installed it. After
01-AUG-97
the installation I tried to start the enterprise manager and was I asked for a
expected output
password I didn't define during the installation. So - what's that? I cannot open my
01-AUG-97 12:35AM.
software because of some password someone else created.
If you know how to change system default datetime format, please give me a help.
I couldn't find anything about such a default log-in in the documentation.
A -- You will need to use the TO_CHAR function. For your needs, type:
Please help me with the following information:
SELECT TO_CHAR(SYSDATE, 'DD-MON-YY H:MIPM') FROM DUAL;
- What user id and password must be typed in to log in?
You will get a response like
- What service must be typed in?
04-AUG-97 10:19AM
A -- The default usernames and passwords (which should be in the
documentation) are:
103.
SYS
change_on_install
Subject: Default value of pct_increase
SYSTEM
manager
Q --According to the Oracle manual (Oracle 7 Server SQL Language Reference
SCOTT
tiger
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 108.
(can the dba have done this ?).
Subject: Moving Datafiles
To check this, I did the following in SQL*Plus :
Q -- Is it possible to recreate the control file with the new locations of the data
SQL> create table marc (x number);
files? ie. after connecting as internal, run "alter database backup controlfile to
Table created.
trace". This will create a .trc file in the log directory. Can I then edit this file after
SQL> select pct_increase from user_tables where table_name = 'MARC';
moving the data file/s and then use this file to recreate the control file?
PCT_INCREASE
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.
0
A -- Yes, this is one of the best features of the "create controlfile" script. Simply
Is there any reason why it is always set to 0 (not only in this example)?
modify the locations of the datafiles and run the script. I have done this many times.
The Oracle version is 7.3.2.3.0 on HP-UX.
109.
A -- 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 Subject: NUM_ROWS statistic incorrect
Q -- We run Oracle 7.2.2.4 on HP-UX 10.20. I queried user_tables logged on to
to 0. To find out, try:
SQL*Plus as the user who owned the tables I wanted to look at. In the field
SELECT * FROM DBA_TABLESPACES
num_rows a value was returned that in many cases differed from the number of
WHERE TABLESPACE_NAME = 'tablespace_name';
rows I would get by directly querying the specific table with the "select count(*) from
When an object such as a table is created in this tablespace, it will take the
tablename" query. Can you explain the discrepancy.
default storage parameters if not supplied in the CREATE TABLE command.
A -- The reason that you are getting a different number in the NUM_ROWS
104.
column in the USER_TABLES (or ALL_TABLES or DBA_TABLES) views than the
Subject: Oracle long field attribute - length
actual value is that NUM_ROWS is updated only when you analyze the table.
Q -- Anyone know of a way to determine the length of an attribute defined as a
For example, if your table has 1000 records and you issue:
long? The length function does not work with the long attribute.
ANALYZE TABLE table_name COMPUTE STATISTICS;
A -- You cannot do string functions on LONG columns with regular SQL. You will
The NUM_ROWS column at that point will be 1000.
have to use PL/SQL. Look at the following example:
At this point, if you insert 1000000 records, and do NOT analyze the table
SET SERVEROUTPUT ON SIZE 10000;
again, you will have 1100000 records, but NUM_ROWS will still be 1000.
DECLARE
110.
long_var LONG;
Subject: Extents, Blocks, etc. - can anyone point me to help?
BEGIN
Q -- I've had a lot of trouble lately with Oracle extents and blocks. None of the
SELECT text_column INTO long_var
books I've seen on the subject seem to make any sense to me. Can anyone point
FROM table_with_long
me to a good one, or to an FAQ about the topic? What are extents, how do they
WHERE rownum < 2;
work, what do they do; what are blocks, what size are they, and how does one
DBMS_OUTPUT.PUT_LINE('The length is '||LENGTH(long_var));
manage tables that are running into their maximum number of extents? How do
END;
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,
Basically, you define a variable as the LONG type, then SELECT the column
particularly
help that would point me to a resource that would explain all of this. I've
INTO the variable. Finally, it is output to the user. SET SERVEROUTPUT ON SIZE
tried "Oracle Unleashed," "The Oracle DBA Survival Guide" and "Tuning PL/SQL"
10000 allows spooling from the PUT_LINE to go to the screen.
all to no avail, although the "DBA Survival Guide" is a good book. It's just not
105.
explaining things simply enough.
Subject: Shutdown NORMAL not working
A -- A great explanation is in the Oracle "Concepts Guide". Basically, a table (or
Q -- I am a recent graduate into DBA we run oracle 7.3 on windows nt4.0
index or cluster) is stored within a tablespace. A tablespace is a collection of one or
platform I am enclosing my pfile with this mail please help me in changing it or to
more datafiles, which are physical files on the computer's disks. To find which
correct it as I have problems in shutting down the database. I can shut down in
tablespaces you have, type:
immediate and abort options but if I do shut down in normal its taking lot of time i.e.
SELECT TABLESPACE_NAME FROM DBA_TABLESPACES;
hours so I had to do a immediate shut down.
To find out which data files you have (and their locations), type:
A -- The reason that your SHUTDOWN in normal mode is taking so long does not
SELECT FILE_NAME, TABLESPACE_NAME, BLOCKS
have to do with your pfile. The reason is that when you do a SHUTDOWN normal,
FROM DBA_DATA_FILES;
http://homepage.interaccess.com/~akaplan/oracle.html page 14
101.
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.
Wait for the import to finish.
===============================================================
111.
Q -- I am trying to import loads of records to an Oracle table but keep having the
Subject: export table a 10 gig table
112.
Subject: How to set default initial extent when creating new table
Q – I’ve got a problem about Oracle V8 on NT. When Oracle creates new table, if
initial size of extent is not specified, ORACLE sets initial extent to 1M. It will waste
a lot space for a small temporary table. But the instance’s db_block_size = 8k. How
to set default initial size of extent.
A -- 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);
113.
Subject: ORACLE Import
error (in .log file)
' ORA-01631: max # extents (50) reached in table TRAINS_DATA
A -- If you have Oracle8, you can partition the table and export each partition
LOAD discontinued'
individually. Otherwise, check out the tip from Oramag
The maxextents parameter is set to 50 for this table. Can I set Maxextents to
(http://www.oramag.com/code/tip01168.htm):
unlimited?
Is there a problem with the size of the table itself or INITIAL etc settings? What
TIP OF THE WEEK January 16, 1998
about PCTINCREASE?
Here is the create table statement:
Exporting a Database That's More Than 2GB When Compressed
CREATE TABLESPACE boxsheet
This Tip of the Week entry comes from Devarajan Sundaravaradan, a Senior
DATAFILE '/oradata/boxt/box_data' size 100M
Consultant for Leading Edge Systems, Inc. in Edison, New Jersey.
DEFAULT STORAGE (
In HP-UX, there is a 2GB limit on file sizes of 2GB. Many of us have reached this
INITIAL 50K NEXT 50K
limit when exporting files and the most common solution is to do a filesystem
MINEXTENTS 2 MAXEXTENTS 50
compression of the export dump using named pipes and then store the compressed
PCTINCREASE 0)
file. But what if the compressed file itself passes the 2GB limit? There is solution to
ONLINE;
this, too.
A -- 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
---------------- Export Section
used. Otherwise, it looks like the table will be 50k initial, 50k next. Since you are
# Create new Named pipes.
running out of extents at 50, your table will be at least 50k*50 = 2.5M, if not more.
mknod -p /dev/split_pipe
So, change the storage parameters to 3M initial 3M next and try again. You should
mknod -p /dev/compress_pipe # You can use the existing named pipe
create the table with the appropriate size and no data, then import with IGNORE=Y
# itself, instead of creating new.
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.
Create a shell script under a file, named Split_export.sh
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.
# -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
114.
# file name specified. The export file name is expfile.
Subject: Finding duplicate rows in a table
nohup split -b1000m < /dev/split_pipe > /DumpDir/expfile &
Q -- I don't know how, but when I try and copy one of my tables to another server
nohup compress < /dev/compress_pipe > /dev/split_pipe &
across the net, I get a constraint violation on the primary key. How can I find the
exp username/password full=y file=/dev/compress_pipe (and other parameters for
rows in the original table that have duplicate primary key information (the primary
export.)
key consists of two columns).
=============================================================== A -- You are most likely getting the primary key constraint violation because:
After saving the above three commands in split_export.sh, execute the following.
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
chmod a+x split_export.sh
values in it.
nohup split_export.sh > /tmp/split_export.log 1>&2 &
To see the duplicate records, follow the example below:
===============================================================
You are inserting records from TABLE B into TABLE A, and the primary key on
After a few minutes you should see files in the export dump directory.
both tables is COLUMN A and COLUMN B. Issue the following query to find the
=============================================================== duplicate records:
SELECT * FROM TABLE_B
------------------ IMPORT Section
WHERE (COLUMN_A||COLUMN_B) IN
===============================================================
(SELECT COLUMN_A||COLUMN_B
Create a shell script with the following command under the file name
FROM TABLE_A);
split_import.sh. After creating provide execution permission to this script as
To find if there are any duplicate values in TABLE_B alone (if there is a primary
follows:
key then there will be no duplicates) type the following:
===============================================================
SELECT COUNT(*), COLUMN_A, COLUMN_B
Chmod a+x split_import.sh
FROM TABLE_B
# The import script assumes in this example that the above export script created 2
GROUP BY COLUMN_A, COLUMN_B
# split files called expfileaa and expfileab. The order of the file for the cat
HAVING COUNT(*)>1;
# command is very important.
115.
nohup cat /dumpdir/expfileaa /dumpdir/expfileab > /dev/split_pipe &
Subject: DELETE COMMAND
Q -- Does anybody know about the DELETE command where when you issue a
# sleep 3 seconds
delete * from table it does not go into the rollback segment but gets deleted
Sleep 3
immediately and cannot be recovered.
nohup uncompress < /dev/split_pipe > /dev/compress_pipe &
A -- Use the TRUNCATE command. This will skip all triggers, rollback segments,
redo logs, etc.
#Sleep at this point is very important as some time is needed to uncompress the
# file and send it to the pipe.
116.
sleep 60
Subject: OFA, utlbstat/utlestat
imp username/password file=/dev/compress_pipe and other parameters for export. Q -- I am being asked by some DBAs about the performance of my database I
nohup split_import.sh > /tmp/split_import.log 1>&2 &
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
http://homepage.interaccess.com/~akaplan/oracle.html page 15
Q -- How can I export a 10 gig table when the max UNIX file size is 2 gig?
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 compliant? If you don't have
the time, I understand. You just seem to be the only one I ever get a response
from.
A -- 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...
Q --
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.
A -- Hit ratio is pretty good. Anything less than 85% should be an indication to
increase the DB_BLOCK_BUFFER size.
Q --
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
A -- 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...
Q --
free memory
10,844
A -- 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!
117.
Subject: Index REBUILD vs. DROP/CREATE
Q -- I am a DBA trainee at Nokia. Am doing my final year project on "Coalescing
Free Spaces During Index Recreation".
Over here, 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 difference between these two syntax?.
A -- 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 storage 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.
Q -- (2) which one is faster and more accurate.
A -- REBUILD is faster with the UNRECOVERABLE clause, and if done in
parallel.
Both are equal in accuracy.
Q -- (3) which one eliminates fragmentation as we recreate indexes for the large
tables.
A -- They both eliminate fragmentation
Q -- (4) could you please explain the "ALTER index REBUILD command for me
as I have just started using Oracle.
A -- 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.
Q -- (5) could you please, explain index recreation to me.
A -- Please see above.
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?)??
A -- 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 great 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.
119.
Subject: Writing Ampersands to fields
Q -- Can you write a string containing Ampersands to a field in Oracle? I don't
seem to be able to do it.
A -- Try the following in SQL*Plus:
SET ESCAPE '^'
SELECT 'Here is an ampersand: ^& - cool, huh?'
FROM DUAL;
120.
Subject: Export speed too slow
Q -- In my company, there are 10mb data to export , but it take me about 10 hours
to export , does this sound normal or do you have some way to speed up the
export?
oracle 7.1.3 for DG
A -- 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
121.
Subject: How to detect objects approaching MAXEXTENTS
Q -- 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-organize
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?
A -- 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 overwritten 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;
118.
Now, to find all objects that are nearing the MAXEXTENTS, you can do the
Subject: Simple SQL Question from a beginner
following (assuming it is 3 extents or less away from MAXEXTENTS):
Q -- I've downloaded and installed the trial version of the Workgroup Server 7.3
SELECT SUBSTR(owner||'.'||segment_name,1,50) OBJECT,
on a Solaris 2.6 platform. I'd like to try some simple things out before buying the full
EXTENTS, MAX_EXTENTS
blown version. I've been using PostgreSQL and have a simple little table that
FROM DBA_SEGMENTS
includes some arrays. Can anyone tell me how to implement arrays in sqlplus?
WHERE MAX_EXTENTS - EXTENTS < 4
This is what I tried along with the error it gave me:
ORDER BY EXTENTS;
http://homepage.interaccess.com/~akaplan/oracle.html page 16
122.
126.
Q -- I have a table that consists of two fields a varchar2 and a long. I want to
Q --
Subject: replicating LONGS
replicate this table but I have tried 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.
A -- 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.
123.
Subject: about database setup
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 system is saying background process PMON not started...
Can anybody help on this how to solve.....
A -- 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.
Subject: How to get multiple rows via a stored procedure
127.
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.
A -- 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
Q -- I am using ANALYZE TABLE COMPUTE STATISTICS; and then selecting
Q -- I am developing an application in VC++ and accessing the Oracle database
124.
Subject: temporary segments
Q -- I'm running oracle 7.3.2 on Irix and hp-ux. I've noticed that sometimes
temporary segments are left in the temp tablespace long after the sort or group-by
that created them has finished. Is this normal behavior? Does oracle reuse those
segments?
A -- 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.
Subject: Analyze question
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
include Header space per row also? :
A -- 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.
128.
Subject: L decoding Oracle password
Q -- 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?
A -- Oracle compares the encoded passwords on each database. If there were an
algorithm to decode the passwords, we'd all be in trouble.
129.
Subject: Clearing rollback segments
Q -- 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?
A -- Since you are using Oracle 7.3, you 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;
130.
Subject: How do I put an & in a varchar2
Q -- 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?
A -- 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
131.
Subject: DESC tables
Q -- 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 screenfull at a time?
Subject: US7ASCII and Oracle 6.0
A1 -- Try this:
Q -- I would be thankful to you, if U could tell me how I exp a 7.3 or 7.x database
SET PAGESIZE 23
(tables) to 6.0.33 DB.
SET PAUSE "Press Return to continue"
I have all methods spec. by oracle. ie. run script catexp6.sql and then oracle 7
To see the next screen, press Return.
exp. But I am facing problems with character set, i.e. Oracle 6 character set is
Hope this helps.
US7ASCII, whereas 7.x is WEISO... Even I have oracle db with US7ASCII
A2 – Answer #1 does not work for the DESC command. The description of a
character set. But no way I could import the data to 6.0
table or view (or procedure, etc.) will scroll off of the screen even if PAUSE is set.
A -- That's a good question. I believe the only way is to change the
The only method I use is to SPOOL to a file, do the DESCRIBE, and then SPOOL
COMPATIBILITY parameter in the PFILE file to "6.0.33". Do this for the 7.x
off. You can then view the contents of the file.
database. Then export and import into the 6.0.33 db.
When it is successfully imported, remove the COMPATIBILITY line in the PFILE.
125.
http://homepage.interaccess.com/~akaplan/oracle.html page 17
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
Q -- We have various programs (PL/SQL, SQL, FORMS/3 and REPORT/1), that two to three times. Can anybody help me on this.
we must to convert to year 2000. Same tests were done, but the results were not
A1 -- You probably have an auto-start of the database when your Solaris sparc
good. Anybody knows how we can work with the function to_date, that dates are
boots up. This is usually in the /bin/init.d or /sbin/init.d directory.
stored with 2 positions for year, and convert for 4 positions.
Look for "dbstart" or "oracle" files.
A -- To convert a string to a date format (for inserting into a DATE field), use:
If you do not want this to happen, you should change your "/etc/oratab"
TO_DATE(string,'DD-MON-YYYY')
file and put an "Y" next to the instances you DO want to come up, or a "N"
To convert a date field (such as SYSDATE) to a string, use:
next to those that you do not.
TO_CHAR(date_field,'DD-MON-YYYY')
: 2) After creating the new database and bringing up the database and running the
This will assume a date in the format of "18-SEP-1997". There are other options
SQL file to create a profile I am getting the error saying that "Table or view doesn't
for formatting. See my web page more much more information on this subject.
exist" and one more thing is I am not able to start pl/SQL can anybody help
regarding this.
133.
A2 -- You cannot start "PL/SQL". I assume that you mean "SQL*Plus". Check
Subject: Connecting to DB from home
Q -- I am running ORACLE 7.2.2.4 on a Windows NT 3.51 server. How can I take 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
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 executable will be found.
As for "Table or view doesn't exist", what table is this? Which file did you run to
to do this as it will enable me to rebuild the database from home.
create the profile? Most scripts DROP the table/view and then CREATE the
A -- There are two ways that I do DBA work from home:
table/view. Thus, if it is the first time you run the script, you will get a "Table/view
1) Use the "dial-up networking" option of Windows95 to establish a connection, then does not exist" followed by a "Table/View created."
connect to the same network as the NT server. SQLDBA72 should work. You
138.
should start using Server Manager, as SQLDBA is no longer supported in
Subject: ORA-00984
Oracle7.3.
Q -- I am trying to insert data into a table, keep getting an error message that
says:
2) Telnet in to the NT server, and use SQLDBA72 or SVRMGRL to do DBA
error at line ... .
functions.
ORA-00984: column not allowed
I am fairly new an don't understand why column not allowed. I am using Oracle 7
134.
server release 7.2.3.0.0
Subject: Multiple CPUs help
Any ideas will greatly appreciated, and sorry for the beginner stuff !
Q -- We just added two more CPU's to our ORACLE 7.3.3.0.0 server (a Sun
Here is the definition of the table which is a part of several tables in my
Ultrasparc 4000 running Solaris 2.5) bringing the total up from 2 to 4 but have only
schema.
seen a slight (16%) improvement in even the most processor intensive PL/SQL
create table consultant
blocks.
(
Do we have to make any changes to ORACLE in order to optimize it for the new
cid
NUMBER(5)
CPU's...?
,cname
VARCHAR2(15)
Does anyone know of a script that can generate some system stats for
,cssn
NUMBER(9) PRIMARY KEY
performance tuning in general..?
,cphone
NUMBER(10)
A -- To take advantage of additional CPUs, in your initSID.ora file add the line:
,chrate
NUMBER(5)
cpu_count=4
,pname
VARCHAR2(15)
This will have Oracle take advantage of your 4 CPUs. As for tuning scripts, try
,hours
NUMBER(10)
$ORACLE_HOME/rdbms/admin/utlbstat.sql and
, FOREIGN KEY(cid) REFERENCES address(cid)
$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
A -- The lines above should read
email. The scripts have documentation to guide you further.
,hours
NUMBER(10
135.
) FOREIGN KEY(cid) REFERENCES address(cid)
Subject: Export Utility
Q -- I am attempting to issue a simple export on an ORACLE 7.2.3 instance. I am The table was created improperly.
receiving the following errors
EXP-00008: ORACLE error 6553 encountered
Here are part of the insertion sql*plus commands:
ORA-06553: PLS-213: package STANDARD not accessible
accept ssn number EXP-00222:
prompt "enter consultant social security number(required): "
System error message 2
accept consid number EXP-00008: ORACLE error 6553 encountered
prompt "enter consultant id number: "
ORA-06553: PLS-213: package STANDARD not accessible
accept name char EXP-00000: Export terminated unsuccessfully
prompt "enter consultant name: "
It looks like a script needs to be run, before issuing an export, does anyone know accept phone number the name of the script(s) ? P.S. I did run the 'standard.sql' script as 'internal'
prompt "enter consultant phone number: "
A -- Log in as SYS and execute both
accept rate number $ORACLE_HOME/rdbms/admin/standard.sql and
prompt "enter consultant hourly rate: "
$ORACLE_HOME/rdbms/admin/dbmsstdx.sql
accept prname char prompt "enter project name: "
136.
accept whours number Subject: Checking the used memory
Q -- I would like to know how to check the used memory resource in an Oracle prompt "enter hours worked: "
insert into client(cid) values(&consid);
Developer/2000 application.
insert into consultant(cid,cname,cssn,cphone,chrate,pname,hours)
A -- To find the memory usage, if you are on UNIX you can do "top" and look at
values(&consid,&name,&ssn,&phone,&rate,&prname,&whours) ;
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:
139.
SELECT * FROM V$SGA;
Subject: dbms_output.put_line
will show the fixed size and variable size of memory, along with the database
Q -- I want to display some numbers with dbms_output.put_line but I don't know
buffers and redo buffers. You may also do:
how to show them nicely in columns like this:
SELECT * FROM V$SGASTAT;
col1 col2
to give you the size of over 30 portions of memory.
1 100
10 20
137.
100
1
Subject: On Oracle architecture
200 300
Q -- I am observing some strange behavior in oracle can any body help me how
A -- It's not pretty, but it works:
it is.
DBMS_OUTPUT.PUT_LINE('col1 col2');
I have oracle 7.2 installed on Solaris sparc stations.
132.
Subject: New Century
http://homepage.interaccess.com/~akaplan/oracle.html page 18
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 leftspaces to fit four characters and ten characters.
140.
Subject: rollback segs problem 7.3.2.3 -> 7.3.3.0
Q -- 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.
A -- I will quote my Oracle documentation, which will solve your problem:
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.
143.
Subject: How do you read REDO logs?
Q -- 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.
A -- 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.
144.
Subject: Archive log performance
Q -- 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?
141.
Is there a way to set it so it doesn't uses a lot of system resource?
Subject: Creating a second instance
I though the information written to the archivelog is update/delete/insert not select.
Q -- I have to create a second Oracle instance. My platform is Unix and I am
am I right ?
running Oracle 7.3.2. My background is NT and I'm a little shaky working with Unix. A -- Archivelog does not use up much resources. Your slower performance could
Could someone please tell me if the following steps are correct for creating a
be due to three things:
second instance. Am I leaving steps out? Are there concerns that I should have or 1) You are putting your archive directory on the same drive as your redo logs. This
things to look out for?
will be bad for performance, and should be put on a separate drive, hopefully on a
(1) Set the environment variables ORACLE_SID to the new instance name.
low-activity device.
(2) Create the new instance using oradim73.exe
2) Your redo log files are sized too small, and this is causing frequent redo log
(3) Connect internal
switches. Increasing the size of all redo logs will improve this
(4) startup the instance using the new initxxx.ora file w/NOMOUNT
3) Your archive volume's disk has filled up. If this is the case, your database will
(5) create the new database ... etc ...
more than slow down - it will effectively stop (except for SELECT statements). Be
A -- You will have to first make directories, if you want to be OFA compliant. I
sure to remove old archive logs daily, and monitor your free space on the device
strongly recommend this, especially if you plan on having more than one instance
with archive log files.
on your server, which you indicated you do. To do this :
145.
* Make $ORACLE_BASE/admin/$ORACLE_SID/bdump,
Subject: 7.3.2.init.ora parameters
$ORACLE_BASE/admin/$ORACLE_SID/cdump,
Q -- I was surprised to learn that the default value for the parameter,
$ORACLE_BASE/admin/$ORACLE_SID/udump,
COMPATIBLE is not the current release. We are installing Oracle for the first time,
$ORACLE_BASE/admin/$ORACLE_SID/pfile directories, owned by the
we have release 7.3.2, are there any other parameters that must be set so we get
"oracle" userid and the "dba" group.
the benefits of the release we purchased? Is there a list of all the possible
* Create an init.ora file, called "init$ORACLE_SID.ora" in the pfile directory.
parameters and an example of setting each one?
Oracle supplies sample files, or you can use the one from the other instance,
A -- Since there are several hundred parameters, I will not attempt to explain
and change the file to reflect the new $ORACLE_SID.
them all in this email. There are many books that explain most of the important
* Make a "soft link" in the $ORACLE_HOME/dbs directory. Since you not a
ones. I recommend "Oracle Performance Tuning" by O'Reilly. I would recommend
UNIX type, you can issue the following commands:
the book I am co-authoring "Oracle8 How-To" by Macmillan/Waite Group,
cd $ORACLE_HOME/dbs
ln -s $ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora but it won't be out until a few weeks.
To see all parameters, and an example of each, go into Server Manager (svrmgrl),
init$ORACLE_SID.ora
issue
CONNECT INTERNAL, and then issue SHOW PARAMETERS.
* Create the volumes for your data files, owned by "oracle"/"dba".
* Connect to SERVER MANAGER:
146.
svrmgrl
Subject: INDEXFILE with exports
> CONNECT INTERNAL;
Q -- Our backup of the ORACLE users are taken through export utility, with
connected.
INDEXES=N option. This fastens the export process and also the importing of data
> CREATE DATABASE ....
becomes easy whenever required. We then create the indexes on the objects of the
* Update your /etc/oratab file (see below)
table. We have written a pl/SQL code for spooling the indexes of each user and
* If using SQL*Net, update your listener (vi
submitted it as a job. This script will create a spool file with the 'create index ....'
$ORACLE_HOME/network/admin/listener.ora) and add the instance. Then,
statements, along with all the other parameters for that index. The problem is ,
restart the listener:
where should we look for the parameter about if the index created with
lsnrctl stop
'ASCENDING' / 'DESCENDING' option ?
lsnrctl start
A -- An easier method is to do "exp full=y INDEXFILE=cr_indexes.log".
Q2 -- Also, what do I have to do to ensure that this instance will be automatically The INDEXFILE will spool all CREATE INDEX statements (with storage parameters
started on reboot. ( I didn't set up the first instance and I am not a UNIX person).
and everything else) to the cr_indexes.log file. Note that Primary Keys are not
A2 -- You need to modify your /etc/oratab file. It should contain a list of all
included.
instances, followed by the Oracle home and a Y/N. Set the value to Y if you want to
147.
bring up the database automatically during a reboot.
Subject: Shutdown immediate problem
Also, you need to put Oracle's dbshut and dbstart in the proper directories. This
Q -- Has anyone ever done a shutdown immediate which did not shut down at all
will depend on your UNIX environment.
Usually, K100oracle or dbshut goes in the /sbin/rc1.d directory, and S9000oracle ? 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.
or dbstart goes in the /sbin/rc2.d directory.
A -- If someone is in the login process, then "shutdown immediate" will not work,
142.
and will hang. Eventually, you will see a trace file saying "waiting for logins to
Subject: Is it possible to pass args. to a SQL script?
complete". For example, try issuing sqlplus, but when it prompts you for a
Q -- I have a SQL-script in a file which I execute from SQL-plus, but is it possible username/password, do not enter anything. Open another window and try
to pass arguments when I execute this script?
"shutdown immediate". You will see that Oracle will not shut down.
A -- To pass parameters to a SQL-Script, simply separate them with a space. For
You will either have to shutdown abort, or have a program kill all oracle
example:
connections and then to a shutdown immediate.
SQL> @script.sql parameter1 parameter2 parameter3
148.
In the SQL-Script, refer to the parameters as &1, &2, and &3.
Subject: Determining max concurrent users
Q -- 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
http://homepage.interaccess.com/~akaplan/oracle.html page 19
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.
A -- 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'
149.
Subject: Memory & Oracle
Q -- We have an HPUX (HP 9000)system 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?
A -- 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 a
lot 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)
150.
Subject: ORA-600
Q -- I am running oracle 6 on sco Unix v3.2.4.2. today I encountered an error:
oracle error 600 encountered
interal error [4147] [17] [16]
Now I can't access my application database.
A -- 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.
A -- 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.
153.
Subject: How to rebuild indexes quickly.
Q -- Could you help me with a script which creates and drop indexes and then
uses the alter index rebuild command to rebuild the index.
Is it possible that you can alter index ( change storage parameters) then use
rebuild index. does it work?
A -- 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.
154.
Subject: Renaming a database
Q -- 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?
A -- 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
151.
database there. Shut down the database. Set the ORACLE_SID environment
Subject: Finding the total rows in the database.
variable to the new SID name. Move all datafiles to new directories per OFA
Q -- How can we calculate the total number of rows in oracle database and in this compliance. Modify the trace file again to reflect the file locations, and run the script.
way get size of database?
3) Be sure to modify all scripts that point to the old SID, and change the GLOBAL
A -- There are three ways that come to mind to find the number of rows in the
name so that Oracle's networking software can properly determine the database
database:
when making connections.
1) Use the ANALYZE built-in package to estimate or compute statistics for all users,
Please read the documentation on the CREATE CONTROLFILE command, as I
then issue
cannot take responsibility for anything bad that may happen.
SELECT SUM(NUM_ROWS) FROM ALL_TABLES;
2) Export the database with FULL=Y. The output of the export will display the
155.
number of records for each table. You will manually add the numbers.
Subject: Selecting constraints from the dictionary
3) SELECT COUNT(*) from all tables. Since there could be a large number of
Q -- Is there a way to select all of the constraints on a table except the not null
tables, you can write a script to dynamically create another script:
ones? The problem I'm encountering is that if I try to say
set header off
SELECT * FROM USER_CONSTRAINTS
set feedback off
WHERE TABLE_NAME = 'MYTABLE'
spool count_it.sql
AND SEARCH_CONDITION NOT LIKE '%IS NOT NULL'
SELECT 'SELECT COUNT(*) FROM '||owner||'.'||table_name||';'
I get an error stating basically that SEARCH_CONDITION is a LONG datatype.
FROM ALL_TABLES;
If I try to join USER_CONSTRAINTS, USER_CONS_COLUMNS, and
spool off
USER_TAB_COLUMNS to see if USER_TAB_COLUMNS.NULLABLE 'N', then it
Now, you have a script, "count_it.sql" that contains multiple SELECT COUNT(*)
excludes ALL constraints on the not null columns, not just the NOT NULL
statements. Run count_it.sql and add up the totals.
constraints (i.e. there could be a not null constraint *and* a check constraint on a
The above three methods are good to find the number of records. Since there is
column).
overhead, such as free space within a block, and since each table has differing data A -- You cannot do string comparisons on LONG columns in SQL. You have to
and column types, the number of records does not always give an indication of the use PL/SQL. I wrote a script for you to do your request:
size of the data. To do this, type:
DECLARE
SELECT COUNT(distinct substr(rowid,1,8)) FROM table_name;
constraint_text long;
This will give the number of physical database blocks that the table data occupies.
c_name varchar2(100);
Usually a database block is 2k, 4k or 8k. You should be able to get the block size by
c_type varchar2(100);
looking at your initSID.ora file or configSID.ora file. Do the above script for all tables.
c_owner varchar2(100);
c_table_name varchar2(100);
152.
cursor CONSTRAINTS is SELECT table_name, owner, search_condition,
Subject: Determining and changing ROLLBACK sizes
constraint_name, constraint_type
Q -- Please guide me how to determine the size of ROLLBACK SEGMENTS after
FROM dba_constraints;
creation of database.
BEGIN
How will you change the size of ROLLBACK SEGMENTS according to
OPEN CONSTRAINTS;
Application requirements.
LOOP
http://homepage.interaccess.com/~akaplan/oracle.html page 20
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;
/
156.
Subject: Instance Startup Parameters
Q -- 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?
A -- You can use the PFILE parameter:
STARTUP PFILE=/home/oracle/test/initTHESID.ora
157.
Subject: Reducing Buffer Cache Misses
Q -- Suddenly my buffer cache miss rate has jumped from a comfortable 5-6% to
65%. We have a lot more users and a lot more hits. Could anyone direct me to
information that would help me reduce the buffer cache misses?
A -- 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
maintenance routine.
158.
Subject: SQL Quiz
Q -- 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.
A -- 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.
159.
Subject: Removing Columns from a Table
Q -- Is there an easy way to delete empty columns from a table?
A -- 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? ;)
160.
Subject: Oracle8.0 for Windows NT
Q -- 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
what the maximum number of tables is and the maximum number of columns in a
table and max rows per table are?
A -- 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.
161.
Subject: Password Expiration Methods
Q -- We currently use RACF at the mainframe to set password expiration
methods.
We are about to move our Oracle Database 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?
A -- 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 Orlando, Florida.
162.
Subject: ORA-1555 Snapshot Too Old
Q -- 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 (initial 128K, next 128K,
optimal 256K) And I have 2 rbs tablespaces, the first 50M, the next 100M. What do I
need to increase?
A -- 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
163.
Subject: Finding which users hog the system
Q -- Suddenly the server performance became sloooow. I would like to find which
users occupy more space.
A -- 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.
http://homepage.interaccess.com/~akaplan/oracle.html page 21
164.
Subject: Converting LONG to VARCHAR2
Q -- Is there any conversion function or method to convert a Long variable type
into a varchar2? (varchar can be v. large...2500+).
A -- 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;
/
165.
Subject: Applying REDO logs Twice
Q -- 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 ?
A -- 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.
166.
Subject: How to learn SQL and PL/SQL
Q -- 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).
A -- 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.
A -- 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.
168.
Subject: Toolkit II Problem with Server Manager
Q -- 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 below 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.
A -- 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".
169.
Subject: Primary Key design
Q -- 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?
A -- 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.
170.
Subject: Import into a non-empty table
Q -- Forget the first question of the day. I have found 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
A -- 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.
171.
Subject: Oracle error when writing, deleting large amounts of data
Q -- 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
A -- 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
167.
segments. If you feel that many processes will benefit from larger rollbacks, then
Subject: Becoming Oracle Certified
drop and recreate the segments with a much larger initial and next storage clause.
Q -- I enjoyed your Web site! I was wondering if you might have a moment to
Be sure to specify OPTIMAL size so that rollbacks have a chance to shrink back
offer some free advice. I have just graduated with a MS in MIS and work at a small down.
software company as a QA Engineer. We develop and application in Smalltalk and
The final option is to have your rollback segments as they are and add a large
C++ that is the front end to an Oracle database where we store our information and rollback segment to be used just for your large inserts and deletes. You will need at
configuration info. I really love working with Oracle and we periodically have an
least 121 times the size as your other rollback segments. To use the rollback
Oracle consultant in to help us do installations on various platforms, and tuning, etc. segment, before the load/delete you must specify:
Myself and a developer are responsible for most of the Oracle maintenance here
SET TRANSACTION USE ROLLBACK SEGMENT segment_name;
also.
When you do this, Oracle will force your session to use the larger rollback
My question is this: How can I become Oracle certified (my company will not
segment. Every time you do a COMMIT, ROLLBACK, or DDL-statement you must
spring or sanction this as we may be abandoning Oracle) and what advice do you
re-issue the above command.
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.
http://homepage.interaccess.com/~akaplan/oracle.html page 22
172.
Subject: cpu count
Q -- 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
A -- 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.
173.
Subject: What does flushing the shared pool do?
Q -- What does the following command do, and when should it be used. I am
running Oracle 7.4 on NT.
ALTER SYSTEM FLUSH SHARED POOL.
A -- 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.
174.
Subject: 1) Does unique constraint exist? 2) How do you use HOST?
Q -- 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
A -- 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 reinstalling SQL*Plus with all windows closed.
Q -- 2. UNIQUE constraint:
How to find whether a unique constraint exists for a given column in a table?
A -- 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') );
175.
Subject: Copying a database to another server while it is still up
Q -- 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.
A -- 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 original database, 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.
http://homepage.interaccess.com/~akaplan/oracle.html page 23
Download