Thursday, July 26, 2012

How To EXPORT/IMPORT Full DB in ORACLE

Hi,
If you'd like to make full export for your oracle DB, you can use "EXP" command for this.
Here you see examples for "exp" command:

exp system/manager@xyz FULL=Y FILE=FULL.DMP

Here is EXPORT example by OWNER:
exp system@manager@xyz FILE=File_name.dmp OWNER=Owner_Name


You should drop tables before import:
Create file drop_list.sql


set head off
set pagesize 0
set verify off
set feedback off
spool drop_objects.sql
select 'drop table '||table_name ||';' 
from user_tables
/
spool off

Connect with user/password and run this script: sqlplus owner/owner @drop_list.sql
The script will create file drop_objects.sql - this is a list of tables that should be deleted.



When you should import dumped file to other database you can use "IMP" command.
imp system/manager@xyz FULL=Y FILE=FULL.DMP


Here is IMPORT example by OWNER:
imp system@manager@xyz FILE=File_name.dmp OWNER=Owner_Name


Also you can export/import specific schema with same commands with out "FULL" prefix.

Tuesday, July 24, 2012

How to shrink LOG file in MS-SQL Server 2005/2008


Hi,

There was a problem with Log file was bigger that 40Gb  in my DB.

With these steps I managed to shrink a file:


USE [DBNAME]
GO
CHECKPOINT -- Write checkpoint to the log file, and force SQL to write all dirty pages to the database.
GO
ALTER DATABASE [DBNAME] SET RECOVERY SIMPLE -- Set database to Simple recovery, essentially truncating all the non-active part of the transaction log file.
GO
ALTER DATABASE [DBNAME] SET OFFLINE WITH ROLLBACK IMMEDIATE -- Kill all active transactions/connections rolling back any changes that are outstanding.
GO
ALTER DATABASE [DBNAME] SET ONLINE -- Bring database back online (should have no active connection now).
GO
DBCC SHRINKFILE('LOGICAL_FILE_NAME',0) -- Since we have killed all active transactions, and we have set database to simple recovery mode; all VLF should be in inactive state now; and you should be able to shrink the file.
GO 


Of course you should change backup recovery mode to FULL after this steps.

Friday, July 20, 2012

How to check CPU temperature in Linux

Hi,

If you should check CPU Temperature in Linux
You can use follow command:

cat /proc/acpi/thermal_zone/THM0/temperature
or
cat /proc/acpi/thermal_zone/*/temperature

Good Luck...

Thursday, July 12, 2012

How to create user in Linux.


In this example I'm creating user applprod with bash login option.
You should only change user name & run it with root permissions.

useradd -gdba -s/bin/bash -papplprod -d/home/applprod -m applprod
useradd -gdba -s/bin/bash -poraprod -d/home/oraprod -m oraprod

Tuesday, July 10, 2012

Starting Database Listener gives "Linux Error: 32: Broken pipe"

After attempting to start the listener it is giving following errors
TNS-12547:TNS:lost contact
TNS-12560:TNS:protocol adapter error
TNS-00517:lost contact
Intel SVR4 UNIX Error: 32: Broken pipe

To resolve this issue you should find listener log files location.
1. Login with "ORAUSER" and load environment for this user.
2. cd $TNS_ADMIN
3. Open listener.ora file and find "LOG_DIRECTORY" path.
4. cd to directory found in previous step
5. Check if log size (if log file bigger that 2Gb please delete this file)
6. Start listener.

Thursday, July 5, 2012

How to clear ALL Oracle Application Cache.

1. Login to application with SYSADMIN or different user with sysadmin responsibility.

2. Navigate to -> Functional Administrator


3. Press -> Core Services

4. Press -> Caching Framework

5. Press ->  Global Configuration


6. Press -> Clear All Cache


7. Press -> Yes


8. Press -> Apply


Good Luck...






How to run gather statistics on a table.


You can use analyze command:

analyze table TABLE_NAME compute statistics  
or
analyze table TABLE_NAME estimate statistics 

also you can use "dbms_stats package" follow:

exec dbms_stats.gather_table_stats('ownername','tablename')