*=========================================================================*/
/* 昄最q被改动?0个文?nbsp; */
/*=========================================================================*/
ls -alt|head
/*=========================================================================*/
/* 把Oracle的SGA钉在内存?nbsp; */
/*=========================================================================*/
HP-UX AND LINUX AS 3
LOCK_SGA = TURE
SUN Solaris
USE_ISM=TRUE
/*=========================================================================*/
/* 汇出数据库成文g */
/*=========================================================================*/
exp userid=arms/arms@arms owner=arms file=(arms_1123-1.dmp,arms_1123-2.dmp,
arms_1123-3.dmp,arms_1123-4.dmp,arms_1123-5.dmp,arms_1123-6.dmp,arms_1123-7.dmp)
filesize=2GB log=arms_1123.log
imp armsetl/armsetl fromuser=armsetl touser=armsetl rows=y indexes=n
commit=y buffer=65536 feedback=100000 ignore=n volsize=0
file=exp_icd.dmp
--oracle10g中汇入需要system用户做汇入动?br />
imp userid=sys/sys@ARMS fromuser=ARMS touser=ARMSETL file=(arms_1123-1.dmp,arms_1123-2.dmp,
arms_1123-3.dmp,arms_1123-4.dmp,arms_1123-5.dmp) filesize=2GB COMMIT=Y log=ARMSETL.log
E:\export>imp userid=system/arms@arms fromuser=arms touser=armsetl tables=VW_PAY
MNTRESP indexes=n ignore=y file=VW_PAYMNTRESP.dmp filesize=2GB log=VW_PAYMNTRESP
_imp.log
D:\ARMS_EXP>exp userid=arms/arms@arms tables=VW_PAYMNTRESP direct=y file=VW_PAYM
NTRESP.dmp filesize=2GB log=VW_PAYMNTRESP.log
/*=========================================================================*/
/* 查看消耗CPU的百分比 */
/*=========================================================================*/
RHORA*ORA-/etc>ps auxgw|sort +2 |tail
oracle 14482 0.0 3.9 303796 20068 ? S 17:09 0:01 oracleORA (LOCAL=NO)
oracle 14184 0.0 5.1 303132 26188 ? S 11:58 0:01 ora_smon_ORA
oracle 14305 0.0 5.9 303280 30208 ? S 15:08 0:04 oracleORA (LOCAL=NO)
oracle 14216 0.0 6.3 305588 32440 ? S 12:04 0:10 oracleORA (LOCAL=NO)
oracle 14180 0.1 0.8 308684 4248 ? S 11:58 0:29 ora_lgwr_ORA
oracle 14178 0.2 7.5 305536 38748 ? S 11:58 0:50 ora_dbw0_ORA
oracle 14512 14.1 11.2 309252 57364 ? S 18:05 3:25 oracleORA (LOCAL=NO)
oracle 14289 2.0 12.9 305088 65976 ? S 13:51 5:44 oracleORA (LOCAL=NO)
oracle 14226 2.3 3.1 305868 16116 ? S 12:09 8:47 oracleORA (LOCAL=NO)
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
/*=========================================================================*/
/* 查看消耗CPU最长时间的q程 */
/*=========================================================================*/
RHORA*ORA-/etc>ps -ef |grep oracle|sort +6|tail
sort 按第六排排序....
tail昄输出后的多少?默认为前10?br />
/*=========================================================================*/
/* 更改字符集问题解册l请见本人BLOG */
/*=========================================================================*/
select userenv('language') from dual;
SIMPLIFIED CHINESE_CHINA.ZHT16BIG5
SIMPLIFIED CHINESE_CHINA.WE8ISO8859P1
SQL> ALTER DATABASE CHARACTER SET ZHT16BIG5;
ALTER DATABASE CHARACTER SET ZHT16BIG5
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set
使用q_的这U方式是不可以更Ҏ据库字符集的.
改了字符集后
SQL> conn / as sysdba;
ERROR:
ORA-12705: invalid or unknown NLS parameter value specified
解决办法:
export NLS_LANG=CHINESE_CHINA.ZHT16BIG5
当服务器客户机无法登?
/*=========================================================================*/
/* 表空间文件丢失问题解?nbsp; */
/*=========================================================================*/
SQL> startup
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
ORA-01122: database file 18 failed verification check
ORA-01110: data file 18: '/opt/oracle/product/9.2.0/dbs/LHB.DAT'
ORA-01251: Unknown File Header Version read for file number 18
问题如上所C?没有办法扑ֈLHB.DAT
1.SQL> startup mount
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> alter database datafile '/opt/oracle/product/9.2.0/dbs/LHB.DAT' offline drop;
Database altered.
SQL> alter database open;
Database altered.
SQL>
/*=========================================================================*/
/* 修改global_name */
/*=========================================================================*/
conn / as sysdba
update props$ set value$ = 'oradb' where name = 'GLOBAL_DB_NAME';
commit;
shutdown immediate
startup
之后再创建dblink即不带域名?/p>
grant connect to arms
/*=========================================================================*/
/* TO_DATE函数问题解决. */
/*=========================================================================*/
select OHDUEDATE,to_date(lhb.OHDUEDATE,'dd/mm/yy') from lhb --写错了这L一个格?宛_我花了半天的旉
最lȝ,要看清格式这点很重要:to_date/'dd/?yy')...q种方式.'dd/mon/yy'q样解决问题;
/*=========================================================================*/
/* 不断昄输出新的?nbsp; */
/*=========================================================================*/
tail -f logfile.log
/*=========================================================================*/
/* 讄ORACLE下的ksh命o提示W?nbsp; */
/*=========================================================================*/
export PS1="`hostname`*\${ORACLE_SID}-\${PWD}>"
/*=========================================================================*/
/* 强制在UNIX下关闭ORACLEq程 */
/*=========================================================================*/
ps -ef |grep "ora_"|grep -v grep|awk '{print $2}' |xargs kill -9
shutdown abort
/*=========================================================================*/
/* db_block_size */
/*=========================================================================*/
show parameter db_block_size (高速缓存区(Database Buffer Cache))
每个表空间可以徏立不同的DB_BLOCK_SIZE 说明:8k的高速缓存通过DB_8K_CACHE_SIZE
参数来设定的.
share pool 存储数据字典高速缓?br />
当share pool装满?最q最用的执行路径和分析树从库高速缓存中删除,以便为新?br />
腾出空?
/*=========================================================================*/
/* oracle 9.2.4+linux启动与关闭相?nbsp; */
/*=========================================================================*/
linux+oracle 9.2.4 的启动方法与原来oracle 8.1.7的启动方式有些不?br />
方式?
[oracle@RHORA oracle]$ sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0 - Production on Wed Nov 8 17:24:47 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> startup
关闭改为shutdown immediate;
LRM-00109: could not open parameter file '/opt/oracle/product/9.2.0/dbs/initORCL.ora'
把initORA.ora拯q去可以用了.
ORA-01990: error opening password file '/opt/oracle/product/9.2.0/dbs/orapw'
把密码文件拷贝过d可以启动?
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
/*=========================================================================*/
/* utl_file的相关问?nbsp; */
/*=========================================================================*/
查找导出路径:show parameter utl_file_dir -oracle 8i 可以直接更改初始参数?br />
件而后重新启动数据库就可以保存;
alter system set utl_file_dir='\home\oracle' scope=spfile; 更改9i的版本可以这h?br />
注上面只能更改到spfile(也是所说的内存).要更改到pfile 请从pfile------spfile
呵呵.
startup mount;
recover database until cancel;
alter database open resetlogs;
/*=========================================================================*/
/* 查剩余表I间 */
/*=========================================================================*/
SELECT tablespace_name, sum ( blocks ) as free_blk ,
trunc ( sum ( bytes ) /(1024*1024) ) as free_m,
max ( bytes ) / (1024) as big_chunk_k, count (*) as num_chunks
FROM dba_free_space GROUP BY tablespace_name;
/*=========================================================================*/
/* JOB按时间去执行存储q程 */
/*=========================================================================*/
DECLARE
X NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT
( job => X
,what => 'ARMS1.SP_OUTPUT_COL_CUST_PAY;'
,next_date => to_date('26-10-2006 20:09:06','dd/mm/yyyy hh24:mi:ss')
,interval => 'TRUNC(LAST_DAY(SYSDATE)) + 1 + 1/24 + 30/1440'
,no_parse => TRUE
);
SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
END;
/
commit;
午夜12?...TRUNC(SYSDATE+1)
W二天凌晨一Ҏ ...TRUNC(LAST_DAY(SYSDATE)) + 1 + 1/24
如还要在后面加分?可以l箋
/*=========================================================================*/
/* 建立常用输出?nbsp; */
/*=========================================================================*/
CREATE OR REPLACE Package PKG_APBT As
type Type_Ret_Curs is ref Cursor;
msg_0 CONSTANT VARCHAR2(100) := '埯成功!';
msg_1 CONSTANT VARCHAR2(100) := '埯失敗!';
msg_2 CONSTANT VARCHAR2(100) := '沒有該紀?';
msg_3 CONSTANT VARCHAR2(100) := '主鍵已經存在!';
msg_4 CONSTANT VARCHAR2(100) := '長度太長!';
msg_5 CONSTANT VARCHAR2(100) := '輸入參數不能為空!';
msg_6 CONSTANT VARCHAR2(100) := '沒有數據!';
msg_7 CONSTANT VARCHAR2(100) := '用戶不存?';
msg_9 CONSTANT VARCHAR2(100) := '輸入參數不正?';
End;
/
/*=========================================================================*/
/* 建日志表 */
/*=========================================================================*/
CREATE TABLE LOGDATA
(
LOG_DATE VARCHAR2(20) DEFAULT to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') NOT NULL,
OPERATOR VARCHAR2(50),
LOG_TYPE CHAR(1),
USER_TABLE VARCHAR2(50),
INFO VARCHAR2(4000),
SYS_TYPE NUMBER(1) DEFAULT 0 NOT NULL
)
/*=========================================================================*/
/* 建立同义词ƈ使用 */
/*=========================================================================*/
我们先看如下的一pd执行Q?/p>
SQL> create or replace view v_bmw_pay_online_new as
2 select *
3 from taobao.bmw_pay_online_new@lnk_db215;
SQL> create or replace procedure sp_v_test is
2 v_id number;
3 begin
4 select id into v_id from v_bmw_pay_online_new where id=1;
5 end;
6 /
Procedure created
SQL> create or replace synonym s_bmw_pay_online_new
2 for taobao.bmw_pay_online_new@lnk_db215;
Synonym created
SQL> create or replace procedure sp_s_test is
2 v_id number;
3 begin
4 select id into v_id from s_bmw_pay_online_new where id=1;
5 end;
6 /
Warning: Procedure created with compilation errors
SQL> show error
Errors for PROCEDURE TAOBAO.SP_S_TEST:
LINE/COL ERROR
-------- ------------------------------------------------------------------------------------
4/29 PL/SQL: ORA-00600: 内部错误代码Q参? [17069], [0x57E77854], [], [], [], [], [], []
4/4 PL/SQL: SQL Statement ignored
可以看到Q在同样一个远E对象上面,我可以通过创徏视图Q然后在该视图上创徏存储q程Q是没有M问题的,
但是如果我对该远E操作做一个同义词Q再在同义词上创建存储过E,则报ZOra-00600。跟t也无果Q?br />
看生的日志文g也不能看出来什么,上metalinkQ搜?ora-00600 17069"Q发现查出现的东西一大堆Q?br />
大致是library cache错误Q但是到底怎么会生这个错误呢Qonline联系上一个oracle在线技术支持,聊了一会儿Q?br />
问题是解决了Q但是他是不承认是bugQ呵c?/p>
以下是聊天的ȝQ?br />
ORA-00600 [17069] reorted on compiling a procedure.
Invalid lock in library cache.
Unable to pin the object and hence the Error.
<Note:39616.1> "Failed to pin a library cache object after 50 attempts"
Clearing the shared memory will help to get rid of inconsistant information
in memory which is causing the error.
The inconsistency was suspected to be in the remote site. But flushing the
shared pool in remote location didnt help.Tried recreation of the procedure
after dropping and recreating the synonym in the local database. But the
same failed.Flushed the shared pool in local database abd successfully
created the procedure.
alter system flush share_pool;
/*=========================================================================*/
/* 建立同义词ƈ使用 */
/*=========================================================================*/
create synonym synonym_name for table_name@db_link;
select * from table_name;
/*=========================================================================*/
/* 建立DB-LINKq接q?nbsp; */
/*=========================================================================*/
讄之前误|alter system set global_names = false
create public database link db_link
connect to user identified by pwd
using 'connect string';
select sysdate from dual@db_link;
/*=========================================================================*/
/* 插入旉?nbsp; */
/*=========================================================================*/
insert into test(IMPORT_DATE) values
(to_date('2002-10-20 15:30:00','yyyy-mm-dd hh24:mi:ss'));
insert into test(testtime) values(sysdate);
取得时候可以to_char(sysdateQ?yyyy-mm-dd hh24:mi:ss')
/*=========================================================================*/
/* 更改表时记录其变化的TRIGGER */
/*=========================================================================*/
CREATE OR REPLACE TRIGGER T_APBT_CONTRACT_ALL_AIUDR
after insert or update or delete on APBT_CONTRACT_ALL
for each row
/*无论一条语句改变了多少条记?ORACLE对于每条记录触发一ơ触发器*/
/*before和after的区?事g发生前还是事件发生后*/
begin
if inserting then
insert into A_APBT_CONTRACT_ALL(ID,CONTRACT_SERIAL_NUM,flag)
values (Seq_APBT_ARMS.NEXTVAL,:new.CONTRACT_SERIAL_NUM,1);/* :new*/
elsif updating then
insert into A_APBT_CONTRACT_ALL(ID,CONTRACT_SERIAL_NUM,flag)
values (Seq_APBT_ARMS.NEXTVAL,:old.CONTRACT_SERIAL_NUM,2);
/*此句存在问题*/
elsif deleting then
insert into A_APBT_CONTRACT_ALL(ID,CONTRACT_SERIAL_NUM,flag)
values (Seq_APBT_ARMS.NEXTVAL,:old.CONTRACT_SERIAL_NUM,3);
end if;
end;
/
/*=========================================================================*/
/* 你能够创如下语句所触发: */
/*=========================================================================*/
DML语句( DELETE,INSERT,UPDATE)
DDL语句( CREATE,ALTER,DROP)
数据库操? SERVERERROR, LOGON, LOGOFF, STARTUP, SHUTDOWN)
/*=========================================================================*/
/* 建立sequence序列: */
/*=========================================================================*/
DROP SEQUENCE ARMS.SEQ_APBT_ARMS;
CREATE SEQUENCE ARMS.SEQ_APBT_ARMS
START WITH 30
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;