Search This Blog

Friday, December 30, 2016

Oracle: Delete all constraint from multiple table

If you want o delete all constraint from your required tables , you can use following PL/SQL program:

begin
    for r in ( select table_name, constraint_name
               from user_constraints
               where TABLE_NAME in ('TABLE1', 
                                    'TABLE2',
                                    'TABLE3') )
    loop
        execute immediate 'alter table '||r.table_name
                          ||' drop constraint '||r.constraint_name;
    end loop;
end loop;

Monday, December 26, 2016

Oracle: ORA-12712: new character set must be a superset of old character set

 

In Oracle Database 11g you can get this error.

ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;

SQL> ALTER DATABASE CHARACTER SET AL32UTF8;
ALTER DATABASE CHARACTER SET AL32UTF8
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set


SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;

Database altered.

All steps for change database character parameter.

SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP RESTRICT;
ORACLE instance started.

Total System Global Area  612368384 bytes
Fixed Size                  1292036 bytes
Variable Size             268437756 bytes
Database Buffers          335544320 bytes
Redo Buffers                7094272 bytes
Database mounted.
Database opened.
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

System altered.

SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;

System altered.

SQL>
SQL>
SQL> ALTER DATABASE CHARACTER SET AL32UTF8;
ALTER DATABASE CHARACTER SET AL32UTF8
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set


SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;

Database altered.

SQL> ALTER DATABASE CHARACTER SET AL32UTF8;

SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP;
ORACLE instance started.

Total System Global Area  612368384 bytes
Fixed Size                  1292036 bytes
Variable Size             272632060 bytes
Database Buffers          331350016 bytes
Redo Buffers                7094272 bytes
Database mounted.
Database opened.

Monday, December 12, 2016

Oracle Database Auto Database Startup and Shutdown on Linux Platform

First login using Root user ;  then use the below command :

# vi /etc/oratab

You will find following line ( you may fund different line as per your install location of DB).

NANODB:/u01/app/oracle/product/11.2.0/dbhome_1:N

Now, you have to change it to

NANODB:/u01/app/oracle/product/11.2.0/dbhome_1:Y


Now, Create a file called '/etc/init.d/dbora' as the Root user, containing the following code.

#!/bin/sh
# chkconfig: 345 99 10

# description: Oracle auto start-stop script.
#

# Set ORA_HOME to be equivalent to the $ORACLE_HOME


# from which you wish to execute dbstart and dbshut;

#

# Set ORA_OWNER to the user id of the owner of the

# Oracle database in ORA_HOME.

mount -t tmpfs shmfs -o size=28g /dev/shm

ORA_HOME=/DATABASE/u01/app/oracle/product/11.2.0/dbhome_1

ORACLE_HOME=/DATABASE/u01/app/oracle/product/11.2.0/dbhome_1

ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]

then

echo "Oracle startup: cannot start"

exit

fi

case "$1" in

'start')

# Start the Oracle databases:

# The following command assumes that the oracle login

# will not prompt the user for any values

su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"

su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"

su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
;;

'stop')

# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
;;

esac
export ORACLE_HOME=/DATABASE/u01/app/oracle/product/11.2.0/dbhome_1
/etc/init.d/httpd stop
/etc/init.d/httpd start
route add default gw 225.57.178.188 em1
exit $?

  
Use the chmod command to set the privileges to 750 as well as service list

chmod 750 /etc/init.d/dbora
#chkconfig --add dbora


Oracle and PHP: Using Bangla in Oracle and PHP (Unicode)

SQL> conn sys as sysdba
Connected.
SQL>
SQL>
SQL>  shutdown immediate;
         Database closed.
         Database dismounted.
         ORACLE instance shut down.
SQL> startup restrict;
         ORACLE instance started.

Total System Global Area  ####### bytes
.
.
.
.


Database mounted.
Database opened.

SQL> alter database character set AL32UTF8;

Database altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area  ####### bytes
.
.
.
.


Database mounted.
Database opened.

Now , you can insert BANGLA in Oracle Database. 

Again, you need to access from PHP front end. You have to add character set in PHP connection file. 
I used below line:
   
 <?php
         $db_charset = 'AL32UTF8';

$con = oci_connect('nano', 'nan786', '192.168.1.111/nandb',$db_charset);
   ?>

Thursday, December 1, 2016

Oracle: Export multiple table in a single command example

exp falhrma/falhrma@xe file=E:\ERP_BACKUP\FALHRMA_ACC_01122016.DMP log=E:\ERP_BACKUP\exp_FALHRMA_ACC_01122016.log  tables=HRM_EMP_SALARY_BANK_MYVW_TB,HRM_EMPLOYEE_ENTIT_MYVW_TB,HRM_EMPLOYEE_MYVW_TB,HRM_EMPLOYEE_SALARY_MYVW_TB,HRM_LEAVE_TRANS_DTL_MYVW_TB,HRM_LEAVE_TRANS_MAIN_MYVW_TB,HRM_RAW_DATA_ATTND_BKP_MYVW_TB,HRM_SALARY_DTLS_MYVW_TB,HRM_SALARY_MST_MYVW_TB,HRM_WEEKEND_MYVW_TB MANUAL_ATTENDANCE_INFO_MYVW_TB consistent=y