A blog by a system administrator and programmer.

Oracle moving index to another table space 
Tuesday, April 8, 2008, 05:04 PM - Programming
Posted by Freddy Chu
These days I am super busy. Nearly no time to write my blog. :(

There is so many people asking me how to move the index after created. As you know if you use plsql developer's GUI it will drop the constraint and add again with index. I don't know why it work like that but there is some simple solution.

ALTER INDEX <INDEX_NAME> REBUILD TABLESPACE <TALESPACE_NAME>

Here also show you a simple procedure to move all index of a table from one tablespace to another tablespace.


create or replace procedure MOVE_INDEX_BETWEEN_TABLESPACE(from_ts in string,
to_ts in string,
tablename in string) is
cursor index_names is
select user_indexes.index_name
from user_indexes
where user_indexes.table_name like upper(tablename)
and user_indexes.tablespace_name = upper(from_ts);
index_name user_indexes.index_name%type;
begin
open index_names;
loop
fetch index_names
into index_name;
exit when index_names%notfound;
if index_name is not null and to_ts is not null then
EXECUTE IMMEDIATE 'ALTER INDEX ' || index_name ||
' REBUILD TABLE_SPACE ' || to_ts;
end if;
end loop;
end MOVE_INDEX_BETWEEN_TABLESPACE;

add comment ( 119 views )   |  permalink   |   ( 3 / 4329 )
Java disk usage 
Friday, January 11, 2008, 11:56 AM - Programming
Posted by Freddy Chu
It have been a long time for me to found a way to check the disk usage in Java.

Finially i get the solutions. It is in Java 6.0. java.io.File

There is 2 functions.

getTotalSpace() --- Returns the size of the partition named by this abstract pathname.
getUsableSpace() --- Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.


If your application is limited to use versions before 6.0. Then you can only keep using external commands.
Runtime.getRuntime().exec(commands);
e.g.
Linux/Unix: df
Windows: fsutil volume diskfree c:

Alternative solutions for system independent solutions is to setup a snmp on the server you want to check and use java snmp client to query the result. That will be quite complex.

Useful links:
snmp4j
netsnmp
add comment ( 125 views )   |  permalink   |   ( 3 / 3840 )

<<First <Back | 1 | 2 |