Skip to main content

Posts

Sergey's script of rman Incrementally Updated Backups

  #!/bin/bash # This script invokes rman to perform a daily # incremental backup of db # if ARC key is used it makes an archive log backup if a threshold is exceeded # It checks for errors and sends email if any. # It cleans up this script log files older then the log file retention period, Check "set up variables" section. # set up a debug mode ##set -x host_name=$(hostname) opsys=$(uname) script=$(basename $0) if [ ${opsys} = 'Linux' ]; then     scriptpath=$(dirname $(readlink -f $0)) else     scriptpath=$(dirname $0) fi scriptNoExt=$(echo ${script} | cut -d \. -f 1) paramFilePath=${scriptpath}/${scriptNoExt}.param oraSetFile="${HOME}/.oraset_ss" #---------------- # Functions usage () {     echo "Usage: ${script} db_instance_name type_of_backup"     echo "Where type_of_backup = [empty|ARC|DELARC|DELBACKUPS]"     echo "    empty - backup the whole database"     echo "    ARC - backup and clean up archi...

ORDS commands

ORDS Installation/config ${ORDS_HOME}/bin/ords --config ${ORDS_CONFIG} install ORDS version: version from database and ords binary should match select ords.installed_version from dual; ${ORDS_HOME}/bin/ords --version sqldeveloper cli to show ORDS enabled schemas and modules C:\Downloads\Oracle\sqlcl-23.1.0.089.0929\sqlcl\bin>sql jiulusun/$passwd@//MYIncorp-scan:1521/webd SQL> rest schemas C:\Downloads\Oracle\sqlcl-23.1.0.089.0929\sqlcl\bin>sql testuser1/testuser1@//MYIncorp-scan:1521/webd SQL> rest  modules To change the ords_public_user password in wallet file ${ORDS_HOME}/bin/ords config --db-pool webd secret db.password start and stop: more  /MYIncorpmw/scripts/stop_ords_dev.sh #!/bin/bash export PATH=/usr/sbin:/usr/local/bin:/usr/bin:/usr/local/sbin:$PATH kill $(ps -ef | grep "ords_dev/ords/ords.war" | grep -v grep | awk '{print $2}') [Wed Jun 07 10:18:49]oracle@vm-km-ords2-t.MYIncorp.local:/MYIncorpmw/scripts /MYIncorpmw/o...

SQL Server query stats

 This is helpful -- https://www.mssqltips.com/sqlservertip/7696/sql-server-oracle-cached-query-statistics-execution-plans/?utm_content=head SELECT     DB_NAME(ISNULL([t].[dbid],     (SELECT CAST([value] AS SMALLINT) FROM [sys].[dm_exec_plan_attributes]([st].[plan_handle]) WHERE [attribute] = 'dbid'))) [DatabaseName],    ISNULL(OBJECT_NAME([t].[objectid], [t].[dbid]),'{AdHocQuery}') [Proc/Func],    MIN(SUBSTRING([t].[text], ([st].[statement_start_offset]/2)+1, ((CASE [st].[statement_end_offset] WHEN -1 THEN DATALENGTH([t].[text]) ELSE [st].[statement_end_offset] END - [st].[statement_start_offset])/2)+1)) [Text],    MAX([st].[max_rows]) [Rows],    SUM([st].[execution_count]) [Runs],    SUM([st].[execution_count])/(SELECT MAX(v) FROM (VALUES (DATEDIFF(ss,MIN([st].[creation_time]),GETDATE())), (1)) AS VALUE(v)) [Calls/Sec],    SUM([st].[max_elapsed_time])/1000000 [TimeSec],    SUM([st]....

AutoIT with microsoft teams

Download autoit and install run au4Info_x64.exe go to the microsoft teams meeting chat room, click on the chat room. the autoIT (au4Info_x64.exe)  will capture the window title as "mylastname, myfirstname (BC xxx inc) (You) | Microsoft Teams", get it also in summary tab so that I can copy the title. run SciTE/SciTE.exe, create new file with the content below, replace the windows title with what was captured in the step above.  ; Wait for 5 seconds to open Microsoft Teams, click on the typing message field Sleep(5000) While True ; Loop indefinitely WinWait("mylastname, myfirstname (BC xxx inc) (You) | Microsoft Teams") WinActivate("mylastname, myfirstname (BC xxx inc) (You) | Microsoft Teams") WinWaitActive("mylastname, myfirstname (BC xxx inc) (You) | Microsoft Teams") Send("H ")    Sleep(240000) WEnd SciTE.exe-> tools-> go

AZure SQL DMV

 -- https://learn.microsoft.com/en-us/azure/azure-sql/database/high-cpu-diagnose-troubleshoot?view=azuresql SELECT     COUNT(*) as vCores FROM sys.dm_os_schedulers WHERE status = N'VISIBLE ONLINE'; select * from sys.dm_os_schedulers select * from  master.sys.resource_stats SELECT * FROM sys.dm_db_resource_stats ORDER BY end_time DESC;  

Azure SQL logins roles permissions

 --for sql logins SELECT * FROM sys.sql_logins; SELECT * FROM sys.sysusers; SELECT * FROM sys.database_principals  --- to connect master sql logins to the users in the user databases --- run this in user database select l.name as [login name],u.name as [user name] from sysusers u inner join sys.sql_logins l on u.sid=l.sid -- For AAD logins: SELECT * FROM sys.server_principals  SELECT * FROM sys.database_principals  -- To retrive role and it's granted members: SELECT    roles.principal_id                            AS RolePrincipalID   ,    roles.name                                    AS RolePrincipalName   ,    database_role_members.member_principal_id    AS MemberPrincipalID   ,    members.name            ...

AutoIT input message in MicrosoftMeeting

; Download software https://www.autoitscript.com/site/autoit/downloads/ ; run this script from SciTE script editor ; This is the script, it will find the microsoft teams window and the chat box title, typing automatically  ; Wait for 5 seconds to open Microsoft Teams, click on the chat window and typing message field, this need to be done manually. Sleep(5000) While True ; Loop indefinitely ; Wait for the Microsoft Teams window to exist ;MsgBox(0, "Window Handle","debug -1") ;use the AutoIt v3 Window Info to capture the microsoft teams chat window title, for example, capture the chat box title is "John Smith (ABC) (You) | Microsoft Teams" WinWait("John Smith (ABC) (You) | Microsoft Teams") ; Activate the Microsoft Teams window using its title and a more specific WinTitleMatchMode WinActivate("John Smith (ABC)  (You) | Microsoft Teams") ; MsgBox(0, "Window Handle","debug0") ; Wait for the window to become active W...