Oracle õ˳ʼͨǶsqlplusshow parameter áOracleΪdebug ߽һЩ⣬ṩһЩԡ_ͷ һЩscriptɼЩ. ǣû,ǿֱsqlplus show parameter ȡЩأ
ġ
棬ҽʾһsqlplus show parameterֱӲ鿴Oracle.
鿴ȫOracle õ˳ʼͨǶsqlplusshow parameter áOracleΪdebug ߽һЩ⣬ṩһЩԡ_ͷ һЩscriptɼЩ. ǣû,ǿֱsqlplus show parameter ȡЩأ
ġ
棬ҽʾһsqlplus show parameterֱӲ鿴Oracle.
鿴ȫֻǼѣ룿
鿴ȫ̳ѯڴstatspack data£Զ N report
20 һԺȷ˵µĿգ
1,2,3,4,5,6,......
ԶɻʹshellڼĿյı棬ûз
˳дһScript, ԶN report
ȫΪ Script
鿴ȫʵʵķ/ݿУǶҪԱҪСģںܶҪ淶жҪ
¼
ڶ ¼ Ҫдһscript, Զ¼ÿlogin session Ķ
Oracle 9i ̬SGAĴСǣʵУм(resize/reduce) shared_pool_sizeɹcheckpoint(CKPT) ̺ôCPUļĽһṩʱ
鿴ȫOracle 9iR2SQL ȡ汾
select text from dba_source
where OWNER ='SYS'
and name = 'DBMS_SQL'
and TYPE = 'PACKAGE'
and line between 37 and 94
order by line
/
PL/SQLαԷΪʽʽ֣ʽзΪselect intoʽαfor .. in ʽα֡ԣǿΪ3α÷
A. ʽα
B. select intoʽα
C. for .. in ʽα
ȷѡʹα꣬ijܣɶԣȲشӰ졭
--By RollingPig, http://rollingpig.itpub.net
ļоPL/SQLõļֲͬ͵αдԱ˲ͬαдȱ㣬ͬʱһѡĻԭ
IJ̫ʵ/ܲԣȤĻҿԸʾԼԡ
Oraclecontrolfile DBɵһļ¼˰datafile/logfile/archived_log/rman_backupϢͬҲơ
ὲcontrol file һЩ(limitation)
ϵ֮һOracleƣlimit) ϵ1--sessions & processes
Уδͬ⣬תأлл
鿴ȫĽηԶ̷ij˿ڼORACLEʵ/
鿴ȫOracleɫɫƣlimit)˽ЩƿǸõʹOracleOracle.
Oracleϵеĵһƪ£ҪһЩOracleʼ趨һЩƣsessions , processes
Key Word: ORA-00018 , ORA-00020
鿴ȫ1Init parameter趨
2OS趨
3OS
4Resource Control
5ȫ
backup database on standby instead of backup on primary,BUG
BUG:3612680
rman backupquery v$archived_logʱ
ORA-01861: literal does not match format string
Bug: 2749174
rman backupʱ
ORA-19573: cannot obtain sub-shared enqueue for datafile
鿴ȫʱOracleлᷢϢֵܹ
Message ... not found; No message file for product=network, facility=NL
Ҳ
Error 6 initializing SQL*Plus
Message file sp1
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
һν
鿴ȫORA-04030: ڳԷ ֽ (hash-join subh,kllcqas:kllsltba) ʱڴ治
ORA-04030:out of process memory when trying to allocate string bytes
ORA-04030ijԭ
鿴ȫUnix Backup listener.log .ܼһscript
cd $ORACLE_HOME/network/log
LG=listener.log
cat $LG | gzip -9c > $LG.bak.`date +%Y%m%d`.gz && cat /dev/null > $LG
ܹbackup
listener.log.bak.20060510.gz
ѹԭ 5%
ʱimpһdmp file , ĺݣССĽһôķƿ
鿴ȫ(Step 3-5 only applies to development/testing DB or in an offline production DB, because move table would destroy index.)
Ȼresize datafile ˣдһ²
鿴ȫ
Linux RedHat 9ϰװ Oracle 9201 update 9206 ļҪ
鿴ȫijЩطOracle fileıv$session_wait p2ʱָᷢfile# ܴv$datafileûиfile#
ʵtempfilefile#+parameter db_filesֵ
ǿȥparameter db_filesMAPv$tempfiledba_temp_fileͿ.
һSQLܻѰҹ̡
SELECT * FROM (
SELECT file_name , tablespace_name ,file_id,'datafile' AS TYPE
FROM DBA_DATA_FILES
UNION ALL
SELECT file_name , tablespace_name ,file_id + value ,'tempfile '
FROM DBA_TEMP_FILES , v$parameter p
WHERE p.name = 'db_files'
)
WHERE file_id = &FILE#
Question:
table TУserial_no
ܹѯһserial_noֶεIJֵ
磺
serial_no
1
2
3
4
6
8
9
10
һsqlȱʧĺ룬
ʾΪ
5
7
:
SELECT /*+ordered */T2.serial_no + 1, MIN (t3.serial_no) - 1
FROM T T1, T T2, T t3
WHERE T1.serial_no(+) = (T2.serial_no + 1) AND T1.serial_no IS NULLAND t3.serial_no > T2.serial_no
GROUP BY T2.serial_no
˼·
1not exists /not in , : t1.serial_no = t2.serial_no + 1
2οhttp://www.itpub.net/406784.html not exists /not in Ϊouter join + is null ʽ
3 min ȷ
пгϸ
v$session_wait enqueue P1Īʲô
鿴ȫһ ASP VB ʹð ( Bind Variable ) ļʾӴ˲õĿԱԹ˵ ASP / VBʹðˡ
'Constant for parsing'
const adParamInput = 1
const adOutput = 2
const adVarChar = 200
const adInteger = 3
const adStateOpen = 1
const adUseClient = 3
const adOpenStatic = 3
const adCmdStoredProc = 4
const adCmdText = 1
Dim oConn
Dim oComm 'ADO command objects'
dim oRs
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=MSDAORA;Password=luo;Persist Security Info=True;
User ID=serol;Data Source=mescp"
Set oComm = CreateObject("ADODB.Command") oComm.ActiveConnection = oConnoComm.CommandType = adCmdText 'Command type'
oComm.CommandText = "select * from all_objects where rownum < ? and owner = ?" 'SQL,? stand for variable '
oComm.Parameters.Append oComm.CreateParameter("v1",adInteger,adParamInput,4,100)
oComm.Parameters.Append oComm.CreateParameter("v2",adVarChar,adParamInput,255,"SYS")
Set oRs = oComm.Execute 'Execute '
ӿcreate / rebuild index3
1sort_area_size
sort_area_size,
auto pgaģӦworkarea_size_policy=manualsort_area_size
alter session set workarea_size_policy=manual
alter session set sort_area_size=512000000
2.nologging
create index t on t(a) nologging
3.ڶCPUϵͳ,Լparallel ͨΪCPU or CPU-1
create index t on t(a) nologging parallel 7
дһscript,primary key fast full scan query table record_count
DECLARE
record_count NUMBER;
BEGIN
FOR rec IN
(SELECT a.table_name,b.index_name FROM USER_TABLES a,USER_CONSTRAINTS b
WHERE a.table_name = b.table_name(+) AND b.constraint_type(+) = 'P' ) LOOP
EXECUTE IMMEDIATE 'select /*+index_ffs( a '||rec.index_name||') */ count(*) from ' ||rec.table_name||' a ' INTO record_count;
dbms_output.put_line(rec.table_name||' '||record_count);
END LOOP;
END;
ԭijԣ
http://www.idevelopment.info/data/Oracle/DBA_tips/Export_Import/EXP_3.shtml
SELECT
SUBSTR(sql_text, INSTR(sql_text,'INTO "'),30) table_name
, rows_processed
, ROUND( (sysdate-TO_DATE(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60,1) minutes
, TRUNC(rows_processed/((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60)) rows_per_minute
FROM
sys.v_$sqlarea
WHERE
sql_text like 'INSERT %INTO "%'
AND command_type = 2
AND open_versions > 0;
The RMAN environment can contain the following components:
In general, the rules of RMAN compatibility are as follows:
ҵOracleϵͳSQLPATH
Ȼͷӵ㾭õ sql script,óһ¡
1login.sql
2. conn.sql / connect.sql
3. su.sql / su1.sql
4. fo.sql / findObject.sql
5. fl.sql / flush.sql
6. ci.sql / compileInvalid.sql
7. fv.sql / fixView.sql
鿴ȫдƪµԭǸϰһ¼uniq磺
ls,sort,cut,awk,sort,uniqgrep
ֵбҪúоһoracleĻscript.....
cd $ORACLE_HOME/rdbms/admin
ls -1 | cut -f2 -d"." | sort | uniq -c
444 sql
303 plb
ls -1 *.plb | cut -b 0-3|sort |uniq -c|sort -nr|head
234 prv
57 owm
9 dbm
2 utl
1 xum
ls -1 *.sql | cut -b 0-3|sort |uniq -c|sort -nr
100 dbm
95 cat
43 utl
28 xml
28 jvm
16 ini
12 pub
12 pri
10 owa
6 wpg
6 c08
6 a08
4 xsl
4 spc
3 spu
3 spr
3 spd
3 ols
3 i08
2 wwv
2 u08
2 std
2 rma
2 pro
2 owm
2 mgw
2 dro
1 xav
1 wpi
1 use
1 udj
1 u09
1 u07
1 tra
1 sta
1 spt
1 spp
1 spa
1 rmx
1 rmj
1 rmc
1 rdb
1 prg
1 pls
1 pli
1 pis
1 pip
1 pid
1 pbu
1 pbl
1 odm
1 n_s
1 not
1 jis
1 i09
1 f09
1 f08
1 e09
1 e08
1 dum
1 diu
1 d09
1 d08
1 csm
1 cmp
1 c09
1 c07
1 amd
1 a09
1 a07
1.prv*.plb -- ܺcode,Ҫdbms_* packagecode,һЩصtype,libraryviewȡ
grep "CREATE OR REPLACE" prv* |tee /tmp/all.log awk '{print $4}' | sort |uniq -c|sort -nr
354 PACKAGE
53 PUBLIC
35 LIBRARY
12 TYPE
10 VIEW
8
6 PROCEDURE
6 package
2 FORCE
1 TRIGGER
1 REPLACE
1 PRIVATE
1 FUNCTION:
1 DIRECTORY
grep "CREATE OR REPLACE PUBLIC" prv* | awk '{print $4,$5}' | sort |uniq -c|sort -nr
53 PUBLIC SYNONYM
2.dbm* (dbms*) -- ϶dbms* packagedeclare
echo dbms* | wc -w
109
3.cat*.sql catalog,catproc,catexp壬
catalog.sql : Creates data dictionary views.dba_ user_ all_ v_$ gv_$view, ԼӦsynonymcatsql.
grep "create or replace" catalog.sql | awk '{print $4}' | sort | uniq -c | sort -nr
717 public
712 view
7 synonym
6 replace
2 -
grep "create or replace public " catalog.sql | awk '{print $4}' | sort | uniq -c | sort -nr
717 synonym
grep @ catalog.sql
Rem rkooi 01/23/92 - use @@ command for subscripts
@@standard
@@dbmsstdx
@@catcr
@@catcdc
@@cataudit
Rem This statement must happen before @catexp.
@@utlraw
@@catexp
@@catldr
@@catpart
@@catadt
@@catsum
@@catlsby
@@catxtb
catproc.sql -- prv*.plb,dbms*.sql ,cat*.sql utl*sqlɻprocedural ֧֣
grep @ catproc.sql | wc -l
84 prv
54 dbm
28 cat
12 utl
1 wpi
1 pls
1 pli
1 pis
1 pip
1 pid
1 owa
1 m @
1 m
1 diu
catexp.sql -- internal views for Export/Import utility
Ķͨۿע֪;..
4.owm* oracle workspace managerĶ,ɺ,scriptoracleϺע͡
5.utl*, utlԼscript,utlxplan,utlfile
utlxplan,utlxplp,utlxpls: execute plan صtableԼview
utl_http,utl_smtp,utl_tcp,utl_tcp,utl_url صһЩpackage
utlexcpt.sql,utlexpt1.sql : excetion table
utlrcmp.sql : compile invalid package
utlraw.sql : raw charת
...
6.xml*,xsl* ֧xmlpackage
7 init* , jre*jserverһЩpackage
8.u0*,d0*,e0*,f0*,,i0*,a0* ݿscript
u0* upgrade main scripts
d0* downgrade main scripts
DBAУʱҪһѾObjecttablespace resizeСһ㡣ɲŶ
˵
"ҵtablespace100MΪʲôû취resize/reduce 200M?"
ӶƵĿʼԹOracleơ
棬ҽʾһЧresize/reduce datafile size.
鿴ȫոմ asktom.oracle.com һƪ£Ҫ´ǡ
1. Shutdown the instance
2. Backup all control, redo, and data files.
3. Go through the .profile, .cshrc, .login, oratab,
tnsnames.ora, (for SQL*Net version 2), and redefine the
ORACLE_SID environment variable to a new value.
For example, search through disks and do a grep ORACLE_SID *
4. Change locations to the "dbs" directory
% cd $ORACLE_HOME/dbs
and rename the following files:
o init<sid>.ora (or use pfile to point to the init
file.)
o control file(s). This is optional if you do not rename
any of the controlfiles, and the control_files parameter
is used.
The "control_files" parameter is set in the
"init<SID>.ora" file or in a file it references with the
ifile parameter. Make sure that the control_files
parameter does not point to old
file names, if you have renamed them.
o "crdb<sid>.sql" & "crdb2<sid>.sql", This is optional.
These are only used at database creation.
5. Change locations to the "rdbms/admin" directory
% cd $ORACLE_HOME/rdbms/admin
and rename the file:
o startup<sid>.sql. This is optional. On some platforms,
this file may be in the "$ORACLE_HOME/rdbms/install" directory.
Make sure that the contents of this file do not reference old
init<SID>.ora files that have been renamed. This file
simplifies the "startup exclusive" process to start your
database.
6. To rename the database files and redo log files if need be.
7. Change the ORACLE_SID environment variable to the new value.
8. Check in the "$ORACLE_HOME/dbs" directory to see if the
password file has been enabled. If enabled, the file
"orapw<OLD_SID>" will exist and a new password file for the new
SID must be created (renaming the old file will not work). If
"orapw<OLD_SID>" does not exist, skip to step 9. To create
a new password file, issue the following command as oracle
owner:
orapwd file=orapw<NEWSID> password=?? entries=<number of
users to be granted permission to start the database instance>
9. Start up the database and verify that it works. Once you
have done this, shutdown the database and take a final backup
of all control, redo, and data files.
10. When the instance is started, the control file is updated
with the current ORACLE_SID.