2007-09-27 Thu
On Linux/Unix we can use gcc to compile OCI source code. Use the following command to compile the text unload utility as 64 bit binary.
gcc -m64 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/rdbms/demo -L${ORACLE_HOME}/lib -lclntsh -o ociuldr.bin ociuldr.c
I usually compile it as 32 bit executable file by the following command.
gcc -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/rdbms/demo -L${ORACLE_HOME}/lib32 -lclntsh -o ociuldr.bin ociuldr.c
On windows, I will use Microsoft Visual C++ as compiler. Run the following command to compile it.
set ORACLE_HOME=c:\oracle\product\10.2.0
set LIB=%LIB%;%ORACLE_HOME%\oci\include
set INCLUDE=%INCLUDE%;%ORACLE_HOME%\oci\lib\msvc
cl /ML /Feociuldr.exe ociuldr.c oci.lib
For the Pro*C compilation, you just need to change the include file path and library path.
Related Posts
Leave New Comment(Current: 0)
Link: http://www.dbatools.net/experience/compile_oci_program.html
今天hoterran跟我说obj$中怎么会有那么多type#=10的对象存在。即select obj#,name,type# from obj$ where type#=10;
其type#为10表示的是什么类型呢?
对obj$基表字段的解释可以从sql.bsq文件中获得,关于type#的解释,我们可以从中得到:
type# number not null, /* object type (see KQD.H): */
/* 1 = INDEX, 2 = TABLE, 3 = CLUSTER, 4 = VIEW, 5 = SYNONYM, 6 = SEQUENCE, */
/* 7 = PROCEDURE, 8 = FUNCTION, 9 = PACKAGE, 10 = NON-EXISTENT, */
/* 11 = PACKAGE BODY, 12 = TRIGGER, 13 = TYPE, 14 = TYPE BODY, */
/* 19 = TABLE PARTITION, 20 = INDEX PARTITION, 21 = LOB, 22 = LIBRARY, */
/* 23 = DIRECTORY , 24 = QUEUE, */
/* 25 = IOT, 26 = REPLICATION OBJECT GROUP, 27 = REPLICATION PROPAGATOR, */
/* 28 = JAVA SOURCE, 29 = JAVA CLASS, 30 = JAVA RESOURCE, 31 = JAVA JAR, */
/* 32 = INDEXTYPE, 33 = OPERATOR , 34 = TABLE SUBPARTITION, */
/* 35 = INDEX SUBPARTITION */
/* 57 = SECURITY PROFILE */
即type#=10表示的是non-existant类型的对象。
随便找个db来看一下:
select">sys@alisoft_std3>select count(*) from obj$ where type#=10;
COUNT(*)
----------
111
有111个non-existant类型的对象,并且这些对象的创建时间(ctime)都很早,不可能是最近12个小时内产生的。
首先说说什么情况下会产生non-existant类型的对象。
有两大类情况会生成non-existant类型的对象:
1.删除,重命名之类的操作,也就是说原来的对象不存在了,oracle会将这些对象的type#改成10。
这种情况相信大家都好理解。
2.第二种情况相对来说就不太好理解了,用oracle的话来说"object entries created for negative dependency reasons"
即为了negative依赖关系而创建的。这种主要表现为系统包、视图和dual表。后面会找个例子来说明。
我们都知道smon进程有一大功能就是理清obj$中不存在的对象,其实就是清理type#为10的对象。
即然smon进程会清理,那为什么还会有这么多non-existant的对象呢?
其实smon只清理那些没有任何依赖关系的non-existant的对象,如果那些没有被任何其他对象使用的non-existant对象没有
被smon进程清理掉的话,都可以认为是oracle的bug.
其实前面所说的第一种情况正常情况下都会被smon清理掉的(当然也可以通过event来禁止smon这种功能),
而那些不会被smon进程清理掉的non-existant对象正常情况下都是属于前面所说的第二种情况。
select">sys@alisoft_std3>select obj#,name from obj$ where type#=10 and obj# not in (select p_obj# from dependency$);
no rows selected
可以发现所有type#=10的对象都是被别人使用的。
还有有个存过,里面有这段代码:
SELECT substr(child_id, 9, length(child_id) - 8), b.aw
FROM rry_im_child_user a,
(SELECT '201' aw
FROM dual
UNION
SELECT '202' aw
FROM dual
UNION
SELECT '203' aw
FROM dual
UNION
SELECT '301' aw
FROM dual
UNION
SELECT '302' aw
FROM dual
UNION
SELECT '305' aw FROM dual) b
WHERE a.login_id = x.login_id
AND a.gmt_expire >= v_gmt_online;
END IF;
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('no data found by : ' || x.login_id);
END;
当创建这个存过(object_id为21300)的时候,由于第二种原因,会产生两个non-existant的对象。
select">sys@alisoft_std3>select obj#,name,type# from obj$ where obj# in (select p_obj# from dependency$ where d_obj#=21300) and type#=10;
OBJ# NAME TYPE#
---------- ------------------------------ ----------
6614 DUAL 10
6616 DBMS_OUTPUT 10
不过有一点还没弄明白的是,oracle这么做会带来什么好处。
In this week’s Creative Commons Artist Spotlight, we interview French artists Monsieur Madame about their CC-licensed album Et Maintenant, available at Jamendo.com.
Why did you decide to release your music under a Creative Commons license?
Because we just want to be heard. It’s hard to sell music because there are a lot of bands. We just like to play live music and share it with people. The Creative Commons is a good way to share directly.
How much of your work is CC-licensed?
All tracks of the CD (Et Maintenant) are CC-licensed. The new ones, not yet.
Who are your musical influences?
Maybe are we influenced by French bands, such as Rita Mitsouko or Thomas Fersen, for example.
What tools do you use to produce your music?
A guitar and a pen (to write songs!)
Which of your CC-licensed songs is your favorite?
I think that it’s “Du sable entre les doigts de pied” because it’s sweet!
Are you touring, and if so, how can readers find you?
No, for the moment. We are trying to play in live once a month in Paris, in the Bibax Bar (10th arrondissement) for example.
Anything you’d like our readers to know about you?
We’re going to work on a new CD in october. We’ve already got 12 new songs so… Let’s go!
written by Steve ‘Ashcrow’ Milner and Anderson Silva
The same way tabbed browsing revolutionized the web experience, GNU Screen can do the same for your experience in the command line. GNU Screen allows you to manage several interactive shell instances within the same “window.” By using different keyboard shortcuts, you are able to shuffle through the shell instances, access any of them directly, create new ones, kill old ones, attach and detach existing ones.
Instead of opening up several terminal instances on your desktop or using those ugly GNOME/KDE-based tabs, Screen can do it better and simpler.
Not only that, with GNU Screen, you can share sessions with others and detach/attach terminal sessions. It is a great tool for people who have to share working environments between work and home.
By adding a status bar to your screen environment, you are able to name your shell instances on the fly or via a configuration file called .screenrc that can be created on the user’s home directory.
Installing
Installing Screen on a Fedora or Red Hat® Enterprise Linux® 5 system is quite easy with yum, assuming you have sudo access.
- Login as root:
su # enter root password - Use yum to install it:
yum install screen
Enter your password. After a few minutes (depending on your network connection), Screen will be installed. But before you start playing around with it, let’s look at how to do some basic configuration.
Customizing the configuration file
Screen keeps its configuration file in the same vein that many applications do: in a dot file in your user’s home directory. This file is aptly named .screenrc. In my experience, most people use ~/.screenrc to do two things:
- Make a hardstatus line. This is basically a line at the bottom of the screen that lists your current terminal and all opened ones. It can also display the system clock and the hostname.
- Default screens on startup. It’s quite nice to have your IRC connection, mail client, and default SSH connections auto-start for you!
The lines below are numbered for reference. Your config file should not have numbered lines.
1 hardstatus alwayslastline
2 hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
3
4 # Default screens
5 screen -t shell1 0
6 screen -t shell2 1
7 screen -t server 2 ssh me@myserver
On lines 1 and 2, you are setting the hardstatus. Line 1 makes the hardstatus always show up as the last line. Line 2 is about what will be shown in the hardstatus line. In this case you will see something like so at the bottom:
As you change screens, you will see the parentheses move around the active screen.
Line 4 is a comment, as it starts with #. Lines 5-7 are all screen statements in the following format:
screen -t NameOfScreen ScreenNumber ShellCommand
Shortcuts
The following are some of the most used shortcuts that lets you navigate through your screen environment. Note that unless modified by your .screenrc, by default every screen shortcut is preceded by Ctrl+a. Note that these shortcuts are case-sensitive.
- 0 through 9 – Switches between windows
- Ctrl+n – Switches to the next available window
- Backspace – Switches to the previous available
- Ctrl+a – Switches back to the last window you were on
- A – Changes window session name
- K – Kills a window session
- c – Creates a new window
- [ - Then use arrows to scroll up and down terminal
Find out about more shortcuts in Screen’s man pages. In your terminal, run: man screen.
Sharing a session with others
Another great application of Screen is to allow other people to login to your station and to watch the work you are doing. It is a great way to teach someone how to do things on the shell.
Setup to allow screen to be shared
- As root:
chmod u+s /usr/bin/screen(Screen has to be SUID if you want to share a term between two users.)
Note: SUID allows an executable to be run by the owner of that file, instead of with the user’s own permission. There are some security concerns when doing this, so use this tip at your own discretion. chmod 755 /var/run/screen- Log out of root, and run Screen as the user who is going to share the session:
screen - Press Ctrl+a, then type :multiuser on and press Enter.
- Press Ctrl+a, then type :acladd steve (”steve” is the username of the person who will connect to your screen session).
Connecting to the shared screen:
- SSH into the workstation that you are going to watch the screen session on.
- On your terminal type: screen -x anderson/ (”anderson” is the username of the person who is sharing the screen session. You need the / at the end.).
And now both users (from the host and guest) will be sharing a screen session and can run commands on the terminal.
Working from multiple locations
Let’s say you have a screen session open at work with X number of windows on it. Within those screens you may be running an IRC client, an SSH connection to the web server, and your favorite text-based email client. It’s 5 p.m. and you have to go home, but you still have work left to do.
Without Screen you would probably go home, VPN into your company’s network, and fire up all the shells you need to keep working from home. With Screen, life gets a little easier.
You can simply SSH into your workstation at work and list your available screen sessions with the command:
screen -ls
And connect to the sessions you were running at work with the command:
screen -x screen_session_name
This way screen will let you pick things up exactly from where you left off.
Applications to make Screen your window manager
Now that you have seen what Screen can do for you, you probably are wondering how to make it your main interaction point, like a terminal window manager.
Let’s start with IRC, a very common and popular chat system. Instead of using a graphical client like Pidgin, install Irssi. Irssi sports a slick console interface, tons of add-ons and scripts, and can be enhanced with Perl. It’s even theme-able!
Another important part of any user’s setup is email. Today most people use graphical clients such as Thunderbird, Evolution, or Sylpheed. My favorite client happens to run in a terminal: Mutt. While Mutt isn’t the easiest client in the world to set up, it sure is a joy to use. You can even use your favorite console text editor for doing emails.
Speaking of favorite text editors, there is a good chance that you work on some code projects or configurations. Instead of using gedit/kedit or powering up a heavy IDE such as Eclipse, you can pick up on Vim. Vim is a powerful text editor which, as is stated on the Vim website, could be considered an entire IDE in itself and sports syntax coloring in over 200 programming languages. If Vim doesn’t fit your style, there is always emacs, nano, or JOE.
Now all you need you need to do is edit your ~/.screenrc to meet your needs.
My ~/.screenrc looks like the following:
1 hardstatus alwayslastline
2 hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=
kw}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}
%Y-%m-%d %{W}%c %{g}]'
3
4 # Default screens
5 screen -t shell1 0
6 screen -t shell2 1
7 screen -t server 2 sh me@myserver
8 screen -t IRC 7 irssi
9 screen -t Mail 8 mutt
Once you get used to the shortcuts in GNU screen, not only will your desktop become more organized (due to the lower number of open windows), but your efficiency as a developer or system administrator will increase not only at work but at your home office as well.
I am moving some data by ociuldr with the following field and record option.
ociuldr ... field=0x07 record=0x06 ...
I think it will work well, but actually not, there are rows rejected when loading with sqlldr. The database use UTF8 character set and contains some Asia language data. The I change the separator option with following.
Unix: ociuldr ... field=\<#\> record=\<$\> ...
Windows: ociuldr ... field="<#>" record="<$>" ...
This time it works very well, no rows are rejected, and the source and target tables are matched.
SQL> SELECT COUNT(*) FROM CR_8875106_UTNS19;
COUNT(*)
----------
100000
SQL> SELECT * FROM CR_8875106_SRC
2 minus
3 select * from CR_8875106_DEST;
no rows selected
SQL> SELECT * FROM CR_8875106_DEST
2 minus
3 SELECT * FROM CR_8875106_SRC;
no rows selected
The only reason is the database character set, we should specify separators with the same character set as the database. Some invisible chars do not work well under UTF8 character set.
Related Posts
Leave New Comment(Current: 0)
Link: http://www.dbatools.net/experience/choose_right_separators.html
2007-09-26 Wed
2007-09-25 Tue
AnySQL.net
DBA notes
Oracle & Starcraft
eagle's home
给你点color see see
AnySQL.net English
Oracle Scratchpad
Oracle Life
OracleDBA Blog
Photos from dbanotes
Chanel [K]
xzh2000的博客
Oracle Security Blog
ERN空间
Eddie Awad's Blog
MySQL Performance Blog
The Tom Kyte Blog
del.icio.us/fenng/oracle
AIXpert
O'Reilly Databases
Red Hat Magazine
DBASupport
DB2 Magazine 中文版
developerWorks : AIX 专区的文章,教程
Pythian Group Blog
车东[Blog^2]
blue_prince
玉面飞龙的BLOG
此生 今世
人生就是如此
Orange Tiger 木匠 的 移民生活
生活帮-LifeBang
Hey!! Sky!
dba on unix
Oracle Notes Wiki
Welcome to brotherxiao's Home
柔嘉维则@life.oracle.eng
Fenng's shared items in Google Reader
jametong's shared items in Google Reader
缥缈游侠-logzgh
Tanel Poder's blog: Core IT for geeks and pros
DBA Tools
DBA is thinking
NinGoo@Net

