<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>百里挑一</title> 
<link>http://www.admin99.net/index.php</link> 
<description>linux命令 &#124; seo优化技术 &#124; linux系统管理员指南 --我的学习园地</description> 
<language>zh-cn</language> 
<copyright>Powered by Bo-blog 2.0.2 sp2</copyright>
<item>
<link>http://www.admin99.net/read.php?415</link>
<title>有效清理oracle过大的temp表空间</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Tue, 03 Mar 2009 02:45:52 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?415</guid> 
<description>
<![CDATA[ 
	有台oracle服务器上的temp表空间已经有21G之巨了，磁盘上的空间所剩不多，决定清理一下。<br/>因为服务器访问量并不是很大，半夜里停一两分钟还是能接受的，所以采用了下面的步骤。<br/>我们服务器前台用的是tomcat，在这个例子里。重启tomcat或者重启oracle都是一样的。主要是关掉哪些使用temp空间的session<br/>如果服务器不能停，那么下面的步骤并不合适，将会变得很慢很慢，主要是在drop tablespace这一步。因为之前还有很多session还在使用这个temp空间，所以drop的操作需要一直等待。<br/><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">create &nbsp;temporary &nbsp;tablespace &nbsp;TEMP2 &nbsp;TEMPFILE &nbsp;'/usr/local/opt/oracle/oradata/orcl/temp02.dbf' &nbsp;SIZE &nbsp;512M &nbsp;REUSE &nbsp;AUTOEXTEND &nbsp;ON &nbsp;NEXT &nbsp;640K &nbsp;MAXSIZE &nbsp;UNLIMITED;<br/>alter &nbsp;database &nbsp;default &nbsp;temporary &nbsp;tablespace &nbsp;temp2;<br/>shutdown immediate<br/>startup<br/>drop &nbsp;tablespace &nbsp;temp &nbsp;including &nbsp;contents &nbsp;and &nbsp;datafiles;<br/>create &nbsp;temporary &nbsp;tablespace &nbsp;TEMP &nbsp;TEMPFILE &nbsp;'/usr/local/opt/oracle/oradata/orcl/temp01.dbf' &nbsp;SIZE &nbsp;512M &nbsp;REUSE &nbsp;AUTOEXTEND &nbsp;ON &nbsp;NEXT &nbsp;640K &nbsp;MAXSIZE &nbsp;UNLIMITED; <br/>alter &nbsp;database &nbsp;default &nbsp;temporary &nbsp;tablespace &nbsp;temp;<br/>shutdown immediate<br/>startup<br/>drop &nbsp;tablespace &nbsp;temp2 &nbsp;including &nbsp;contents &nbsp;and &nbsp;datafiles;</div></div><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=oracle" rel="tag">oracle</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?409</link>
<title>在redhat 5.1 上安装oracle 10g</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Sun, 21 Dec 2008 12:59:34 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?409</guid> 
<description>
<![CDATA[ 
	redhat 5.1 安装 oracle 10g 的过程<br/>1、软件包下载：<br/>http://www.oracle.com/technology/software/products/database/oracle10g/index.html<br/>2、解压软件包：<br/>unzip 10201_database_linux32.zip<br/>3、修改系统内核：<br/> vi /etc/sysctl.conf<br/>在文件中添加如下内容：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">kernel.shmall = 2097152<br/>kernel.shmmax = 2147483648<br/>kernel.shmmni = 4096<br/>kernel.sem = 250 32000 100 128<br/># semaphores: semmsl, semmns, semopm, semmnikernel.sem = 250 32000 100 128<br/>fs.file-max = 65536<br/>net.ipv4.ip_local_port_range = 1024 65000<br/>net.core.rmem_default=262144<br/>net.core.rmem_max=262144<br/>net.core.wmem_default=262144<br/>net.core.wmem_max=262144</div></div><br/>其中kernel.shmall和kernel.shmmax 在该文件中已存在，将已存在的注释掉即可。<br/>sysctl -p &nbsp; &nbsp; &nbsp;#使设置生效<br/>4、vi /etc/security/limits.conf<br/>添加如下内容：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">* soft nproc 2047<br/>* hard nproc 16384<br/>* soft nofile 1024<br/>* hard nofile 65536</div></div><br/>5、vi /etc/pam.d/login<br/>添加如下内容：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">session required /lib/security/pam_limits.so</div></div><br/>6、vi /etc/selinux/config<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">SELINUX=disabled #关闭selinux</div></div><br/>vi /etc/redhat-release<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">Red Hat Enterprise Linux Server release 4 (Tikanga)</div></div><br/>将原来的版本 5.1 改成了现在的4<br/>7、安装相关的开发包（rpm包）：<br/>rpm -q binutils compat-db control-center gcc gcc-c++ glibc libXp-1.0.0 libstdc++ &#92;<br/>libstdc++-devel make openmotif-2.3.0<br/><br/>binutils-2.17.50.0.6-5.el5<br/>compat-db-4.2.52-5.1<br/>control-center-2.16.0-14.el5<br/>gcc-4.1.2-14.el5<br/>gcc-c++-4.1.2-14.el5<br/>glibc-2.5-18<br/>libXp-1.0.0-8.1.el5<br/>libstdc++-4.1.2-14.el5<br/>libstdc++-devel-4.1.2-14.el5<br/>make-3.81-1.1<br/>openmotif-2.3.0-0.3.el5<br/>我已经安装完成了。<br/>8、创建Oracle用户组和必须的目录<br/>（1）、创建用户组<br/>groupadd dbagroup<br/>groupadd oinstall<br/>（2）、添加oracle用户<br/>useradd -g oinstall -G dbagroup oracle<br/>passwd oracle<br/>（3）、创建oracle的安装目录<br/>mkdir -p /data/oracle/product/10.2.0<br/>chown oracle.oinstall /data/oracle<br/>9、用oracle用户登陆，建立环境变量<br/>su - oracle<br/>vi .bash_profile<br/>添加如下设置：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># Oracle Settings<br/>ORACLE_BASE=/data/oracle; export ORACLE_BASE<br/>ORACLE_HOME=$ORACLE_BASE/product/10.2.0/;export ORACLE_HOME<br/>ORACLE_SID=admin99;export ORACLE_SID<br/>ORACLE_TERM=xterm;export ORACLE_TERM<br/>PATH=$PATH:$ORACLE_HOME/bin;export PATH<br/>LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;<br/>export LD_LIBRARY_PATH<br/>CLASSPATH=$ORACLE_HOME/JREORACLE_HOME/jlib$ORACLE_HOME/rdbms/jlib;<br/>export LANG=AMRICAN<br/>export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK</div></div><br/> &nbsp; &nbsp;使更改生效<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">source .bash_profile</div></div><br/> &nbsp; &nbsp;10、设置vnc (如果是在本机安装就跳过这步)<br/>具体参考 http://www.admin99.net/read.php/283.htm<br/> &nbsp; &nbsp;11、开始安装<br/>在刚才解压缩的目录下执行<br/>./runInstaller <br/><br/>安装过程中按要求设置各种参数<br/>安装过程的最后会要求以root权限执行两个脚本<br/>我在安装过程中遇到了两个问题<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">makefile '/oracle/product/10.2.0/db_1/rdbms/lib/ins_rdbms.mk' 的目标 'all_no_orcl' 时出错”</div></div><br/>查看安装日志是提示<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">/usr/lib/libstdc++.so.5: No such file or directory</div></div><br/>通过链接一个高版本的动态链接库解决了<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ln -s /usr/lib/libstdc++.so.6 /usr/lib/libstdc++.so.5</div></div><br/>还有个问题是提示<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">checking for semopm=100; found semopm=32</div></div><br/>通过在sysctl.conf中添加下面一条指令<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">kernel.sem = 250 32000 100 128</div></div><br/>然后执行 sysctl -p 解决了<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=oracle" rel="tag">oracle</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?405</link>
<title>简单的oracle随linux自启动脚本</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Sun, 07 Dec 2008 13:09:09 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?405</guid> 
<description>
<![CDATA[ 
	创建文件 /usr/bash/startoracle<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">touch /usr/bash/startoracle</div></div><br/>内容为<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">sqlplus &quot;/as sysdba&quot; &lt;&lt;eof<br/>startup<br/>exit<br/>eof</div></div><br/>赋予oracle用户的执行权限<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">chown oracle:dba /usr/bash/startoracle<br/>chmod 755 /usr/bash/startoracle</div></div><br/>在/etc/rc.d/rc.local中加入下面一行<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">su - oracle -c &quot;/usr/bash/startoracle&quot;</div></div><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=oracle" rel="tag">oracle</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?400</link>
<title>通过linux管道加快oracle exp/imp的速度</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Sun, 16 Nov 2008 02:00:31 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?400</guid> 
<description>
<![CDATA[ 
	通过exp直接导出的dmp文件，经过gzip压缩后，一般能减少60～80％的磁盘空间<br/>exp和imp不能像mysqldump那样直接使用管道命令"&#124;"，所以需要使用管道文件<br/><br/>1.通过 mknod /tmp/pipe p 建立管道文件，不要忘了参数p<br/>2.通过 exp和 gzip导出数据到建立的管道并压缩<br/> &nbsp; &nbsp;exp test/test file=/tmp/pipe & gzip < /tmp/pipe > exp.dmp.gz<br/>3.导出成功完成之后删除建立的管道<br/> &nbsp; &nbsp;rm &nbsp; &nbsp;-rf &nbsp; &nbsp;/tmp/pipe<br/><br/>下面是个自动导出的脚本<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">export ORACLE_HOME=/usr/local/opt/oracle/product/9204;<br/>export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;<br/>export ORACLE_SID=orcl;<br/>mknod /tmp/pipe p;<br/>exp admin99/admin99passwd owner=admin99 file=/tmp/pipe & gzip < /tmp/pipe > /home/oracle/backup/admin99$(date +%Y%m%d).dmp.gz;<br/>rm -rf /tmp/pipe;<br/>rm -rf /home/oracle/backup/*$(date +%Y%m%d -d '7 days ago')*</div></div><br/>可以自动完成备份并删除7天前的备份数据<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=oracle" rel="tag">oracle</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?305</link>
<title>转贴-优化你的Oracle for Linux</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Thu, 27 Mar 2008 05:26:02 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?305</guid> 
<description>
<![CDATA[ 
	1. 标准优化：遵从Oracle技术文档中的说明tune你的Linux，比如共享内存等。这里不赘述，因为文档中很全 <br/>2. 根据你的使用情况采取Dedicate型或MTS型数据库。详细方法也看文档。 <br/>3. 如果你不是对数据库中的Java应用特别有需求的话，不要装它，也不要启动它-如果你装了的话。 <br/>4. 对你的服务器来说，最好专用。如果你不专用，说明你对性能并不那么敏感，也用不着优化了:-) <br/>5. 内存越大越好。但Linux对内存大小有限制，因此需要去找一些Patch <br/>6. 到http://oss.sgi.com区，下载一个SGI's POSIX Asynchronous I/O and Raw I/O 的内核Patch。它能大幅度提高你数据文件的访问速度 <br/>7. 如果你采用ext2文件系统，把Block的大小增加到4~8K.其中dbf所在分区的大小 最少弄到8192 <br/>8. 尽可能用SCSI硬盘。如果是IDE的，好好调调参数 <br/>9. 这里是一个别人写的程序 <br/>set -a <br/>VM=/proc/sys/vm <br/>BDFLUSH="40 1024 64 256 500 3000 500 1884 2" <br/>BUFFERMEM="5 8 10" <br/>FREEPAGES="512 1024 3072" <br/>OVERCOMMIT="1" <br/>case $1 in <br/>start) <br/>echo "$BDFLUSH"&gt;$VM/bdflush <br/>echo "$BUFFERMEM"&gt;$VM/buffermem <br/>echo "$FREEPAGES"&gt;$VM/freepages <br/>echo "$OVERCOMMIT"&gt;$VM/overcommit_memory <br/>/sbin/hdparm -k -u 1 -m 32 -c 1 /dev/hda; <br/>/sbin/hdparm -k -u 1 -m 16 -c 1 /dev/hdc; <br/>;; <br/>stop) <br/>touch /root/shouldnt.happen; <br/>;; <br/>*) <br/>echo "USAGE $0 {start&#124;stop}"; <br/>;; <br/>esac; <br/><br/>10. 如果你有Solaris for X86的话，可以运用它的分区工具把你的所有分区都改成UFS。Linux的当前Kernel是支持UFS的。在数据库运用上， UFS比ext2好 <br/>11. 如果可能，应该采用诸如IBM JFS或SGI XFS这样的64位文件系统。http://oss.sgi.com是个大宝库，你不妨再去看看。这些日志文件系统 不仅能大幅度提高性能，还给你带来其它好处，比如掉电以后用不着花两个小时检查文件系统 <br/>12。 不要用Linux发行版带的核心，要自己编译。关于核心优化，也有相当多的文章介绍，可以到http://www.linux.com去看看核心tune up的文章。<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96" rel="tag">性能优化</a> , <a href="http://www.admin99.net/tag.php?tag=oracle" rel="tag">oracle</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?300</link>
<title>oracle9204上安装和使用statspack</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Tue, 11 Mar 2008 03:29:28 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?300</guid> 
<description>
<![CDATA[ 
	redhat 5.0 &nbsp;oracle 9204 测试通过<br/><br/>一。用管理员帐户登陆，创建statspack所需的表空间，一般情况下，给100M空间差不多了<br/>sqlplus "/as sysdba"<br/>SQL> create tablespace statspack datafile '/home/oracle/oradata/db/statspack.dbf' size 100M AUTOEXTEND ON EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K<br/><br/>二。执行安装脚本，脚本在 $oracle_home/rdbms/admin目录下，脚本名称为spcreate.sql<br/><br/>SQL> @spcreate.sql<br/><br/>创建过程中会让提示输入新建用户perfstat的密码、默认表空间、默认临时表空间，我在这里分别设置为: admin99 &nbsp; statspack &nbsp;temp<br/><br/>三。以 prefstat用户连接oracle<br/>sql>conn perfstat/oracle<br/><br/>四。抓取快照。要生成报告，至少要有同一数据库没有中断的运行周期内的两次快照，两次快照的时间间隔好像是随意的，我一般取半小时的间隔。<br/>sql>exec statspack.snap<br/>--至少要两次快照<br/>sql>exec statspack.snap<br/><br/>五。生成报告。会提示你输入开始和结束的快照id号，以及报告的名称<br/><br/>sql>@spreport.sql<br/><br/>生成报告后，就可以用文本编辑器来查看报告了<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=statspack" rel="tag">statspack</a> , <a href="http://www.admin99.net/tag.php?tag=oracle" rel="tag">oracle</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?297</link>
<title>修改oracle最大连接数</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Tue, 04 Mar 2008 10:05:29 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?297</guid> 
<description>
<![CDATA[ 
	oracle 9204默认150个连接，现在的生产环境中，这个连接数已经不够用了，需要调整一下。<br/>调整这个参数需要注意pga的大小。<br/>一。备份现有配置文件。<br/><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>cp -p initadmin99.ora initadmin99.ora.20080303<br/>cp -p spfileadmin99.ora spfileadmin99.ora.20080303<br/></div></div><br/>二。以sysdba权限登入数据库，更改参数以及更新配置文件<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>[oracle@test2 ~]$ sqlplus "/as sysdba"<br/></div></div><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>SQL> show parameter processes<br/><br/>NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VALUE<br/>------------------------------------ -------------------------------- ------------------------------<br/>aq_tm_processes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br/>db_writer_processes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br/>job_queue_processes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br/>log_archive_max_processes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2<br/>processes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;300<br/><br/>SQL> alter system set processes=300 scope=spfile;<br/><br/>System altered.<br/><br/>SQL> create pfile from spfile;<br/><br/>File created.<br/><br/></div></div><br/>三。重起数据库<br/><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96" rel="tag">性能优化</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?296</link>
<title>TOAD执行计划中报ORA-02404的解决方法</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Mon, 25 Feb 2008 08:24:23 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?296</guid> 
<description>
<![CDATA[ 
	创建toad所需要的表:<br/><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>CREATE TABLE toad_plan_table ( &nbsp; <br/> &nbsp;STATEMENT_ID &nbsp; &nbsp; VARCHAR2 (32), &nbsp; <br/> &nbsp;TIMESTAMP &nbsp; &nbsp; &nbsp; &nbsp;DATE, &nbsp; <br/> &nbsp;remarks &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VARCHAR2 (80), &nbsp; <br/> &nbsp;operation &nbsp; &nbsp; &nbsp; &nbsp;VARCHAR2 (30), &nbsp; <br/> &nbsp;options &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VARCHAR2 (30), &nbsp; <br/> &nbsp;object_node &nbsp; &nbsp; &nbsp;VARCHAR2 (128), &nbsp; <br/> &nbsp;object_owner &nbsp; &nbsp; VARCHAR2 (30), &nbsp; <br/> &nbsp;object_name &nbsp; &nbsp; &nbsp;VARCHAR2 (30), &nbsp; <br/> &nbsp;object_instance &nbsp;NUMBER, &nbsp; <br/> &nbsp;object_type &nbsp; &nbsp; &nbsp;VARCHAR2 (30), &nbsp; <br/> &nbsp;search_columns &nbsp; NUMBER, &nbsp; <br/> &nbsp;ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NUMBER, &nbsp; <br/> &nbsp;COST &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NUMBER, &nbsp; <br/> &nbsp;parent_id &nbsp; &nbsp; &nbsp; &nbsp;NUMBER, &nbsp; <br/> &nbsp;POSITION &nbsp; &nbsp; &nbsp; &nbsp; NUMBER, &nbsp; <br/> &nbsp;CARDINALITY &nbsp; &nbsp; &nbsp;NUMBER, &nbsp; <br/> &nbsp;optimizer &nbsp; &nbsp; &nbsp; &nbsp;VARCHAR2 (255), &nbsp; <br/> &nbsp;BYTES &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NUMBER, &nbsp; <br/> &nbsp;other_tag &nbsp; &nbsp; &nbsp; &nbsp;VARCHAR2 (255), &nbsp; <br/> &nbsp;other &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LONG, &nbsp; <br/> &nbsp;PARTITION &nbsp; &nbsp; &nbsp; &nbsp;NUMBER, &nbsp; <br/> &nbsp;partition_start &nbsp;VARCHAR2 (255), &nbsp; <br/> &nbsp;partition_stop &nbsp; VARCHAR2 (255), &nbsp; <br/> &nbsp;distribution &nbsp; &nbsp; VARCHAR2 (30) &nbsp; <br/>); &nbsp;<br/></div></div><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=toad" rel="tag">toad</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?294</link>
<title>oracle海量数据的批量删除与提交</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Thu, 21 Feb 2008 02:26:43 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?294</guid> 
<description>
<![CDATA[ 
	提出的需求是需要删除一个表中的约500w行数据，这个表里只需要保留大约2w行。<br/>最初的想法是把这2w行插入临时表，然后truncate原表，再将这2w行插入原表。这样做效率最高，但是很不幸的发现表里有个自增长的列，而且该列与一些重要的数据绑定的，绝对不能变动，而导入导出的话，这列的值好像就要变掉了。逼不得已，delete慢慢删吧。<br/>直接delete肯定是不行的。数据库服务器的配置不高，而且该表有30多列，大多是varchar2 (255char)<br/>测试了一下<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">delete from user_bbs where usertype=2 and creattime is null and rownum < 1000</div></div><br/>大约执行了1分钟，照这样计算，500w行大概要80多个小时.....<br/>被事情逼着的时候，学习效果最好了。<br/>以前断断续续的学写存储过程，写来写去没觉得什么意思，这次没办法了，写吧。<br/>初步的设想是每删100条提交一下，然后在屏幕上给出提示<br/>先打开屏幕输出<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">set serveroutput on size 1000000</div></div><br/>这个是 output的提示<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">DBMS_OUTPUT.PUT_LINE('Totally '&#124;&#124;to_char(i * 100)&#124;&#124;' records deleted!');</div></div><br/>不过很遗憾的发现，存储过程并不能loop一次就打印一次，而是执行完了才能一次性把结果打印出来，在网上查了查，也只能这样。这不行，我要在屏幕前等死掉的。<br/>最后找到折中的办法，每loop一次，将提示信息插入到一个临时表中。<br/>先创建个临时表<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>create table tempcount (count number(19));<br/></div></div><br/>将存储过程写入到del.sql 文件中，其中的注释是后来加的<br/>del.sql 内容如下：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>create or replace procedure del<br/> as<br/> &nbsp; i number:=0 ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--设置个变量控制循环<br/> &nbsp; begin<br/> &nbsp; &nbsp; while i < 100000 loop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--循环条件<br/> &nbsp; &nbsp; &nbsp; &nbsp;EXECUTE IMMEDIATE<br/> &nbsp; &nbsp; &nbsp; &nbsp;'delete from user_bbs where usertype=2 and creattime is null and rownum < 100 ' ;<br/> &nbsp; &nbsp; &nbsp; &nbsp;if SQL%NOTFOUND then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--如果删完了就推出<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br/> &nbsp; &nbsp; &nbsp; &nbsp;else<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i := i + 1;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EXECUTE IMMEDIATE<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'update tempcount set count = '&#124;&#124;i*100&#124;&#124;'' ; &nbsp; &nbsp; &nbsp; &nbsp; --每删100条，将删除的条数插入临时表<br/> &nbsp; &nbsp; &nbsp; &nbsp;end if; &nbsp; &nbsp; &nbsp; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp;commit;<br/> &nbsp; &nbsp; &nbsp;end loop;<br/> &nbsp; commit;<br/>end;<br/>/<br/>exec del<br/></div></div><br/>然后通过sqlplus在后台执行del.sql<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>sqlplus username/password &nbsp;@del.sql &<br/></div></div><br/>另开一个sqlplus，查看运行状态<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>SQL> select * from tempcount;<br/><br/> &nbsp; &nbsp; COUNT<br/>----------<br/> &nbsp; &nbsp; 100<br/><br/>SQL> /<br/><br/> &nbsp; &nbsp; COUNT<br/>----------<br/> &nbsp; &nbsp; 200<br/><br/></div></div><br/>已经在运行了<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B" rel="tag">存储过程</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?293</link>
<title>ORA-27123 sga 1.7G内存限制</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>oracle</category>
<pubDate>Tue, 19 Feb 2008 01:52:24 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?293</guid> 
<description>
<![CDATA[ 
	调整sga到2.5G，启动时没启动起来，报错如下：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">SQL> startup<br/>ORA-32004: obsolete and/or deprecated parameter(s) specified<br/>ORA-27123: unable to attach to shared memory segment<br/>Linux Error: 22: Invalid argument<br/>Additional information: 1<br/>Additional information: 65536</div></div><br/><br/>查了查原来是32位平台上 9i的sga默认最多只能扩展到1.7G，如果想突破这个限制，需要重新link Oracle软件。<br/>先不管了，调整到1.7G先用着吧<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=oracle" rel="tag">oracle</a>
  ]]> 
</description>
</item>
</channel>
</rss>