Category: Database

Splunk query to group URI request by first three IP address octets

We needed this to understand the source of a large influx of requests for a given URI pattern. import splunklib.client as client import splunklib.results as results service = client.connect(host="*******",port="8089",username="showard",password="************") job = """ search host=\"cmhlpecomweb*\" sourcetype=access_combined karlie-kloss | eval temp=split(_raw,\"\t\") |…

Query SQL Server XML column for value

Just an example of how to pull this type of value from an embedded XML document in a SQL Server database table column… select top 100 * from Transactions with (nolock) where trn_xml.value('(/Transaction/RetailStoreId)[1]', 'int') = 2401

Oracle materialized view and query rewrite

Just a simple example to show what it takes to get this to work… SQL> set lines 1000 trims on pages 100 SQL> explain plan for select count(*) from member; Explained. SQL> select * from table(dbms_xplan.display()); PLAN_TABLE_OUTPUT ——————————————————————————– Plan hash…

SQL Server – querying active users by database

use master go declare @table table(         spid int,         status varchar(max),         login varchar(max),         hostname varchar(max),         blkby varchar(max),         dbname varchar(max),         command varchar(max),         cputime int,         diskio int,         lastbatch varchar(max),         programname varchar(max),        …