Vim的编码及字体问题详解

[不指定 2009/08/10 21:33 | by ipaddr ]

Vim 有四个跟字符编码方式有关的选项,encodingfileencodingfileencodingstermencoding (这些选项可能的取值请参考 Vim 在线帮助 :help encoding-names),它们的意义如下:

* encoding: Vim 内部使用的字符编码方式,包括 Vim buffer (缓冲区)、菜单文本、消息文本等。默认是根据你的locale选择.用户手册上建议只在 .vimrc 中改变它的值,事实上似乎也只有在.vimrc 中改变它的值才有意义。你可以用另外一种编码来编辑和保存文件,如你的vimencodingutf-8,所编辑的文件采用cp936编码,vim会 自动将读入的文件转成utf-8(vim的能读懂的方式),而当你写入文件时,又会自动转回成cp936(文件的保存编码).

* fileencoding: Vim 中当前编辑的文件的字符编码方式,Vim 保存文件时也会将文件保存为这种字符编码方式 (不管是否新文件都如此)

* fileencodings: Vim自动探测fileencoding的顺序列表,启动时会按照它所列出的字符编码方式逐一探测即将打开的文件的字符编码方式,并且将 fileencoding 设置为最终探测到的字符编码方式。因此最好将Unicode 编码方式放到这个列表的最前面,将拉丁语系编码方式 latin1 放到最后面。

* termencoding: Vim 所工作的终端 (或者 Windows Console 窗口) 的字符编码方式。如果vim所在的termvim编码相同,则无需设置。如其不然,你可以用vimtermencoding选项将自动转换成term 的编码.这个选项在 Windows 下对我们常用的 GUI 模式的 gVim 无效,而对 Console 模式的Vim 而言就是 Windows 控制台的代码页,并且通常我们不需要改变它。

好了,解释完了这一堆容易让新手犯糊涂的参数,我们来看看 Vim 的多字符编码方式支持是如何工作的。

1. Vim 启动,根据 .vimrc 中设置的 encoding 的值来设置 buffer、菜单文本、消息文的字符编码方式。

2. 读取需要编辑的文件,根据 fileencodings 中列出的字符编码方式逐一探测该文件编码方式。并设置 fileencoding 为探测到的,看起来是正确的 (1) 字符编码方式。

3. 对比 fileencoding encoding 的值,若不同则调用 iconv 将文件内容转换为encoding 所描述的字符编码方式,并且把转换后的内容放到为此文件开辟的 buffer 里,此时我们就可以开始编辑这个文件了。注意,完成这一步动作需要调用外部的 iconv.dll(2),你需要保证这个文件存在于 $VIMRUNTIME 或者其他列在 PATH 环境变量中的目录里。

4. 编辑完成后保存文件时,再次对比 fileencoding encoding 的值。若不同,再次调用 iconv 将即将保存的 buffer 中的文本转换为 fileencoding 所描述的字符编码方式,并保存到指定的文件中。同样,这需要调用 iconv.dll由于 Unicode 能够包含几乎所有的语言的字符,而且 Unicode UTF-8 编码方式又是非常具有性价比的编码方式 (空间消耗比 UCS-2 ),因此建议 encoding 的值设置为utf-8。这么做的另一个理由是 encoding 设置为 utf-8 时,Vim 自动探测文件的编码方式会更准确 (或许这个理由才是主要的 ;)。我们在中文 Windows 里编辑的文件,为了兼顾与其他软件的兼容性,文件编码还是设置为 GB2312/GBK 比较合适,因此 fileencoding 建议设置为 chinese (chinese 是个别名,在 Unix 里表示 gb2312,在 Windows 里表示cp936,也就是 GBK 的代码页)

以下是我的 .vimrc(见附件) 中关于字符编码方式设置的内容,这个设置比较有弹性,可以根据系统中的环境变量 $LANG (当然,Windows 中的写法是 %LANG%) 的值来自动设置合适的字符编码方式。此时,推荐设置 %LANG% = zh_CN.UTF-8,可以通过后面的 Windows 注册表脚本文件来方便的做到。

1: 事实上,Vim 的探测准确度并不高,尤其是在 encoding 没有设置为 utf-8 时。因此强烈建议将 encoding 设置为 utf-8,虽然如果你想 Vim 显示中文菜单和提示消息的话这样会带来另一个小问题。

2: GNU FTP 上可以下载到 iconv Win32 (http://mirrors.kernel.org/gnu/libiconv/libiconv-1.9.1.bin.woe32.zip),不推荐去GnuWin32(http://gnuwin32.sourceforge.net/) 下载 libiconv,因为那个版本旧一些,并且需要自己改名 dll 文件。

3: 查看帮助 :h iconv-dynamic

强烈推荐:240多个jQuery插件

[不指定 2009/08/06 10:52 | by ipaddr ]

概述

jQuery 是继 prototype 之后又一个优秀的 Javascript 框架。其宗旨是—写更少的代码,做更多的事情。它是轻量级的 js 库(压缩后只有21k) ,这是其它的 js 库所不及的,它兼容 CSS3,还兼容各种浏览器(IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)。 jQuery 是一个快速的,简洁的 javaScript 库,使用户能更方便地处理 HTML documents、events、实现动画效果,并且方便地为网站提供 AJAX 交互。 jQuery 还有一个比较大的优势是,它的文档说明很全,而且各种应用也说得很详细,同时还有许多成熟的插件可供选择。 jQuery 能够使用户的 html 页保持代码和 html 内容分离,也就是说,不用再在 html 里面插入一堆js来调用命令了,只需定义 id 即可。今天在Kollermedia.at上发现了一篇JQuery插件列表的文章,特推荐如下。

文件上传(File upload)

Ajax File Upload.
jQUploader.
Multiple File Upload plugin
jQuery File Style.
Styling an input type file.
Progress Bar Plugin.

表单验证(Form Validation)

jQuery Validation.
Auto Help.
Simple jQuery form validation.
jQuery XAV - form validations.
jQuery AlphaNumeric.
Masked Input.
TypeWatch Plugin.
Text limiter for form fields.
Ajax Username Check with jQuery.

表单-选取框(Form - Select Box stuff)

jQuery Combobox.
jQuery controlled dependent (or Cascadign) Select List.
Multiple Selects.
Select box manipulation.
Select Combo Plugin.
jQuery - LinkedSelect
Auto-populate multiple select boxes.
Choose Plugin (Select Replacement).

表单基本、输入框、选择框等(Form Basics, Input Fields, Checkboxes etc.)

jQuery Form Plugin.
jQuery-Form.
jLook Nice Forms.
jNice.
Ping Plugin.
Toggle Form Text.
ToggleVal.
jQuery Field Plugin.
jQuery Form’n Field plugin.
jQuery Checkbox manipulation.
jTagging.
jQuery labelcheck.
Overlabel.
3 state radio buttons.
ShiftCheckbox jQuery Plugin.
Watermark Input.
jQuery Checkbox (checkboxes with imags).
jQuery SpinButton Control.
jQuery Ajax Form Builder.
jQuery Focus Fields.
jQuery Time Entry.

时间、日期和颜色选取(Time, Date and Color Picker)

jQuery UI Datepicker.
jQuery date picker plugin.
jQuery Time Picker.
Time Picker.
ClickPick.
TimePicker.
Farbtastic jQuery Color Picker Plugin.
Color Picker by intelliance.fr.

投票插件(Rating Plugins)

jQuery Star Rating Plugin.
jQuery Star Rater.
Content rater with asp.net, ajax and jQuery.
Half-Star Rating Plugin.

搜索插件(Search Plugins)

jQuery Suggest.
jQuery Autocomplete.
jQuery Autocomplete Mod.
jQuery Autocomplete by AjaxDaddy.
jQuery Autocomplete Plugin with HTML formatting.
jQuery Autocompleter.
AutoCompleter (Tutorial with PHP&MySQL).
quick Search jQuery Plugin.

编辑器(Inline Edit & Editors)

jTagEditor.
WYMeditor.
jQuery jFrame.
Jeditable - edit in place plugin for jQuery.
jQuery editable.
jQuery Disable Text Select Plugin.
Edit in Place with Ajax using jQuery.
jQuery Plugin - Another In-Place Editor.
TableEditor.
tEditable - in place table editing for jQuery.

多媒体、视频、Flash等(Audio, Video, Flash, SVG, etc)

jMedia - accessible multi-media embedding.
JBEdit - Ajax online Video Editor.
jQuery MP3 Plugin.
jQuery Media Plugin.
jQuery Flash Plugin.
Embed QuickTime.
SVG Integration.

图片(Photos/Images/Galleries)

ThickBox.
jQuery lightBox plugin.
jQuery Image Strip.
jQuery slideViewer.
jQuery jqGalScroll 2.0.
jQuery - jqGalViewII.
jQuery - jqGalViewIII.
jQuery Photo Slider.
jQuery Thumbs - easily create thumbnails.
jQuery jQIR Image Replacement.
jCarousel Lite.
jQPanView.
jCarousel.
Interface Imagebox.
Image Gallery using jQuery, Interface & Reflactions.
simple jQuery Gallery.
jQuery Gallery Module.
EO Gallery.
jQuery ScrollShow.
jQuery Cycle Plugin.
jQuery Flickr.
jQuery Lazy Load Images Plugin.
Zoomi - Zoomable Thumbnails.
jQuery Crop - crop any image on the fly.
Image Reflection.

Google地图(Google Map)

jQuery Plugin googlemaps.
jMaps jQuery Maps Framework.
jQmaps.
jQuery & Google Maps.
jQuery Maps Interface forr Google and Yahoo maps.
jQuery J Maps - by Tane Piper.

游戏(Games)

Tetris with jQuery.
jQuery Chess.
Mad Libs Word Game.
jQuery Puzzle.
jQuery Solar System (not a game but awesome jQuery Stuff).

表格等(Tables, Grids etc.)

UI/Tablesorter.
jQuery ingrid.
jQuery Grid Plugin.
Table Filter - awesome!.
TableEditor.
jQuery Tree Tables.
Expandable “Detail” Table Rows.
Sortable Table ColdFusion Costum Tag with jQuery UI.
jQuery Bubble.
TableSorter.
Scrollable HTML Table.
jQuery column Manager Plugin.
jQuery tableHover Plugin.
jQuery columnHover Plugin.
jQuery Grid.
TableSorter plugin for jQuery.
tEditable - in place table editing for jQuery.
jQuery charToTable Plugin.
jQuery Grid Column Sizing.
jQuery Grid Row Sizing.

统计图(Charts, Presentation etc.)

jQuery Wizard Plugin .
jQuery Chart Plugin.
Bar Chart.

边框、圆角、背景(Border, Corners, Background)

jQuery Corner.
jQuery Curvy Corner.
Nifty jQuery Corner.
Transparent Corners.
jQuery Corner Gallery.
Gradient Plugin.

文字和超链接(Text and Links)

jQuery Spoiler plugin.
Text Highlighting.
Disable Text Select Plugin.
jQuery Newsticker.
Auto line-height Plugin.
Textgrad - a text gradient plugin.
LinkLook - a link thumbnail preview.
pager jQuery Plugin.
shortKeys jQuery Plugin.
jQuery Biggerlink.
jQuery Ajax Link Checker.

鼠标提示(Tooltips)

jQuery Plugin - Tooltip.
jTip - The jQuery Tool Tip.
clueTip.
BetterTip.
Flash Tooltips using jQuery.
ToolTip.

菜单和导航(Menus, Navigations)

jQuery Tabs Plugin - awesome! . [demo nested tabs.]
another jQuery nested Tab Set example (based on jQuery Tabs Plugin).
jQuery idTabs.
jdMenu - Hierarchical Menu Plugin for jQuery.
jQuery SuckerFish Style.
jQuery Plugin Treeview.
treeView Basic.
FastFind Menu.
Sliding Menu.
Lava Lamp jQuery Menu.
jQuery iconDock.
jVariations Control Panel.
ContextMenu plugin.
clickMenu.
CSS Dock Menu.
jQuery Pop-up Menu Tutorial.
Sliding Menu.

http://stilbuero.de/jquery/tabs_3/

幻灯、翻转等(Accordions, Slide and Toggle stuff)

jQuery Plugin Accordion.
jQuery Accordion Plugin Horizontal Way.
haccordion - a simple horizontal accordion plugin for jQuery.
Horizontal Accordion by portalzine.de.
HoverAccordion.
Accordion Example from fmarcia.info.
jQuery Accordion Example.
jQuery Demo - Expandable Sidebar Menu.
Sliding Panels for jQuery.
jQuery ToggleElements.
Coda Slider.
jCarousel.
Accesible News Slider Plugin.
Showing and Hiding code Examples.
jQuery Easing Plugin.
jQuery Portlets.
AutoScroll.
Innerfade.

拖放插件(Drag and Drop)

UI/Draggables.
EasyDrag jQuery Plugin.
jQuery Portlets.
jqDnR - drag, drop resize.
Drag Demos.

XML XSL JSON Feeds

XSLT Plugin.
jQuery Ajax call and result XML parsing.
xmlObjectifier - Converts XML DOM to JSON.
jQuery XSL Transform.
jQuery Taconite - multiple Dom updates.
RSS/ATOM Feed Parser Plugin.
jQuery Google Feed Plugin.

浏览器(Browserstuff)

Wresize - IE Resize event Fix Plugin.
jQuery ifixpng.
jQuery pngFix.
Link Scrubber - removes the dotted line onfocus from links.
jQuery Perciformes - the entire suckerfish familly under one roof.
Background Iframe.
QinIE - for proper display of Q tags in IE.
jQuery Accessibility Plugin.
jQuery MouseWheel Plugin.

对话框、确认窗口(Alert, Prompt, Confirm Windows)

jQuery Impromptu.
jQuery Confirm Plugin.
jqModal.
SimpleModal.

CSS

jQuery Style Switcher.
JSS - Javascript StyleSheets.
jQuery Rule - creation/manipulation of CSS Rules.
jPrintArea.

DOM、AJAX和其它JQuery插件(DOM, Ajax and other jQuery plugins)

FlyDOM.
jQuery Dimenion Plugin.
jQuery Loggin.
Metadata - extract metadata from classes, attributes, elements.
Super-tiny Client-Side Include Javascript jQuery Plugin.
Undo Made Easy with Ajax.
JHeartbeat - periodically poll the server.
Lazy Load Plugin.
Live Query.
jQuery Timers.
jQuery Share it - display social bookmarking icons.
jQuery serverCookieJar.
jQuery autoSave.
jQuery Puffer.
jQuery iFrame Plugin.
Cookie Plugin for jQuery.
jQuery Spy - awesome plugin.
Effect Delay Trick.
jQuick - a quick tag creator for jQuery.
Metaobjects
.
elementReady.

Useful Uses Of netcat

[不指定 2009/08/05 11:58 | by ipaddr ]

1 Preliminary Note

I'm using two systems in this article:

  • server1.example.com: IP address 192.168.0.100  
  • server2.example.com: IP address 192.168.0.101

netcat should already be installed on your system - you can check with

which nc

To learn more about netcat, take a look at its man page:

man nc

 

2 Copying A File From One System To The Other

Let's say we want to copy the file ISPConfig-2.2.27.tar.gz from server1 to server2. To do this,  run

server2:

nc -lp 1234 > ISPConfig-2.2.27.tar.gz

on server2 (1234 is some  unused port - you can replace it with another value if you like). server2 will  then wait for the file ISPConfig-2.2.27.tar.gz on port  1234.

On server1, run

server1:

nc -w 1 server2.example.com 1234 <  ISPConfig-2.2.27.tar.gz

to start the file transfer.

 

3 Cloning Hard Drives & Partitions

You can use netcat even to clone hard drives/partitions over the network. In  this example, I want to clone /dev/sda from server1 to server2. Of course, the  to-be-cloned partitions must be unmounted on the target system, so if you want  to clone the system partition, you must boot the target system (server2) from a rescue system or Live-CD such as Knoppix. Please keep in mind  that the target system's IP address might change under the live system (you can  find out by running

ifconfig

). server2's IP address in this example is 192.168.0.12 instead of 192.168.0.101.

On server2, run

server2:

nc -l -p 1234 | dd of=/dev/sda

Afterwards, on server1, run

server1:

dd if=/dev/sda | nc 192.168.0.12 1234

to start the cloning process. This can take some time, depending on the size  of the hard drive or partitions.

 

4 Port Scanning

On server1, you can scan for open ports on server2 as follows:

server1:

nc -v -w 1 server2.example.com -z 1-1000

(1-1000 means: scan ports from port number 1 to  port number 1000.)

You can also scan ports on the local system:

nc -v -w 1 localhost -z 1-1000

 

5 Serving Web Pages

You can even use netcat to act as a web server:

while true; do nc -l -p 80 -q 1 < somepage.html; done

would serve the page somepage.html until you close  the terminal window.

 

6 Spoofing HTTP Headers

You can use netcat to request web pages:

nc ispconfig.org 80

You can then type in headers as follows:

GET / HTTP/1.1
Host: ispconfig.org
Referrer:  mypage.com
User-Agent: my-browser

As you see, this allows you to make up your own referrers and browser (User-Agent). After you've typed in your headers, press ENTER twice, and the requested page will appear (including  the headers sent back by the remote server):

server2:~# nc exampple.com 80
GET / HTTP/1.1
Host:  example.com
Referrer: mypage.com
User-Agent: my-browser

HTTP/1.1 200 OK
Date: Fri, 28 Nov 2008 14:11:49  GMT
Server: Apache/2.2.3 (Debian) mod_ssl/2.2.3  OpenSSL/0.9.8c
Last-Modified: Wed, 26 Nov 2008 19:34:17 GMT
ETag:  "228c707-21b1-b6b7e040"
Accept-Ranges: bytes
Content-Length:  8625
Content-Type: text/html

[...]

 

7 Chatting

You can even use netcat to chat from one system to the other on the command  line.

Type

server2:

nc -lp 1234

on server2. server2 will  then wait until server1 connects on port 1234.

On server1, run

server1:

nc server2.example.com 1234

Now you can type in messages on either system and press ENTER, and they will appear on the other system. To close  the chat, press CTRL+C on either system.

 

Overview of RAMFS and TMPFS on Linux

[不指定 2009/07/17 15:18 | by ipaddr ]

Using ramfs or tmpfs you can allocate part of the physical memory to be used as a partition. You can mount this partition and start writing and reading files like a hard disk partition. Since you’ll be reading and writing to the RAM, it will be faster.

When a vital process becomes drastically slow because of disk writes, you can choose either ramfs or tmpfs file systems for writing files to the RAM.


Both tmpfs and ramfs mount will give you the power of fast reading and writing files from and to the primary memory. When you test this on a small file, you may not see a huge difference. You’ll notice the difference only when you write large amount of data to a file with some other processing overhead such as network.

1. How to mount Tmpfs

# mkdir -p /mnt/tmp  # mount -t tmpfs -o size=20m tmpfs /mnt/tmp

The last line in the following df -k shows the above mounted /mnt/tmp tmpfs file system.

# df -k Filesystem      1K-blocks  Used     Available Use%  Mounted on /dev/sda2       32705400   5002488  26041576  17%   / /dev/sda1       194442     18567    165836    11%   /boot tmpfs           517320     0        517320    0%    /dev/shm tmpfs           20480      0        20480     0%    /mnt/tmp

2. How to mount Ramfs

# mkdir -p /mnt/ram  # mount -t ramfs -o size=20m ramfs /mnt/ram

The last line in the following mount command shows the above mounted /mnt/ram ramfs file system.

# mount /dev/sda2 on / type ext3 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/sda1 on /boot type ext3 (rw) tmpfs on /dev/shm type tmpfs (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) fusectl on /sys/fs/fuse/connections type fusectl (rw) tmpfs on /mnt/tmp type tmpfs (rw,size=20m) ramfs on /mnt/ram type ramfs (rw,size=20m)

You can mount ramfs and tmpfs during boot time by adding an entry to the /etc/fstab.

3. Ramfs vs Tmpfs

Primarily both ramfs and tmpfs does the same thing with few minor differences.

  • Ramfs will grow dynamically.  So, you need control the process that writes the data to make sure ramfs doesn’t go above the available RAM size in the system. Let us say you have 2GB of RAM on your system and created a 1 GB ramfs and mounted as /tmp/ram. When the total size of the /tmp/ram crosses 1GB, you can still write data to it.  System will not stop you from writing data more than 1GB. However, when it goes above total RAM size of 2GB, the system may hang, as there is no place in the RAM to keep the data.
  • Tmpfs will not grow dynamically. It would not allow you to write more than the size you’ve specified while mounting the tmpfs. So, you don’t need to worry about controlling the process that writes the data to make sure tmpfs doesn’t go above the specified limit. It may give errors similar to “No space left on device”.
  • Tmpfs uses swap.
  • Ramfs does not use swap.

4. Disadvantages of Ramfs and Tmpfs

Since both ramfs and tmpfs is writing to the system RAM, it would get deleted once the system gets rebooted, or crashed. So, you should write a process to pick up the data from ramfs/tmpfs to disk in periodic intervals. You can also write a process to write down the data from ramfs/tmpfs to disk while the system is shutting down. But, this will not help you in the time of system crash.

Table: Comparison of ramfs and tmpfs
ExperimentationTmpfsRamfs
Fill maximum space and continue writingWill display errorWill continue writing
Fixed SizeYesNo
Uses SwapYesNo
Volatile StorageYesYes


If you want your process to write faster, opting for tmpfs is a better choice with precautions about the system crash.

在Linux下面部署应用的时候,有时候会遇上Socket/File: Can’t open so many files的问题,比如还有Squid做代理,当文件打开数到900多时速能就非常快的下降,有可能打不开网页.

其实Linux是有文件句柄限制的,而且Linux默认不是很高,一般都是1024,生产服务器用其实很容易就达到这个数量.

查看方法

我们可以用ulimit -a来查看所有限制值

[root@centos5 ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
max nice                        (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 4096
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
max rt priority                 (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited||<

其中 "open files (-n) 1024 "是Linux操作系统对一个进程打开的文件句柄数量的限制(也包含打开的SOCKET数量,可影响MySQL的并发连接数目).这个值可用ulimit命令来修改,但ulimit命令修改的数值只对当前登录用户的目前使用环境有效,系统重启或者用户退出后就会失效.

系统总限制是在这里,/proc/sys/fs/file-max.可以通过cat查看目前的值,修改/etc/sysctl.conf 中也可以控制.

另外还有一个,/proc/sys/fs/file-nr,可以看到整个系统目前使用的文件句柄数量

查找文件句柄问题的时候,还有一个很实用的程序lsof.可以很方便看到某个进程开了那些句柄.也可以看到某个文件/目录被什么进程占用了.

修改方法
若要令修改ulimits的数值永久生效,则必须修改配置文档,可以给ulimit修改命令放入/etc/profile里面,这个方法实在是不方便,还有一个方法是修改/etc/sysctl.conf .我修改了,测试过,但对用户的ulimits -a 是不会改变的。只是/proc/sys/fs/file-max的值变了.(我给命令放到rc.local中失败)

我认为正确的做法,应该是修改/etc/security/limits.conf
里面有很详细的注释,比如:

* soft nofile 32768
* hard nofile 65536

也可以直接运行下面这个shell。直接copy到你的终端中运行就好了.
echo -ne "
* soft nofile 65536
* hard nofile 65536
" >>/etc/security/limits.conf

就可以将文件句柄限制统一改成软32768,硬65536.配置文件最前面的是指domain,设置为星号代表全局,另外你也可以针对不同的用户做出不同的限制

注意.这个当中的硬限制是实际的限制,而软限制,是warnning限制,只会做出warning.其实ulimit命令本身就有分软硬设置,加-H就是硬,加-S就是软
默认显示的是软限制,如果运行ulimit命令修改的时候没有加上的话,就是两个参数一起改变.

生效

修改完重新登录就可以见到.(我的系统是Centos5.1.修改了,重新登录后就立刻生效.可以用ulimit -a 查看确认.)

一. 环境
1.操作系统: Suse Linux 10
2.jdk: 1.6.0_13 (使用RPM包安装)
3.jdk安装目录: /usr/java/default => /usr/java/jdk1.6.0_13
4.tomcat: tomcat6.0.20 (官方下载tgz包,直接解压到/usr/local/tomcat)
5.tomcat安装目录: /usr/local/tomcat
(一直漂[鱼漂]原创,转载请注册)

二.创建用户
#useradd -u 1003 -g users webadmin

三.修改目录所有者
#chown -R webadmin.users /usr/local/tomcat

四.安装jsvc
#cd /usr/local/tomcat/bin
#tar xvfz jsvc.tar.gz
#mv jsvc-src jsvc
#cd jsvc
#sh ./support/buildconf.sh
#chmod 755 configure
#./configure --with-java=/usr/java/default
#make
注意查看当前目录,是否生成了jsvc可执行文件.

五.修改启动文件
#vi ./native/Tomcat5.sh
改成如下内容:
(主要修改了前面的配置部分,以及start,stop中的jsvc的路径)

#!/bin/sh
##############################################################################
#
#   Copyright 2004 The Apache Software Foundation.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#    <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
#    <Connector className="org.apache.catalina.connector.http.HttpConnector"
#               port="80" minProcessors="5" maxProcessors="75"
#               enableLookups="true" redirectPort="8443"
#               acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/java/default
CATALINA_HOME=/usr/local/tomcat
DAEMON_HOME=/usr/local/tomcat/bin/jsvc
TOMCAT_USER=webadmin
JAVA_OPTS="-Xms512m -Xmx1024m -XX:PermSize=64M"

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/tomcat

CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

case "$1" in
  start)
    #
    # Start Tomcat
    #
    $DAEMON_HOME/jsvc \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile $CATALINA_HOME/logs/catalina.out \
    -errfile '&1' \
    $JAVA_OPTS \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    exit $?
    ;;

  stop)
    #
    # Stop Tomcat
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;

  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac
                                              


六.拷贝启动文件
#cp ./native/Tomcat5.sh /etc/init.d/tomcat6
#chmod a+x /etc/init.d/tomcat6

七.添加服务
#chkconfig --add tomcat6
#chkconfig --level 345 tomcat6 on

八.完成,启动服务
#/etc/init.d/tomcat6 start | stop
同时重启系统,tomcat也就会自动启动了.

九.中文文件名问题
Linux下的Tomcat在下载中文文件名时,有时会出现无法下载,404错误的页面,可以通过下面的方法修复此问题:
1. 修改server.xml,在connector中加入URIEncoding="UTF-8",告诉Tomcat使用UTF-8来解析URL(IE默认是用utf-8编码URL)
2. 修改tomcat启动脚本,加上export LC_ALL="zh_CN.gbk",使得Tomcat在读定系统系统时,使用gbk编码处理文件名。(也可以设置为其它编码,如UTF8)

Slackware Linux启动过程详解

[不指定 2009/07/13 11:05 | by ipaddr ]
Joe Brockmeier 研究了 Slackware Linux init 进程。他讨论了系统如何初始化服务、各种运行级别是什么,以及如何从缺省安装中添加或除去服务来定制系统。

Linux 用户正日益成熟,这意味着他们想要将系统配置成执行他们希望完成的任务。但目前 Linux 发行版通常都附带了自动配置的设备和启动服务,如 Sendmail 或 Apache。这些发行版没有考虑到的是毫不更改其缺省设置来运行服务,如 Apache -- 用户毫不知情 -- 会让黑客和利用脚本捣乱的人趁虚而入。而且这会用完本可以更好利用的系统资源 -- 比如可以用于 Quake 或您喜欢的编译器的更多处理器时间。由于缺少控制是件“糟糕的事”,因此让我们看一下 Linux 系统引导时在 init 进程期间,在所涉及的各个运行级别上都发生了什么,以及如何在系统运行时定制系统或在运行级别之间切换。

我们的示例使用 x86 平台上的 Slackware Linux 发行版(请参阅本文后面的 参考资料 )。大多数信息可用于其它 Linux 发行版,但在细节处会略有不同。尤其是,与其说 Slackware 的 init 结构类似于 System V 结构,还不如说它更类似于 BSD UNIX 结构,尽管 Slackware 的最新发行版中的程序做了一些让步,它们要将服务添加到启动,但期望这些服务是 System V 目录结构。(请参阅侧栏, “BSD 和系统 V init 脚本之间的差异”。)

所有进程的父代

当 Linux 机器引导时,究竟会发生什么?在计算机的 BIOS 完成其任务后,系统会读取硬盘(或软盘,或 CD-ROM,或 Zip 驱动器……Linux 是非常灵活的)的第一位,并会遇到引导装入程序。虽然 GRUB 和其它装入程序也逐渐变得流行,但通常这就是 Linux 装入程序 (LInux LOader),一般称作 LILO。

然后 LILO 将 Linux 内核装入内存,并开始展示它的魔力。Linux 内核初始化了诸如 SCSI 卡之类的设备,以及其它内核中内置的硬件设备。然后内核运行 init,它是除内核之外在系统运行的第一个进程。如果执行 ps ax | grep 1 ,就会看到 init 的进程 ID (PID) 是 1。

装入 init 之后,它会读取 inittab 以查看下一步做什么。 inittab 告诉 init 要进入什么运行级别,以及在哪里可以找到该运行级别的配置文件。

运行级别

运行级别是由系统上的所有服务在某个给定时间定义的(基本上是操作方式)。Linux 可以有几种操作方式:单用户方式、单用户联网方式、多用户方式、始于 X 窗口的多用户方式,等等。这部分将要说明运行级别的概念、Slackware 上有哪些运行级别,已经它们被叫作什么。

运行级别由数字或字母标明。可惜,不是所有的 Linux 发行版在各个运行级别的称呼问题上都能达成共识。在某些发行版中,运行级别 3 是使用 X 窗口登录的多用户方式。而其它的,如 Slackware,将运行级别 3 指定成使用控制台登录的多用户方式。

据我所知,所有 Linux 发行版都认同运行级别 0 是“停机”、运行级别 1 或 "S" 是单用户方式(稍后将详细说明),运行级别 6 是重新引导系统。Slackware 的运行级别如下:

  • 运行级别 0 = 系统停机
  • 运行级别 1 = 单用户方式,主要用于维护
  • 运行级别 2 = 从不使用
  • 运行级别 3 = 使用控制台登录的多用户方式
  • 运行级别 4 = 使用 X11 会话管理器的多用户方式 (XDM, GDM, KDM)
  • 运行级别 5 = 从不使用
  • 运行级别 6 = 重新引导
  • 运行级别 S 或 s = 单用户方式

这里没有记录运行级别 7 到 9,在理论上,它们适用于在需要时定制运行级别。但我还没有亲自尝试过创建一个。

运行级别配置

如果您使用的不是 Slackware Linux,那么配置文件的结构与我谈到的结构会大不相同。除了 inittab 文件,所有 Slackware 的启动配置文件都在 /etc/rc.d/ 目录中。

缺省情况下,目录中有 5 个运行级别 rc.* 脚本,如果将 symlink 从 rc.0 加到 rc.6 ,那么可有 6 个。

运行级别 init 脚本是:

  • rc.0 = rc.0 文件是到 rc.6 的 symlink
  • rc.M = 多用户运行级别 2、3 和 5 的 init 脚本
  • rc.K = “管理”运行级别,单用户方式
  • rc.S = 系统初始化脚本
  • rc.4 = 运行级别 4(自动引导入所选择的 X 会话管理器)的 init 脚本
  • rc.6 = 重新引导或停止系统时由 init 执行的脚本

目录中的其余 rc.* 文件用于启动诸如联网、内核模块、PCMCIA、Samba、Apache、Netatalk 和 GPM 的系统服务。如果想要使某个服务(如 Apache)完全不能在任何运行级别上使用,请使用 chmod 将文件的许可权从可执行更改成不可执行。除去该文件也可以到达相同效果,但我不推荐这种做法。也许在以后某个日子您会发现要重新启用服务,但却不知道怎样做。

rc.inet1 脚本负责启动基本联网服务,如设置主机名(IP 和 DHCP)。 rc.inet2 脚本负责启动所有其它 INET 服务,如 NFS、包转发、ssh 服务器和其它联网守护程序。

所有 Slackware /etc/rc.d/rc.* 文件都是 Bash shell 脚本,都可以进行手工编辑。可是对于联网,您可能应该先尝试 netconfig 实用程序。虽然需要手工编辑 /etc/resolv.conf 来添加多个名称服务器,但是它也许能处理您想要执行的所有操作,而且它非常易于使用。

如果您是 Linux 初学者并且要修改系统,那么也许应该确保您有引导软盘,并且应该复制您所有想要编辑的 rc.* 文件。如果拿不定主意,我通常会将文件保存为 rc.*.old ,使它们变成不可执行文件。,使它们变成不可执行文件。

使用运行的系统

好,现在系统已经运行,然而您需要在单用户方式中执行一些操作 -- 该怎么做呢?本文的下一部分将说明如何在系统运行时更改运行级别,而不是通过重新引导来更改运行级别,而且还说明了为什么执行此操作以及何时执行。

telinit 命令
在运行的系统上更改运行级别

telinit 命令可以用于更改运行级别。当以 root 身份执行 telinit S (或者想要更改的任意运行级别)时,它会更改运行级别,关闭前一个运行级别,然后启动下一个。

某种程度上您正在重新引导系统的一部分。然而,关闭与重新启动服务的能力正是 Linux 最可爱的品质之一。想要更改机器的 IP 地址吗?没问题,只要进行一些更改,然后重新启动联网服务就行了。只要一切配置正确,备份和运行是如此迅速,很难分辩是否做过更改。在其它即使更改了桌面上的墙纸都必须重新引导的操作系统上,尝试一下执行此操作 :)

确实需要重新引导或彻底关闭 Linux 机器的唯一情况是如果正在添加或更改硬件,假设您正在使用不能热插拔的设备,或者已经中断且需要使机器脱机以修复损坏。与其它操作系统不同,对于那些不经过重新引导就无法解决问题的产品系统,我从来没有看到过重新引导解决了这些系统上的问题。我曾设法利用诸如 hdparm 的命令来挂起非生产性机器,我希望这种情况发生。

假设您想要执行一些系统维护,而这些系统维护要求系统处于单用户方式。例如,使用 hdparm 调整硬盘。第一步是 su (切换)到 root 用户。

然后执行 telinit 命令使系统进入单用户方式:

telinit S -t 60 

自变量 "-t" 是可选的;它告诉 telinit 在真正切换到单用户方式之前等待 60 秒。然而,只要执行了该命令,登录到机器的任何人都会看到在控制台上出现一个警告,指出系统将切换运行级别或将在 60 秒内停机。

到了 60 秒时,init 会关闭单用户方式中不使用的进程,并使系统进入单用户方式。然后,将提示您输入 root 用户密码以执行系统维护。

系统进入单用户方式所使用的进程略有不同。缺省情况下,单用户方式要求 init 在控制台上调用 sulogin 命令,并要求在单用户方式中使用 root 登录。

系统进入单用户方式后,应该会看到如下的消息:

           Give root password for system maintenance             (or type Control-D for normal startup): 

执行了维护之后,可以执行以下命令来使系统回到以前的运行级别:

telinit 3  

此命令告诉系统重新进入多用户运行级别。在此命令中可以用 "2" 或 "4" 来代替 "3"。在 Slackware 系统上,运行级别 4 将使您进入使用 X 窗口显示管理器之一的多用户方式,因此您将直接登录到 X 窗口。

如果在拥有串行电缆的串行上挂了 UPS,那么就可以让 UPS 在断电的情况下向系统发送一个信号。如果您的产品级系统有一个很大的文件系统,那么这是非常有用的。我曾看到过当没有彻底卸载 100GB RAID ext2 文件系统时(完成 fsck 需要大约 4 小时)发生了什么情况。另一方面,正确配置的 UPS 可以提醒系统断电情况,并向 telinit/init 发送 SIGPWR 信号,这会使 init 根据其配置情况将系统切换到单用户方式或者完全关闭系统。

关机

好,由于一直使用计算机,您已经觉得疲倦了,并打算到 Big Blue Room 去放松一下。幸好,您已经知道了在结束时直接按电源开关是一大禁忌,但也许还不知道关闭系统的所有方法。

在 Linux 中,可以使用“三指礼”重新引导系统:Ctrl+Alt+Del 键控顺序会向系统发送消息,通知它执行关机进程并重新启动。换句话说,除非告诉它不要那样做。

如果要禁用该键控顺序,需要注释掉 inittab 中的一行代码

关机时会发生什么情况?调用 shutdown 命令可以逐步关闭系统。然而,shutdown 自身并不完成所有工作,它通知 init:应该进入运行级别 0、1 或 6。

shutdown 命令还通知所有已登录到机器上的用户:机器将关闭。在此之后将锁住 login 命令,因此没有别的人可以再启动会话。

要使用 shutdown 命令来关闭 Linux 系统,使用以下命令:


关机

shutdown -h now 

如果要给用户注销和保存文件的时间,请使用以下命令:

shutdown -h -t 60  

shutdown 命令的 "-h" 开关告诉系统在停机后彻底关机。如果在内核中启用了 APM,那么它会替您关闭电源,否则此时可以放心地按下开关。

"-t" 开关是到系统开始关机之前所需要的时间,以秒为单位。如果要放弃关机,那么使用此开关可以实现。要停止暂挂关机,输入:

shutdown -c 

此命令将取消以前的所有 shutdown 命令。如果出于某些原因,您不想关闭系统,但却要向用户发送“系统即将关闭”的警告,那么应在 shutdown 中使用 "-k" 自变量。

知道如何使用 telinit 和 init 可以在修改 Linux 系统派上用处。本文中,我们讨论了更改运行级别和有关 Slackware Linux 发行版的 init 脚本的基础知识。在各个发行版之间,目录结构和文件位置都各不相同,但在阅读了本文之后,您应该能够掌握系统的 init 脚本,即使您使用的不是 Slackware Linux。

ETL是什么?

[不指定 2009/07/09 11:10 | by ipaddr ]

    对于数据仓库以及ETL的知识,我基本上是个门外汉。一切都得从头开始,记个笔记,方便自已了解学习进度。
   
    首先,我们来了解最基本的定义:
    嗯,也有人将ETL简单称为数据抽取。至少在未学习之前,领导告诉我的是,你需要做一个数据抽取的工具。
    其实呢,抽取是ETL中的关键环节,顾名思义,也就将数据从不同的数据源中抓取(复制)出来。
    太简单了!
    上面的解释无首无尾,有点象能让你吃饱的第七个烧饼,
    仔细一想,抽取是不可能单独存在,我们需要将与之关联的一些其它环节拿出来。

    于是,得到ETL的定义:
    将数据抽取(Extract)、转换(Transform)、清洗(Cleansing)、装载(Load)的过程。
    好的,既然到了这一个层次,我们完全会进一步展开联想,引出上面这个抽象事件的前因后果,

    抽取的源在哪里?
    装载的目的又是什么呢?

    抽取源:大多数情况下,可以认为是关系数据库,专业一点,就是事务处理系统(OLTP)。当然,广义一点,可能会是其它数据库或者是文件系统。
    目的地:OK,我们希望是数据仓库。数据仓库是啥?在学习之前,它对我来说是个抽象的怪物,看过一些简单的资料之后,才了解这个怪物一点都不怪。堆积用来分析的数据的仓库。是了,是用来分析的,于是,它区别于OLTP中的数据存储。

    然后,我们来看看为什么要ETL?
    在我看来,有两个原因。
    一:性能  将需要分析的数据从OLTP中抽离出来,使分析和事务处理不冲突。咦?这不是数据仓库的效果吗?是了,
数据仓库,大多数情况下,也就是通过ETL工具来生成地。
    二:控制  用户可以完全控制从OLTP中抽离出来的数据,拥有了数据,也就拥有了一切。
    嗯,OLAP分析,数据挖掘等等等……。

    最后,总结一下,
    从资料上看,ETL是一门大学问,对于大学问,实在有些怕怕,所以,我觉得应该停下来想一想,下一步我该干点啥?
    嗯,时不我待,我没有办法一切从头开始,
    是了,从应用出发,看看现在工作中,最急需的是什么?

    鸭子要变成一盘菜,并不是举手将之置于油锅之劳。
    OK,要将生米变为熟饭,鸭子放上大盘,一堆废话之后,我得先看看厨房里都有了一些啥?

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/tiger119/archive/2007/01/14/1482555.aspx

Oracle大数据导出

[不指定 2009/07/07 17:22 | by ipaddr ]

1. 创建SQL脚本

set heads off
set heading off
set feedback off
set pagesize 0
set linesize 32
set echo off
set termout off
spool /data/tmp/auction_32.dat
select xxxx from tblName;
spool off

2. 使用sqlplus执行
sqlplus xxxx/xxx @tmp.sql

常见Oracle HINT的用法

[不指定 2009/07/07 17:12 | by ipaddr ]

1. /*+ALL_ROWS*/
表明对语句块选择基于开销的优化方法,并获得最佳吞吐量,使资源消耗最小化.
例如:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO='SCOTT';
2. /*+FIRST_ROWS*/
表明对语句块选择基于开销的优化方法,并获得最佳响应时间,使资源消耗最小化.
例如:
SELECT /*+FIRST_ROWS*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO='SCOTT';
3. /*+CHOOSE*/
表明如果数据字典中有访问表的统计信息,将基于开销的优化方法,并获得最佳的吞吐量;
表明如果数据字典中没有访问表的统计信息,将基于规则开销的优化方法;
例如:
SELECT /*+CHOOSE*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO='SCOTT';

4. /*+RULE*/
表明对语句块选择基于规则的优化方法.
例如:
SELECT /*+ RULE */ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO='SCOTT';

5. /*+FULL(TABLE)*/
表明对表选择全局扫描的方法.
例如:
SELECT /*+FULL(A)*/ EMP_NO,EMP_NAM FROM BSEMPMS A WHERE EMP_NO='SCOTT';

6. /*+ROWID(TABLE)*/
提示明确表明对指定表根据ROWID进行访问.
例如:
SELECT /*+ROWID(BSEMPMS)*/ * FROM BSEMPMS WHERE ROWID>='AAAAAAAAAAAAAA'
AND EMP_NO='SCOTT';

7. /*+CLUSTER(TABLE)*/
提示明确表明对指定表选择簇扫描的访问方法,它只对簇对象有效.
例如:
SELECT /*+CLUSTER */ BSEMPMS.EMP_NO,DPT_NO FROM BSEMPMS,BSDPTMS
WHERE DPT_NO='TEC304' AND BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;

8. /*+INDEX(TABLE INDEX_NAME)*/
表明对表选择索引的扫描方法.
例如:
SELECT /*+INDEX(BSEMPMS SEX_INDEX) USE SEX_INDEX BECAUSE THERE ARE FEWMALE BSEMPMS */ FROM BSEMPMS WHERE SEX='M';

9. /*+INDEX_ASC(TABLE INDEX_NAME)*/
表明对表选择索引升序的扫描方法.
例如:
SELECT /*+INDEX_ASC(BSEMPMS PK_BSEMPMS) */ FROM BSEMPMS WHERE DPT_NO='SCOTT';

10. /*+INDEX_COMBINE*/
为指定表选择位图访问路经,如果INDEX_COMBINE中没有提供作为参数的索引,将选择出位图索引的布尔组合方式.
例如:
SELECT /*+INDEX_COMBINE(BSEMPMS SAL_BMI HIREDATE_BMI)*/ * FROM BSEMPMS
WHERE SAL<5000000 AND HIREDATE

11. /*+INDEX_JOIN(TABLE INDEX_NAME)*/
提示明确命令优化器使用索引作为访问路径.
例如:
SELECT /*+INDEX_JOIN(BSEMPMS SAL_HMI HIREDATE_BMI)*/ SAL,HIREDATE
FROM BSEMPMS WHERE SAL<60000;

12. /*+INDEX_DESC(TABLE INDEX_NAME)*/
表明对表选择索引降序的扫描方法.
例如:
SELECT /*+INDEX_DESC(BSEMPMS PK_BSEMPMS) */ FROM BSEMPMS WHERE DPT_NO='SCOTT';

13. /*+INDEX_FFS(TABLE INDEX_NAME)*/
对指定的表执行快速全索引扫描,而不是全表扫描的办法.
例如:
SELECT /*+INDEX_FFS(BSEMPMS IN_EMPNAM)*/ * FROM BSEMPMS WHERE DPT_NO='TEC305';

14. /*+ADD_EQUAL TABLE INDEX_NAM1,INDEX_NAM2,...*/
提示明确进行执行规划的选择,将几个单列索引的扫描合起来.
例如:
SELECT /*+INDEX_FFS(BSEMPMS IN_DPTNO,IN_EMPNO,IN_SEX)*/ * FROM BSEMPMS WHERE EMP_NO='SCOTT' AND DPT_NO='TDC306';

15. /*+USE_CONCAT*/
对查询中的WHERE后面的OR条件进行转换为UNION ALL的组合查询.
例如:
SELECT /*+USE_CONCAT*/ * FROM BSEMPMS WHERE DPT_NO='TDC506' AND SEX='M';

16. /*+NO_EXPAND*/
对于WHERE后面的OR 或者IN-LIST的查询语句,NO_EXPAND将阻止其基于优化器对其进行扩展.
例如:
SELECT /*+NO_EXPAND*/ * FROM BSEMPMS WHERE DPT_NO='TDC506' AND SEX='M';

17. /*+NOWRITE*/
禁止对查询块的查询重写操作.

18. /*+REWRITE*/
可以将视图作为参数.

19. /*+MERGE(TABLE)*/
能够对视图的各个查询进行相应的合并.
例如:
SELECT /*+MERGE(V) */ A.EMP_NO,A.EMP_NAM,B.DPT_NO FROM BSEMPMS A (SELET DPT_NO
,AVG(SAL) AS AVG_SAL FROM BSEMPMS B GROUP BY DPT_NO) V WHERE A.DPT_NO=V.DPT_NO
AND A.SAL>V.AVG_SAL;

20. /*+NO_MERGE(TABLE)*/
对于有可合并的视图不再合并.
例如:
SELECT /*+NO_MERGE(V) */ A.EMP_NO,A.EMP_NAM,B.DPT_NO FROM BSEMPMS A (SELECT DPT_NO,AVG(SAL) AS AVG_SAL FROM BSEMPMS B GROUP BY DPT_NO) V WHERE A.DPT_NO=V.DPT_NO AND A.SAL>V.AVG_SAL;

21. /*+ORDERED*/
根据表出现在FROM中的顺序,ORDERED使ORACLE依此顺序对其连接.
例如:
SELECT /*+ORDERED*/ A.COL1,B.COL2,C.COL3 FROM TABLE1 A,TABLE2 B,TABLE3 C WHERE A.COL1=B.COL1 AND B.COL1=C.COL1;

22. /*+USE_NL(TABLE)*/
将指定表与嵌套的连接的行源进行连接,并把指定表作为内部表.
例如:
SELECT /*+ORDERED USE_NL(BSEMPMS)*/ BSDPTMS.DPT_NO,BSEMPMS.EMP_NO,BSEMPMS.EMP_NAM FROM BSEMPMS,BSDPTMS WHERE BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;

23. /*+USE_MERGE(TABLE)*/
将指定的表与其他行源通过合并排序连接方式连接起来.
例如:
SELECT /*+USE_MERGE(BSEMPMS,BSDPTMS)*/ * FROM BSEMPMS,BSDPTMS WHERE BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;

24. /*+USE_HASH(TABLE)*/
将指定的表与其他行源通过哈希连接方式连接起来.
例如:
SELECT /*+USE_HASH(BSEMPMS,BSDPTMS)*/ * FROM BSEMPMS,BSDPTMS WHERE BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;

25. /*+DRIVING_SITE(TABLE)*/
强制与ORACLE所选择的位置不同的表进行查询执行.
例如:
SELECT /*+DRIVING_SITE(DEPT)*/ * FROM BSEMPMS,DEPT@BSDPTMS WHERE BSEMPMS.DPT_NO=DEPT.DPT_NO;

26. /*+LEADING(TABLE)*/
将指定的表作为连接次序中的首表.

27. /*+CACHE(TABLE)*/
当进行全表扫描时,CACHE提示能够将表的检索块放置在缓冲区缓存中最近最少列表LRU的最近使用端
例如:
SELECT /*+FULL(BSEMPMS) CAHE(BSEMPMS) */ EMP_NAM FROM BSEMPMS;

28. /*+NOCACHE(TABLE)*/
当进行全表扫描时,CACHE提示能够将表的检索块放置在缓冲区缓存中最近最少列表LRU的最近使用端
例如:
SELECT /*+FULL(BSEMPMS) NOCAHE(BSEMPMS) */ EMP_NAM FROM BSEMPMS;

29. /*+APPEND*/
直接插入到表的最后,可以提高速度.
insert /*+append*/ into test1 select * from test4 ;

30. /*+NOAPPEND*/
通过在插入语句生存期内停止并行模式来启动常规插入.
insert /*+noappend*/ into test1 select * from test4 ;


分页: 15/57 第一页 上页 10 11 12 13 14 15 16 17 18 19 下页 最后页 [ 显示模式: 摘要 | 列表 ]