Saturday, December 27, 2008

Install Oracle XE on Ubuntu

Following some of the directions here, I did something like this:

Added
deb http://oss.oracle.com/debian unstable main non-free
to /etc/apt/sources.list and then:
# wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle  -O- | sudo apt-key add -
# apt-get update
# apt-get install oracle-xe
Then it was off and running.
$ export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
$ export PATH=$PATH:$ORACLE_HOME/bin
$ sqlplus sys@XE as sysdba

I used the nifty web interface http://127.0.0.1:8888/apex to make myself a new user.




Wednesday, December 17, 2008

Apache Commons stuff not everyone uses

Apache Commons has some neat stuff in it that not everybody uses. Here's a sampling of some of the lesser-used items:
  • EqualsBuilder
  • HashCodeBuilder
  • CompareToBuilder
  • ToStringBuilder
For more info read the developerWorks article "Stop writing so much code!"

Tuesday, December 16, 2008

Some Oracle commands

Renaming a table:
alter table oldname rename to newname;


Renaming a column:
alter table sometable rename column oldname to newname;


Return only a specified number of rows:
select * from mytable where rownum;


Make a backup copy of a table:
create table mytable_backup as select * from mytable;


Get a list of tables:
select * from cat;


Get the create command for a table (showing the primary key):
select dbms_metadata.get_ddl('TABLE',upper('MYTABLE')) from dual;


Change a user password:
alter user user_name identified by new_password;


Make things print to screen nicer:
set pagesize 0
set long 999999