Monthly Archives: August 2010

Rows from nothing

Every now and again I will need to create multiple rows of dummy data for whatever reason. The following will generate 10 rows that contain the rownumber and a random 10 character lowercase string:

select rownum, dbms_random.string('l',10) rand_string
from dual
connect by level <= 10;


1              ppwuuixwuj
2              icvidoofrl
3              hxkodzcdji
4              qzvbgmdwpj
5              hnurrfeqtd
6              qlzfdspyxe
7              qnwplopyes
8              yvtlczdofw
9              csojntrkze
10             ruklzscjqv


A handy little function for quickly grabbing information about where code is running / who is running it.

Common Uses:

Current User Name:

sys_context('USERENV', 'CURRENT_USER');

Current User SID:

sys_context('USERENV', 'CURRENT_USERID');

Database Name (from Init Param):

sys_context('USERENV', 'DB_NAME');

More info can be found in the documentation


Welcome to my blog.  I will try to post things that I find that may not be common knowledge to all or things that I wish I would have done differently in retrospect so hopefully someone else can avoid walking down the same path.  This will be mostly for my own notes, but if someone else can benefit from me keeping them public then all the better.