Monday, September 28, 2009

Move An Oracle Datafile To A New Location

Had a filesystem fill up on an AIX server today and there was nothing of significant size that I could delete. I could have asked the AIX admin to add some more space, but since it was just a training environment and there were other filesystems with available space, I chose to move some of the datafiles. It's pretty easy to do. Here are the steps.

1. Shutdown the database
2. Physically move (or copy if you want to be extra safe) the datafiles to their new location.
3. Mount the database (startup mount)
4. Rename the datafiles in Oracle with the following command:
alter database rename file 'old full path and file name' to 'new full path and file name';
ex. alter database rename file '/u81/oradata/train/ilawtrain_01.dbf' to '/u91/oradata/train/ilawtrain_01.dbf';

5. Open the database (alter database open)
6. Verify that the datafiles are in the new location in dba_data_files
7. If the datafiles are in the new location as expected and you copied the files instead of moving them, you can now safely delete the old copies of the datafile. Again if you want to be safe, rename the old copies and wait a day or two to delete them.

Thursday, September 24, 2009

Explorer.exe is Using Too Much Memory

I tend to go long periods of time without rebooting my Windows based PC, because I sometimes need to remotely connect to my work PC from home, and I just don't want to close all those programs I have open. This sometimes leads to the explorer.exe program using up a lot of memory. If my PC starts running slow, or I hear the hard drive spinning for an extended period of time, I'll hit ctl-alt-del and click on the "Processes" tab and sort by "Mem Usage". Usually explorer.exe is using about 30,000k or so, but I've seen it get up to almost 200,000k. In this pic, it's using 34,204k.

explorer.exe mem usage

If I see that is is using more than 50,000k of memory, I'll watch it for a minute and if it doesn't drop back down, I'll go ahead and highlight it by clicking once on it, and then click the "End Process" button. You will get a warning message about terminating a process, but I have never had any problems from terminating this program. However, to be safe make sure that you have saved any important projects that you are working on at the time. Explorer.exe is basically your Windows shell, so once you end the process, your task bar and start button will disappear. Your programs will still be running and you will still be able to see them. Next, click on the "Applications" tab and then click on the "New Process" button. It will bring up a box where you will enter the name of the application, in this case enter explorer.exe and click "OK". You should now see your task bar and start button once again, and if you click on the "Processes" tab and sort by "Mem Usage", the explorer.exe program should now be using much less memory than it was before.

Saturday, September 19, 2009

Search and Replace in VI

This morning I finally got tired of opening a file from ftp in ultraedit just to replace a few words on our AIX systems. I knew there was an easy way to do this directly in the vi editor, but just had not taken the time to research. I finally did, and it is pretty easy, although similar to many unix commands it is not very user friendly in it's context. Here are the basics for replacing a string of text with another string of text in the vi editor:

:s is the command for substitute and you follow that with the string you want to replace and the new string separated by "/". For example, if I wanted to replace the word "left" with "right" I would enter the following command in vi:

:s/left/right/

Now, I don't really find that command very useful because it only searches the current line and only replaces the first instance of the word "left". IF you want to search the entire file, the "%s" command takes care of that:

:%s/left/right/

While that searches the entire file, it still only replaces the first instance of the word "left" that it finds. What I really want to do most often is replace all instances of a word in the file. Going back to the example above, the command to replace all instances of the word "left" would be the "g" option at the end of the command:

:%s/left/right/g

There are plenty of more options that make the substitute command even more powerful, but those are the basics and what I find myself using the most.