2012年3月14日

有趣的一道面试题,求连续的0或者连续的1的最大次数

给几个0和1组成的字符串,要求用程序算成连续的0或者连续的1的最大次数,例如

0011111000100100111    最大5
010011100001101100     最大4
00111110001001000000111     最大6

 

我写了个ORACLE函数,勉强能实现这个功能,如下:

create or replace function FUNC_LSX_TEST(in_str varchar) return number
as
   v_i varchar2(1) ;
   v_j varchar2(1) ;
   v_return number :=1 ;
   i number :=1 ;
   j number :=1 ;
   v_flag number :=1 ;
   type t_tbl is table of number index by binary_integer;
   t_return t_tbl ;
  
begin
  t_return(1) :=1 ;
   while i<length(in_str)
      loop
     v_i := substr(in_str,i,1) ;
      v_j := substr(in_str,i+1,1) ;
        if(v_j is not null) then
           if(v_i = v_j) then
              t_return(i) := v_flag +1 ;
              v_flag := v_flag +1 ;
              i :=i+1 ;
           else
             v_return := 1 ;
             v_flag := 1 ;
             t_return(i) :=1 ;
             i :=i+1 ;
           end if ;
        else
          i :=i+1 ;
        end if ;
      end loop;
     
     
      while j < t_return.count -1 
       loop
        if (t_return(j) > v_return) then
           v_return := t_return(j) ;
           j := j+1 ;
         end if ;
       j := j+1 ;
       end loop;

  return v_return ;
end;

 

select FUNC_LSX_TEST('00111110001001000000111') from dual ;
6

 

 

 

posted @ 2012-03-14 15:37 李世侠 阅读(12) 评论(0) 编辑

2011年4月23日

linux单机配置DG过程记录

在单机的linux虚拟机上配置DG,记录过程

环境介绍:
   linux 4.7 AS 32位
   ORACLE Release 10.2.0.1.0
   主库  testb
   备库  testbdg
   ORACLE_BASE=/oracle
   ORACLE_HOME=/oracle/product/database


1.新建目录
  mkdir -p /oracle/lsx/testbdg/arch

2.新建口令文件
  orapwd file=orapwtestb password=oracle force=y
  orapwd file=orapwtestbdg password=oracle force=y

3.新建pfile
  testb>create pfile='/oracle/admin/testb/pfile/pfiletestb.ora' from spfile;

4.修改主库的pfile文件pfiletestb.ora,修改后内容如下:
testb.__db_cache_size=268435456
testb.__java_pool_size=4194304
testb.__large_pool_size=4194304
testb.__shared_pool_size=138412032
testb.__streams_pool_size=0
*.control_file_record_keep_time=365
*.control_files='/oracle/oradata/testb/control1.ctl','/oracle/oradata/testb/control2.ctl','/oracle/oradata/testb/control3.ctl'
*.db_name='testb'
*.job_queue_processes=10
*.sga_max_size=400M
*.sga_target=400M
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=testb
LOG_ARCHIVE_CONFIG='DG_CONFIG=(testb,testbdg)'
LOG_ARCHIVE_DEST_1='LOCATION=/oracle/oradata/testb/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=testb'
LOG_ARCHIVE_DEST_2='SERVICE=testbdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testbdg'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=testbdg
FAL_CLIENT=testb
DB_FILE_NAME_CONVERT='/oracle/lsx/testbdg/','/oracle/oradata/testb/'
LOG_FILE_NAME_CONVERT='/oracle/lsx/testbdg/','/oracle/oradata/testb/'
STANDBY_FILE_MANAGEMENT=AUTO


5.复制到/oracle/lsx/testbdg/,命名为pfiletestbdg.ora,修改该文件,给备库testbdg使用,修改后内容如下:
testb.__db_cache_size=268435456
testb.__java_pool_size=4194304
testb.__large_pool_size=4194304
testb.__shared_pool_size=138412032
testb.__streams_pool_size=0
*.control_file_record_keep_time=365
*.control_files='/oracle/lsx/testbdg/control1.ctl'
*.db_name='testb'
*.job_queue_processes=10
*.sga_max_size=400M
*.sga_target=400M
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=testbdg
LOG_ARCHIVE_CONFIG='DG_CONFIG=(testb,testbdg)'
LOG_ARCHIVE_DEST_1='LOCATION=/oracle/lsx/testbdg/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=testbdg'
LOG_ARCHIVE_DEST_2='SERVICE=testb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testb'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=testb
FAL_CLIENT=testbdg
DB_FILE_NAME_CONVERT='/oracle/oradata/testb/','/oracle/lsx/testbdg/'
LOG_FILE_NAME_CONVERT='/oracle/oradata/testb/','/oracle/lsx/testbdg/'
STANDBY_FILE_MANAGEMENT=AUTO

6.启动主库testb到mount,创建standby控制文件
testb>startup pfile='/oracle/admin/testb/pfile/pfiletestb.ora' ;
testb>create spfile from pfile='/oracle/admin/testb/pfile/pfiletestb.ora' ;
testb>startup mount force
testb>alter database create standby controlfile as '/oracle/lsx/testbdg/control1.ctl' ;

7.关闭主库testb,复制数据文件和日志文件到备库的位置
testb>shutdown immediate
cp /oracle/oradata/testb/*.dbf /oracle/lsx/testbdg/
cp /oracle/oradata/testb/*.log /oracle/lsx/testbdg/

8.先启动主库到open,再启动备库到mount
testb>startup ;

testbdg>startup mount pfile='/oracle/lsx/testbdg/pfiletestbdg.ora' ;
testbdg>create spfile from pfile='/oracle/lsx/testbdg/pfiletestbdg.ora' ;
testbdg>startup force mount

9.应用日志恢复
testbdg>alter database recover managed standby database disconncet from session ;

10.查看日志是否即时被恢复
select archived_seq#,applied_seq# from v$archive_dest_status ;

11.主备切换
先操作主库
alter database commit to switchover to physical standby with session shutdown ;
shutdown immediate
startup mount

再操作备库
alter database commit to swtichover to primary;
shutdown immediate
startup


 

posted @ 2011-04-23 20:51 李世侠 阅读(129) 评论(0) 编辑

2011年1月4日

新的一年里,祝福朋友们事业有成,快乐开心!

     因为工作变动的原因,好久没有更新博客了,最近又能上外网了,因为偶尔到客户现场,我会尽量更新一些东西,新的一年里,祝福朋友们事业有成,快乐开心!

posted @ 2011-01-04 15:30 李世侠 阅读(64) 评论(0) 编辑

2010年8月12日

在ORACLE数据库间移动或复制表空间测试

做了个移动表空间的测试
我想把数据库orcl里面的某个表空间,移到另一个数据库epma

先建一些表空间,以及用户

create tablespace tts1 datafile 'D:\ORADATA\ORCL\TTS1.DBF' SIZE 10M
autoextend on next 10M maxsize unlimited
segment space management auto
extent management local ;

create user tts identified by tts default tablespace tts1
temporary tablespace temp quota unlimited on tts1 ;

grant connect ,resource to tts ;

建一些测试的表
create table testtts(id number,name varchar2(10))  ;
alter table testtts add constraint pk_testtts primary key(id) using index tablespace tts1 ;

select * from user_indexes ;

 

首先把要转移的表设置为只读
alter tablespace tts1 read only ;

select * from dba_directories ;

 

用如下语句导出元数据信息

set ORACLE_SID=orcl

 

expdp directory=DATA_PUMP_DIR TRANSPORT_TABLESPACES=tts1 dumpfile=tts1.dump

下面是cmd里面的详细过程:
C:\Documents and Settings\lisx>expdp directory=DATA_PUMP_DIR TRANSPORT_TABLESPACES=y tablespaces=tts
1 dumpfile=tts1.dump

Export: Release 10.2.0.1.0 - Production on 星期四, 12 8月, 2010 11:15:28

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

用户名: sys as sysdba
口令:

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
UDE-00010: 已请求多个作业模式, tablespace 和 transport_tablespaces。

 

上面的语句报错,原来expdp转移表空间和exp是有区别的,exp的格式是
EXP transport_tablespace=y tablespaces=tts1,tts2 file=expdat.dmp
注意transport_tablespace后面没有s,不是复数形式的

而用expdp的正确的导出如下:
C:\Documents and Settings\lisx>expdp directory=DATA_PUMP_DIR TRANSPORT_TABLESPACES=tts1 dumpfile=tts
1.dump

Export: Release 10.2.0.1.0 - Production on 星期四, 12 8月, 2010 11:16:06

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

用户名: sys as sysdba
口令:

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
启动 "SYS"."SYS_EXPORT_TRANSPORTABLE_01":  sys/******** AS SYSDBA directory=DATA_PUMP_DIR TRANSPORT_
TABLESPACES=tts1 dumpfile=tts1.dump
处理对象类型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
处理对象类型 TRANSPORTABLE_EXPORT/TABLE
处理对象类型 TRANSPORTABLE_EXPORT/INDEX
处理对象类型 TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
处理对象类型 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
已成功加载/卸载了主表 "SYS"."SYS_EXPORT_TRANSPORTABLE_01"
******************************************************************************
SYS.SYS_EXPORT_TRANSPORTABLE_01 的转储文件集为:
  D:\ADMIN\ORCL\DPDUMP\TTS1.DUMP
作业 "SYS"."SYS_EXPORT_TRANSPORTABLE_01" 已于 11:16:41 成功完成

 

 

下面导入到新的数据库epma
set ORACLE_SID=epma

impdp directory=DATA_PUMP_DIR dumpfile=TTS1.DUMP TRANSPORT_DATAFILES='D:\oradata\epma\TTS1.DBF'


C:\Documents and Settings\lisx>impdp directory=DATA_PUMP_DIR dumpfile=TTS1.DUMP TRANSPORT_DATAFILES=
'D:\oradata\epma\TTS1.DBF'

Import: Release 10.2.0.1.0 - Production on 星期四, 12 8月, 2010 11:29:16

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

用户名: sys as sysdba
口令:

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功加载/卸载了主表 "SYS"."SYS_IMPORT_TRANSPORTABLE_01"
启动 "SYS"."SYS_IMPORT_TRANSPORTABLE_01":  sys/******** AS SYSDBA directory=DATA_PUMP_DIR dumpfile=T
TS1.DUMP TRANSPORT_DATAFILES='D:\oradata\epma\TTS1.DBF'
处理对象类型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
ORA-39123: 数据泵可传输的表空间作业中止
ORA-29342: 数据库中不存在用户 TTS

作业 "SYS"."SYS_IMPORT_TRANSPORTABLE_01" 因致命错误于 11:29:26 停止

 

一定要先建用户TTS,否则报错


create user tts identified by tts  ;
grant connect ,resource to tts ;


C:\Documents and Settings\lisx>impdp directory=DATA_PUMP_DIR dumpfile=TTS1.DUMP TRANSPORT_DATAFILES=
'D:\oradata\epma\TTS1.DBF'

Import: Release 10.2.0.1.0 - Production on 星期四, 12 8月, 2010 11:30:51

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

用户名: sys as sysdba
口令:

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功加载/卸载了主表 "SYS"."SYS_IMPORT_TRANSPORTABLE_01"
启动 "SYS"."SYS_IMPORT_TRANSPORTABLE_01":  sys/******** AS SYSDBA directory=DATA_PUMP_DIR dumpfile=T
TS1.DUMP TRANSPORT_DATAFILES='D:\oradata\epma\TTS1.DBF'
处理对象类型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
处理对象类型 TRANSPORTABLE_EXPORT/TABLE
处理对象类型 TRANSPORTABLE_EXPORT/INDEX
处理对象类型 TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
处理对象类型 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
作业 "SYS"."SYS_IMPORT_TRANSPORTABLE_01" 已于 11:31:10 成功完成

**/

查看发现原来表空间里面的内容果然导入到新的表空间里面了
select * from user_indexes ;

查看状态也是只读
select * from dba_tablespaces ;
select * from dba_data_files ;

alter tablespace tts1 read write ;

 

 

 

 

 

 

 

 

posted @ 2010-08-12 14:13 李世侠 阅读(535) 评论(0) 编辑

2010年7月5日

rman复制数据库ORA-01547ORA-01194ORA-01110,强制打开并修改日志文件

    我用rman复制数据库,做好前期准备了:创建了路径,建密码文件,参数文件,启动到nomount,用RMAN同时连接到源库
和辅助nomount库,当然也提前做了全库备份,并把备份复制到了目标库。

然后执行:
run{
DUPLICATE TARGET DATABASE TO sgpmdb2b
pfile='/oracle/base/admin/sgpmdb2b/pfile/pfilesgpmdb2b.ora'
db_file_name_convert=('/app/oracle/base/oradata/sgpmdb2/','/oracle/base/oradata/sgpmdb2b/');
}

如果顺利的话,数据库会自动重启到open状态,
不顺利的事情十有八九,呵呵。以下是报错
....
b2b/DATA_OUT.DBF
datafile 30 switched to datafile copy
input datafile copy recid=29 stamp=723570072 filename=/oracle/base/oradata/sgpmdb2b/IDX_OUT.DBF
datafile 31 switched to datafile copy
input datafile copy recid=30 stamp=723570072 filename=/oracle/base/oradata/sgpmdb2b/DATA_ARC001.DBF
datafile 32 switched to datafile copy
input datafile copy recid=31 stamp=723570072 filename=/oracle/base/oradata/sgpmdb2b/IDX_ARC001.DBF
datafile 33 switched to datafile copy
input datafile copy recid=32 stamp=723570072 filename=/oracle/base/oradata/sgpmdb2b/tbs_wz.dbf

contents of Memory Script:
{
   set until scn  10161135334995;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 05-JUL-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK

starting media recovery

Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 25 needs more recovery to be consistent
ORA-01110: data file 25: '/oracle/base/oradata/sgpmdb2b/DATA_MAN001.DBF'

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 07/05/2010 15:41:17
RMAN-03015: error occurred in stored script Memory Script
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 2425 lowscn 10161135334770 found to restore
RMAN-06025: no backup of log thread 1 seq 2424 lowscn 10161135334764 found to restore
RMAN-06025: no backup of log thread 1 seq 2423 lowscn 10161135334758 found to restore
RMAN-06025: no backup of log thread 1 seq 2422 lowscn 10161135334751 found to restore
RMAN-06025: no backup of log thread 1 seq 2421 lowscn 10161135334745 found to restore
RMAN-06025: no backup of log thread 1 seq 2420 lowscn 10161135332958 found to restore


我的处理办法:
idle> create spfile from pfile='/oracle/base/admin/sgpmdb2b/pfile/pfilesgpmdb2b.ora' ;

File created.

idle> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
idle> startup mount
ORACLE instance started.

Total System Global Area  205520896 bytes
Fixed Size                  2082816 bytes
Variable Size             150996992 bytes
Database Buffers           46137344 bytes
Redo Buffers                6303744 bytes
Database mounted.
idle> select status from v$instance ;

STATUS
------------
MOUNTED

idle> show parameter db_name ;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      sgpmdb2b
idle> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

idle> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
idle> startup
ORACLE instance started.

Total System Global Area  205520896 bytes
Fixed Size                  2082816 bytes
Variable Size             155191296 bytes
Database Buffers           41943040 bytes
Redo Buffers                6303744 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


idle> alter database open resetlogs ;
alter database open resetlogs
*
ERROR at line 1:
ORA-00344: unable to re-create online log '/oracle/base/oradata/
sgpmdb2b/redo01.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory


idle> select * from v$log ;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          0   52428800          1 YES UNUSED              0
         3          1          0   52428800          1 YES CURRENT             0
         2          1          0   52428800          1 YES UNUSED              0

idle> alter database drop logfile group 1 ;

Database altered.

idle> alter database add logfile '/oracle/base/oradata/sgpmdb2b/redo01.log' size 52m ;

Database altered.

idle> select * from v$log ;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          0   54525952          1 YES UNUSED              0
         3          1          0   52428800          1 YES CURRENT             0
         2          1          0   52428800          1 YES UNUSED              0

idle> select * from v$logfile ;

    GROUP# STATUS  TYPE
---------- ------- -------
MEMBER
----------------------------------------------------------------------------------------------------
IS_
---
         3 STALE   ONLINE
/oracle/base/oradata/
sgpmdb2b/redo03.log
NO

         2 STALE   ONLINE
/oracle/base/oradata/
sgpmdb2b/redo02.log
NO

         1         ONLINE
/oracle/base/oradata/sgpmdb2b/redo01.log
NO

 

--看到这里就清楚了,原来我的初始化文件pfilesgpmdb2b.ora里面的路径有回车,出现了错误。

idle> alter database drop logfile group 2 ;

Database altered.

idle> alter database add logfile '/oracle/base/oradata/sgpmdb2b/redo02.log' size 52m ;

Database altered.

idle>
idle>
idle> alter system switch logfile ;
alter system switch logfile
*
ERROR at line 1:
ORA-01109: database not open

idle> select * from v$logfile ;

    GROUP# STATUS  TYPE
---------- ------- -------
MEMBER
----------------------------------------------------------------------------------------------------
IS_
---
         3 STALE   ONLINE
/oracle/base/oradata/
sgpmdb2b/redo03.log
NO

         2         ONLINE
/oracle/base/oradata/sgpmdb2b/redo02.log
NO

         1         ONLINE
/oracle/base/oradata/sgpmdb2b/redo01.log
NO


idle> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


idle> alter database open resetlogs ;
alter database open resetlogs
*
ERROR at line 1:
ORA-00344: unable to re-create online log '/oracle/base/oradata/
sgpmdb2b/redo03.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory


idle> alter database drop logfile group 3 ;
alter database drop logfile group 3
*
ERROR at line 1:
ORA-01623: log 3 is current log for instance sgpmdb2b (thread 1) - cannot drop
ORA-00312: online log 3 thread 1: '/oracle/base/oradata/
sgpmdb2b/redo03.log'


idle> alter database clear unarchived logfile group 3 ;
alter database clear unarchived logfile group 3
*
ERROR at line 1:
ORA-00344: unable to re-create online log '/oracle/base/oradata/
sgpmdb2b/redo03.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory


idle> alter database drop logfile group 3 ;
alter database drop logfile group 3
*
ERROR at line 1:
ORA-01623: log 3 is current log for instance sgpmdb2b (thread 1) - cannot drop
ORA-00312: online log 3 thread 1: '/oracle/base/oradata/
sgpmdb2b/redo03.log'


idle> alter system switch logfile ;
alter system switch logfile
*
ERROR at line 1:
ORA-01109: database not open


idle> alter database open resetlogs ;
alter database open resetlogs
*
ERROR at line 1:
ORA-00344: unable to re-create online log '/oracle/base/oradata/
sgpmdb2b/redo03.log'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory


idle> alter database rename file '/oracle/base/oradata/
  2  sgpmdb2b/redo03.log' to '/oracle/base/oradata/sgpmdb2b/redo03.log' ;

Database altered.

idle>
idle>
idle>
idle>
idle>
idle> alter database open resetlogs ;

Database altered.

idle> create undo tablespace UNDOTBS2
  2  datafile '/oracle/base/oradata/sgpmdb2b/undotbs02.dbf'
  3  size 200m ;

Tablespace created.

idle> create pfile='/oracle/base/admin/sgpmdb2b/pfile/pfilesgpmdb2b.ora' from spfile ;

File created.

idle> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jul 5 16:35:08 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to an idle instance.


idle> startup pfile='/oracle/base/admin/sgpmdb2b/pfile/pfilesgpmdb2b.ora';
ORACLE instance started.

Total System Global Area  205520896 bytes
Fixed Size                  2082816 bytes
Variable Size             155191296 bytes
Database Buffers           41943040 bytes
Redo Buffers                6303744 bytes
Database mounted.
Database opened.
idle>
idle>
idle>
idle> create spfile from pfile='/oracle/base/admin/sgpmdb2b/pfile/pfilesgpmdb2b.ora';

File created.

idle>
idle>
idle>
idle> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

idle> startup
ORACLE instance started.

Total System Global Area  205520896 bytes
Fixed Size                  2082816 bytes
Variable Size             155191296 bytes
Database Buffers           41943040 bytes
Redo Buffers                6303744 bytes
Database mounted.
Database opened.
idle>
idle>
idle>
idle> show parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      sgpmdb2b
idle>
idle>
idle>
idle>
idle> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /oracle/base/product/10.2.0/db
                                                 _1/dbs/spfilesgpmdb2b.ora
idle>
idle>
idle>
idle>
idle> select status from v$instance ;

STATUS
------------
OPEN

至此搞定。

posted @ 2010-07-05 17:21 李世侠 阅读(361) 评论(0) 编辑

2010年6月18日

PL/SQL Developer 使用错误的tnsnames.ora,如何修改?

摘要: 对于XP系统在环境变量里面设置TNS_ADMIN项,值为路径,例如D:\oracle10g\NETWORK\ADMIN设置好后,重启PL/SQL Developer即可引用正确位置的tnsnames.ora阅读全文

posted @ 2010-06-18 17:03 李世侠 阅读(705) 评论(0) 编辑

2010年3月22日

测试oracle10g 的IO隔离级别serializable

摘要: 用sys用户给scott一个默认表空间create tablespace lisx datafile '+DATA' ;alter user scott default tablespace lisx ;建测试表create table dept (deptno number(9),deptname varchar2(20),detail varchar2(50) );insert into de...阅读全文

posted @ 2010-03-22 17:23 李世侠 阅读(226) 评论(0) 编辑

2010年3月19日

RAC增加ASM磁盘后某个实例无法启动

摘要: RAC增加ASM磁盘后某个实例无法启动实例2启动到mount也不行[oracle@rac1 ~]$ srvctl start instance -d lsxdb -i lsxdb2 -o mountPRKP-1001 : Error starting instance lsxdb2 on node rac2CRS-0215: Could not start resource 'ora.lsxdb....阅读全文

posted @ 2010-03-19 16:52 李世侠 阅读(274) 评论(0) 编辑

2010年1月28日

oracle 10g 的max函数的bug

摘要: oracle 10g 的max 的bug发现一个简单的函数,返回不是预期的结果create or replace function get_num(CONS_ID in number) return varchar2is v_cons_no varchar2(20);begin select max(cons_no) into v_cons_no from c_cons where cons_id...阅读全文

posted @ 2010-01-28 17:25 李世侠 阅读(839) 评论(1) 编辑

2009年11月6日

最简单的oracle10g手工建库步骤

摘要: 最简单的oracle10g手工建库步骤平台:Linux AS release 4,Oracle10.2.0.4db_name = ypythb1. 设置环境变量$ export ORACLE_BASE=/oracle$ export ORACLE_HOME=/oracle/product/10.2$ export ORACLE_SID=ypythb2. 建初始化参数文件$ vi $ORACLE_H...阅读全文

posted @ 2009-11-06 10:53 李世侠 阅读(1002) 评论(0) 编辑