Thursday, July 30, 2009

Setting NLS_LANG for Oracle

NLS_LANG= language_territory.character set

Example:
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

Setting NLS_LANG tells Oracle what characterset the client is using so Oracle can do conversion if needed from client’s characterset to the database characterset and setting this parameter on the client does not change the client’s characterset. Setting Language and Territory in NLS_LANG has nothing to do with storing characters in database, it’s controlled by the characterset and of course if the database can store that characterset.

To check session NLS session parameters, note this doesn’t return the characterset set by NLS_LANG

SELECT * FROM NLS_SESSION_PARAMETERS;
SELECT USERENV ('language') FROM DUAL;

To find the NLS_LANG of your database one can run the following SQL:
SQL> SELECT * from NLS_DATABASE_PARAMETERS WHERE parameter IN ( 'NLS_LANGUAGE', 'NLS_TERRITORY', 'NLS_CHARACTERSET');

PARAMETER VALUE
—————————— —————————————-
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CHARACTERSET WE8MSWIN1252

To get the possible value for language, territory and characterset you can check the view V$NLS_VALID_VALUES.
– parameter – possible values LANGUAGE, TERRITORY, CHARACTERSET

SELECT parameter, value FROM V$NLS_VALID_VALUES;

To change the client language

export NLS_LANG=BELGIUM_.WE8ISO8859P1
To change the client territory
export NLS_LANG=_BELGIUM.WE8ISO8859P1
To change the client characterset
export NLS_LANG=.AL32UTF8


Amin Jaffer

Wednesday, July 29, 2009

HOWTO: Formatting and partitioning your external usb hard drive in LINUX

Say the disk is at /dev/sdc (and not mounted)

sudo parted -i /dev/sdc
mklabel msdos
mkpart primary 0% 100% (makes 1 primary partition span entire disk)
mkfs 1 fat32 (puts a FAT32 filesystem on that partition)
quit
Then you should reformat the disk and check for bad blocks (unmount first if necessary)
sudo mkfs.vfat -c -L label -F 32 /dev/sdc1
note: label can be anything you want up to 11 characters, no spaces.
If you want to go nuts with the check, specify -c twice,
that will write/read 4 bit patterns to the entire drive, giving it a real workout.


or

mkfs.vfat /dev/sdc1

Tuesday, July 7, 2009

Copying Data from One Database to Another

SET ARRAYSIZE 50
SET LONG 1000
SET COPYCOMMIT 100 /* To set commit size */

EXP1:
COPY FROM USER1/USER@SID1 TO USER2/USER2@SID2 INSERT TABLE USING SELECT * FROM TABLEA where ....;

EXP2:
COPY FROM USER1/USER@SID1 TO USER2/USER2@SID2
CREATE NEWTABLE (DEPARTMENT_ID, DEPARTMENT_NAME, CITY)
USING SELECT * FROM EMP_DETAILS_VIEW Where.....;

Monday, July 6, 2009

To Start,Stop,Restart crontab service in Linux

/sbin/service crond start
/sbin/service crond stop
/sbin/service crond restart