Wednesday, September 26, 2007

using general expression when creating check constraint in pl/sql

CONSTRAINT "CUSTOMER_CK_PHONE" CHECK (REGEXP_LIKE ( phone, '^([0-9]*?\ ?\/?[0-9]{4}[0-9]{4})$ ' ) ) ENABLE

Monday, September 24, 2007

Oracle Database 10g Express Edition forgot password after installation

symptom:
I installed 10g ex a while ago, now try to login, but forgot what the password was for the default username "system", can any one please help to retrieve the password?

fix:
SQL> conn / as sysdba
Connected.
SQL> alter user system identified by ;

Sunday, September 23, 2007

PL/SQL DBMS_OUTPUT.PUT_LINE formating experience

for the header row, do this:
DBMS_OUTPUT.PUT_LINE(rpad(‘ID’,5) || rpad(‘LAST_NAME’, 15) || rpad(‘FIRST_NAME’,15) || lpad(‘ANNUAL_SALARY’,11) || lpad(‘TAX’,11) || lpad(‘COMMISSION_PCT’, 16));
DBMS_OUTPUT.PUT_LINE(rpad(‘____ ’,5) || rpad(‘_______________’, 15) || rpad(‘_______________’,15) || lpad(‘___________’,11) || lpad(‘___________’,11) || lpad(‘______________’, 16));

then in the loop I did:
DBMS_OUTPUT.PUT_LINE(rpad(r_emp.id,5) || rpad(r_emp.last_name, 15) || rpad(r_emp.first_name,15) || lpad(v_an_sal,11) || lpad(v_tax,11) || lpad(v_com_pct, 16));

not very enjoyable way of formating, but it worked......

Sunday, September 09, 2007

sqlplus view existing indexes

select * from user_indexes
where table_owner like 'xxxxxx' and table_name like 'ABC';

Friday, September 07, 2007

modify linewidth in sqlplus

set line 200;