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;

Wednesday, August 29, 2007

upload sql database to the host environment

found this tool that makes it easier to upload sql database to the host environment
http://www.codeplex.com/sqlhost

Friday, August 24, 2007

oracle sqlplus

select TABLE_NAME, CONSTRAINT_NAME, STATUS
from USER_CONSTRAINTS
where TABLE_NAME like 'INVOICE';

the word after 'like' must be in capital, otherwise you won't get any result

make your DNN site home page style different to other pages

create a homepage skin with the LogoPane instead of the Logo skin token

all other pages will use a skin that has standard Logo skin token

yellow color flash when open a new page on DNN site

the background color of my site is mainly dark-red and black, the text is in white color. When i click on a link to open another page, the background always flash in yellow color and return back to normal. what happened?

answer:
there is a background color set to be yellow in the css, check it

how to remove DNN version number on the tab

update DNN site from version 3.1 to 3.3.7, now when i open the site in IE7, the version number is displayed together with the page title on the IE7 tab:

My Site > Home (DNN 3.3.7)

in order to get rid of the stuff in '()', Log in as superuser ("host"), go to host settings in host menu and uncheck "show copyright credits".

Thursday, August 09, 2007

Oracle DB 10g EX SQL - case sensitivity

Only the text with quotes is case sensitive.

Wednesday, August 08, 2007

Oracle DB 10g EX SQL - create table - syntax to add Check

CREATE TABLE student(
student_no NUMBER(3) NOT NULL,
age NUMBER(2) CHECK(age>18),
gender CHAR(1) CHECK(gender='m' or gender='f') NOT NULL
);

Tuesday, August 07, 2007

Oracle DB 10g EX SQL - query the list of all columns in curent table

SELECT * FROM tab;

MS SQL - query the list of all columns in curent table

select column_name from information_schema.columns where table_name ='authors'

MS SQL - query the list of all tables in curent schema

select * from sysobjects where type = 'U' and uid=user_id('dbo')

Sunday, August 05, 2007

Thursday, May 10, 2007

filter a GridView column based on another column, ASP.NET

< asp:Button runat="server" ID="GoButton" Text="Go" CommandName="Select" Visible='<%# ((System.Data.DataRowView)Container.DataItem)["ABC"] != DBNull.Value %/>' />

Wednesday, May 09, 2007

Only String Type accpts null value in mssql db

if you want to do assign a NULL value to a integer type column, u will get error, I had to try to give a -1 value to work around, is there a better/real solution?

Thursday, April 12, 2007

VS2005 ASP.NET Gridview Date Format

tried to format date boundfield to {0:dd/MM/YYYY}, it won't work, in order to solve the problem, you need to set the "HtmlEncode" of the column to "false"