.Net 中读写Oracle数据库的两种方式
昨天晚上往Oracle数据库里面保存一幅图片,算是很稀松平常的大字段操作,搞了半天就是没存进去,提示是 “System.Data.OleDb.OleDbException: ORA-01008: 并非所有变量都已关联”。本以为是OleDbParameter的写法不对,到CSDN上一查,问题出在驱动程序上:把“provider= MSDAORA.1;”改为“provider='OraOleDb.Oracle';”,问题解决。 总结一下在 .Net 中读写Oracle数据库常用两种方式:OracleClient和OleDb,其中OleDb的方式根据驱动程序的不同又有两种。 1. OracleClient方式,是微软专门针对Oracle数据
Oracle Temporary Tablespace
SQL> alter tablespace temp add tempfile '/data/oradata/devdb3/temp01.dbf' size 50m autoextend on;SQL> alter database tempfile '/data/oradata/devdb3/temp02.dbf' drop ;SQL> alter tablespace temp add tempfile '/data/oradata/devdb3/temp02.dbf' reuse;SQL> alter database tempfile '/data/oradata/devdb3/temp02.dbf' drop including datafiles;[@more@]
Relocated Data file
SELECT * FROM DBA_DATA_FILESselect * from dba_temp_filesSQL> alter tablespace my_TABLESPACE read only;SQL> !cp -p /data/oradata/ndrs/my_TABLESPACE01.dbf /opt/oracle/ndrs/.SQL> alter tablespace my_TABLESPACE offline;SQL> alter database rename file '/data/oradata/ndrs/my_TABLESPACE01.dbf' to '/opt/oracle/ndrs/my_TABLESPACE01.dbf';SQL> alter tablespace my_TABLESPACE online;SQL> alter tablespace my_TABLESPACE read write;SQL> alter database backup controlfile to trace;SQL> !
Shared_Pool
v$sgastat 中shared pool miscellaneous 值每天都在增长相应shared pool free 的值一直在减少,造成最后没有free 空间,没发连接数据库的情况。 The most common cause is SQLs not using bind variables. alter system flush shared_pool periodically gives you relief temporarily, or set cursor_sharing to force (for 8i) if their bugs don't bother you. But the ultimate solution is to ask your developers to use bind variables. If the code is from third-party (meaning you can't control), that's out of the
Analysing locking issues with LOGMINER
Deadlock example ---------------- One process does the following: SQL> update dept set dname = 'dqkl' where deptno = 10; 1 row updated. SQL> delete emp where empno = 7934; 1 row deleted. Another process does the following and falls on a deadlock situation SQL> update emp set sal = sal * 1.1 where empno = 7934; 1 row updated. SQL> delete dept where deptno = 10; delete dept where deptno = 10 * ERROR at line 1: ORA-00060: deadlock detected while waiting for resour
Temporary Tablespace
Creation of a TEMPORARY Tablespace----------------------------------SQL> create TEMPORARY tablespace temp_tempfile_local2 TEMPFILE '/ora/V817/temp_temp.dbf' size 100M3 EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;----------------------------------SQL> create tablespace TEMP_DATAFILE_DICT2 datafile '/tcase/oradata/V901/temp_data.dbf' size 100M3 TEMPORARY;Tablespace created.Tempfiles Removal---------------------------a. You cannot remove datafiles from a tablespace until you drop the tablespa
resize Online Redo Logfile
sql> startup open restrict;sql> select group#, bytes, status from v$log;sql> select group#, member from v$logfile;sql> alter database add logfile group 4 '/usr/oracle/dbs/log4jinn.dbf' size 100m;...sql> alter system switch logfile;sql> alter database drop logfile group 1;...sql> !rm /usr/oracle/dbs/log1jinn.dbf';sql> alter ssytem disable restricted session; [@more@]
turn Archiving ON or OFF
turn on:1. Enabling Automatic Archiving1a. alter system archive log start;1b. alter system set log_archive_start = true scope=spfile; => restart db2. Changing the Database Archiving ModeLOG_ARCHIVE_START => manual or autoLOG_ARCHIVE_DESTLOG_ARCHIVE_FORMAT => arch%S.%T.arcsql> startup mountsql> alter database archivelog;sql> alter database open;3. Archive commandssql> archive log listsql> archive log all,sql> alter system switch log;trun off:1a. alter system archiv
Function Based Index
Function Based Index Step by Step alter session set query_rewrite_enabled=true; alter session set query_integrity=trusted; create index on orders(trunc(time)); analyze table orders compute statistics; select /* +index(orders) */ * from orders where trunc(time)=trunc(sysdate);[@more@] need to research more ...
Oracle 10G
version: 10.1.0.2.0emcanetcahttp://localhost:5500/emhttp://lcoalhost:5562/isqlplus Oracle Enterprise Manager: http://host.domain:5500/em/ Oracle IsqlPlus Manager: http://host.domain:5560/isqlplus Oracle IsqlPlus Manager DBA : http://host.domain:5560/isqlplus/dba Oracle UltraSearch : http://host.domain:5620/ultrasearch Oracle UltraSearch Admin : http://host.domain:5620/ultrasearch/admin Oracle HTMLDB : http://host.domain:7777/pls/htmldb/htmldb Oracle Apache : http://host.do
LogMiner
$ORACLE_HOME/rdbms/admin/dbmslogmnrd.sql$ORACLE_HOME/rdbms/admin/dbmslogmnr.sql$ORACLE_HOME/rdbms/admin/prvtlogmnr.plbOracle 8.1.6$ORACLE_HOME/rdbms/admin/dbmslmd.sql $ORACLE_HOME/rdbms/admin/dbmslm.sql $ORACLE_HOME/rdbms/admin/prvtlm.plbsys: exec dbms_logmnr_d.build(dictionary_filename => 'dictionary.ora', dictionary_location => '/data/oracle/logmnr'); exec dbms_logmnr.add_logfile(logfilename => '/data/oracle/archive/archiving_1_000026.dbf', options => dbms_logmnr.new); exec
utl_file_dir
SQL> CREATE DIRECTORY log_dir AS '/appl/gl/log'; SQL> GRANT READ ON DIRECTORY log_dir TO DBA; [@more@]
OEM
oemctl start oms dbsnmpagentctl start agentconsider the personal firewall. [@more@]
Alter Sequence
The sequences that need to reset the start number to 0 at the first day of new year. create sequence: CREATE SEQUENCE SEQ_APP_NUMBER INCREMENT BY 1 START WITH 1 MINVALUE 0 MAXVALUE 99999 NOCYCLE NOCACHE ORDER; set_sequence.sql DECLARE Handle Integer; SqlText varchar2(2000); NewNextVal Integer; NewCurrVal Integer; CURSOR cursor_seq_names IS SELECT sequence_name,(last_number * (-1) + increment_by + min_value) last_number,increment_by FROM user_s
ORA-12541: TNS:no listener
App developer report that Ora-12541 appear. On clinet side, sqlplus can connect to all the instances, can all database link not works. Suspect that the listener.ora had been modified. Action: use localhost instead the ip address, the issue solved. LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) This is the workaround only, will follow up for root cause. [@more@]
def$_aqcall on Advanced Replication Environment
System tablespace is increased to almost 100% of storage, after check the dba_segments view, find that the size of table def$_aqcall is 80MB+.1. Terminate the current push operations and prevent them from re-running.2. Stop remote sites from replicating to the local site.3. truncate table system.def$_aqcall;note: 190885.1@metalink[@more@]
OPatch
1. where to get the OPatch patch number: 2617419 note: 224346.1 189489.1@metalink2. How to install OPatch 1) Download the zipfile from metalink 2) Unzip the zipfile to a temp location, eg. '$HOME/tmp/opatch1.50' 3) After unzippping, a directiory called 'OPatch' and a file called 'README.txt' is created. 4) Copy the directory 'OPatch' and its contents to the concerned Oracle Home3. OPatch command opatch lsinventory opatch rollback -ed bug_number opatch query -is_roll