Monday, April 28, 2008

Query to get a date after 10 years

select ADD_Months(to_date('12/3/2008','dd/MM/yyyy'),120)from dual

Profiles commands in oracle

CREATE PROFILE

CREATE PROFILE agent LIMIT CONNECT_TIME 10;
ALTER PROFILE data_analyst LIMIT CONNECT_TIME UNLIMITED;

CREATE PROFILE agent LIMIT CPU_PER_CALL 3000;
ALTER PROFILE data_analyst LIMIT CPU_PER_CALL UNLIMITED;

IDLE_TIME
CREATE PROFILE agent LIMIT IDLE_TIME 10;
ALTER PROFILE daemon LIMIT IDLE_TIME UNLIMITED;



CREATE PROFILE agent LIMIT LOGICAL_READS_PER_CALL 2500;
ALTER PROFILE data_analyst LIMIT LOGICAL_READS_PER_CALL 1000000;


CREATE PROFILE agent LIMIT LOGICAL_READS_PER_SESSION 250000;
ALTER PROFILE data_analyst
LIMIT LOGICAL_READS_PER_SESSION 35000000;

PRIVATE sGA
CREATE PROFILE agent LIMIT PRIVATE_SGA 2500;
ALTER PROFILE data_analyst LIMIT PRIVATE_SGA UNLIMITED;



SESSIONS_PER_USER
CREATE PROFILE admin_profile LIMIT SESSIONS_PER_USER 2;
ALTER PROFILE data_analyst LIMIT SESSIONS_PER_USER 6;




CREATE PROFILE agent LIMIT
FAILED_LOGIN_ATTEMPTS 3
PASSWORD_LOCK_TIME 10/1440;
-- remove failed login restrictions
ALTER PROFILE student LIMIT FAILED_LOGIN_
-- manually unlock an account
ALTER USER scott ACCOUNT UNLOCK;



CREATE PROFILE agent LIMIT
PASSWORD_LIFE_TIME 90 - 14
PASSWORD_GRACE_TIME 14;
-- set no limit to password lifetime
ALTER PROFILE student LIMIT
PASSWORD_LIFE_TIME UNLIMITED
PASSWORD_GRACE_TIME DEFAULT;


CREATE PROFILE agent LIMIT
PASSWORD_REUSE_TIME 365
PASSWORD_REUSE_MAX 4;
-- remove password reuse constraints
ALTER PROFILE student LIMIT
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED;



-- use a custom password function
CREATE PROFILE agent LIMIT PASSWORD_VERIFY_FUNCTION my_function;
-- disable use of a custom function
ALTER PROFILE student LIMIT PASSWORD_VERIFY_FUNCTION DEFAULT;

-- use a custom password function
CREATE PROFILE agent LIMIT PASSWORD_VERIFY_FUNCTION my_function;
-- disable use of a custom function
ALTER PROFILE student LIMIT PASSWORD_VERIFY_FUNCTION DEFAULT;

installing oracle 10g on linux

ORACLE 10g(10.2.0.1.) INSTALLATION ON RedHat Enterprise Linux [RHEL 4]

Minimum Hardware Configuration Required

Ram - 512 MB

Hard Disk space - 20 GB

Processsor - P IV / P III / ( PII IBM support)

Linux Installation

RHEL – 4 [ 4 CDs]

Insert Ist CD and boot from the boot drive, just press the Enter for installation

Manual Disk Partion (minimum)

1. boot 150 MB Fixed

2. / 4000MB Fixed

3. Swap 2xRAM Fixed

4. /home 3500MB Fixed

5. /user 4000MB Fixed

6. /tmp 1000MB fixed

7. /usrlocal 200MB fixed

8. /opt 200 MB fixed

Remaining Freespace create RAID 0

Select Raid

Mount point /oracle

Fill to maximum space

Packges Required For ORACLE 10g

binutils-2.15.92.0.2-13.EL4

compat-db-4.1.25-9

compat-libstdc++-296-2.96-132.7.2

control-center-2.8.0-12

gcc-3.4.3-22.1.EL4

gcc-c++-3.4.3-22.1.EL44

glibc-2.3.4-2.9

glibc-common-2.3.4-2.9

gnome-libs-1.4.1.2.90-44.1

libstdc++-3.4.3-22.1

libstdc++-devel-3.4.3-22.1

make-3.80-5

pdksh-5.2.14-30

sysstat-5.0.5-1

xscreensaver-4.18-5.rhel4.2

setarch-1.6-1

After Installation

Login as root

Insert CD3 , open terminal window , type the following

#rpm –Uvh libaio-0.3.96

#rpm –Uvh openmotif2l -2.1-30-11 RHEL4.2

1. # vi /etc/hosts

press ‘I’ for insert

add the following line below 127.0.0.1 localdoman.localhost local host

ip of the machine machinename.domain machine

eg: 192.168.10.1 lserver.datamate.com lserver

press ESC , Press Shift+: , curson on the bottom , type wq! , press enter for return to root.

2. # vi /etc/ sysconfig/network

press I for insert

add the following HOSTNAME=lserver [ press ESC , Press Shift+: , type

wq! And press Enter return to root

  1. # service network restart
  2. #hostname – i( checking the ipaddress)
  3. #hostname (checking machine name)
  4. #hostname –d (checking domainname)
  5. #vi /etc/sysctl.conf

Add the following lines at a end of the last line , press I

kernel.shmall = 2097152

kernel.shmmax = 536870912

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

fs.file-max = 65536

net.ipv4.ip_local_port_range = 1024 65000

net.core.rmem_default = 262144

net.core.wmem_default = 262144

net.core.rmem_max = 262144

net.core.wmem_max = 262144

press ESC , Press Shitft+:, type wq! , Press Enter to return root

  1. # sysctl –p
  2. vi /etc/pam.d/login

add the following lines at the bottom Press I

session required /lib/security/pam_limits.so

Press ESC , Press Shift+: , type wq! Press Enter to return to root

  1. # vi /etc/security/limits.conf

add the following lines at the bottom Press I

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

Press ESC , Press Shift+: , type wq! , Press Enter to return root

  1. #vi /etc/selinux/config

Check the line SELINUX = disabled

Oracle USER CREATION

#groupadd oinstall

#groupadd dba

#useradd -g oinstall –G dba oracle

#passwd oracle

type password for oracle user two times

#mkdir –p /oracle/u01/app/oracle

#chown –R oracle:oinstall /oracle/u01/app/oracle

#chmod –R 775 /oracle/u01/app/oracle

logout from user and login as oracle

Insert Oracle database 10g cd

Double click on the CD DRIVE

Open terminal

$ cd /database

$ . runistaller