# cd /etc/yum.repos.d # wget http://public-yum.oracle.com/public-yum-ol6.repo # yum install oracle-rdbms-server-12cR1-preinstall –nogpgcheck
Oracle Technical
Posts about Oracle databases
Display the SQL statement that a Linux Process is Executing
-- get the process id from Linux (use top or ps) -- the process id is spid in v$process select sql_id from v$session where paddr in (select addr from v$process where spid in (4567)) -- put the sql_id from v$session into v$sqlarea/v$sql_text/v$sql select sql_text from v$sqlarea where sql_id = 'ap3qms77rt67k' -- this will display the sql that the process is executing -- In one query select sql_text from v$sqlarea where sql_id = (select sql_id from v$session where paddr in (select addr from v$process where spid = 1820) );
Powershell – Recursive Search for Strings in Files
To search for a string (grep) in files recursively with Powershell (example):
gci -recurse -include *.sql|%{gc $_} | %{$_|select-string "dba"}
To get the filename(s): gci -recurse -include *.txt|%{$Filename=$_;gc $_} | %{$res=$_|select-string "dba";if ($res) {Write-Host "$Filename"}}
SQL Server – Translate object_ids/object_names
-- Get object_id from object name select OBJECT_ID('[dbo].[testobject]') -- get object_name from object id select OBJECT_NAME(213575799)
SQL Server – Display Running Tasks
Use this query in conjunction with sp_who to display running tasks and determine whether there are sessions blocking other sessions, and who is executing the query (sp_who)
SELECT command, r.session_id, r.blocking_session_id, s.text, start_time, percent_complete, CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), ' + CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, ' + CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time, CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), ' + CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, ' + CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go, dateadd(second,estimated_completion_time/1000, getdate()) as est_completion_time FROM sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s --WHERE r.command like ('%DBCC%')
Changing SQL Server Database Collation
free -m
Real Memory Consumption = Total – (free + buffers + cached)
# free -m total used free shared buffers cached Mem: 15943 15678 265 6 511 3706 -/+ buffers/cache: 11460 4483 Swap: 8159 0 8159 # cat /proc/meminfo|grep -i huge AnonHugePages: 0 kB HugePages_Total: 4916 HugePages_Free: 3413 HugePages_Rsvd: 35 HugePages_Surp: 0 Hugepagesize: 2048 kB The total memory reserved for huge pages is approximately 10 G ((4916 * 2048) /1024/1024) This is approximately equal to 'used' on the second line of the 'free -m' command 11460/1024 = 11G On an Oracle database server, the Huge Pages should be about 70-80% of the physical RAM - varies with size, not a hard rule. On an Oracle database server, the ulimits for the oracle user should be set accordingly - this means that the Oracle user hard and soft limits for memory should be set high enough Following files are modified to enable Huge Pages and disable transparent huge pages /etc/grub.conf kernel …… transparent_hugepage=never --> reboot Example: 8G RAM --> set 70% for Huge Pages = 5.6G --> set vm.nr_hugepages=2688 in /etc/sysctl.conf --> 5.55G HugePages --> 2 databases with SGA_TARGET set to 2.6G or 1 database with SGA_TARGET set to 5.5G MEMORY_TARGET set to 0 (AMM should be disabled when Huge Pages are configured) /etc/sysctl.conf vm.nr_hugepages=2688 (a number representing the number of pages – no unit) Multiply by 2048 (K) and divide by 1024*1024 to get the number of GB of memory --> 5.55 G in this case vm.hugetlb_shm_group=3000 /etc/security/limits.conf e.g set 7G = 7*1024*1024 = 7340032 --> for a server with 8G of memory Another example for memlock ulimits: Set the value (in KB) slightly smaller than installed RAM. e.g. If you have 64GB RAM installed, you may set soft memlock 60397977 hard memlock 60397977 (works out to 57G)
Flush and Reset Client Resolver Cache
ipconfig /flushdns
Powershell Environment Variables
$env
$env:path
$env:PSModulePath
Full list
Get-Childitem env:
Snipping Tool – Capture Contextual Menu
When you want to capture a menu option, (that annoyingly disappears when you try to capture with snipping tool), use the following
procedure:
- Ensure there is no current capture in the snipping tool program (open/reopen snipping tool)
- To capture a screen clip of a contextual menu, press ctrl-print-screen