Skip to content

Instantly share code, notes, and snippets.

@fljdin
fljdin / tablespace files.sql
Last active July 16, 2018 15:19
Tablespace usage
set lines 160
set pages 200
col tablespace_name format A30
col file_name format A55
col pct_used format 999.99
set verify off
set trimout on
select f.tablespace_name, f.file_name
, round(f.bytes/1024/1024) as size_mb
SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ;
@fljdin
fljdin / uptime date.sh
Last active September 21, 2017 09:13
Display date of last reboot on unix
date -d "$(cut -f1 -d' ' /proc/uptime) seconds ago"
@fljdin
fljdin / convert_to_mp3.ps1
Last active September 21, 2017 09:13
Bulk convert m4a and aac to mp3
foreach($inputFile in get-childitem -recurse | Where-Object { @('.m4a','.aac') -contains $_.extension })
{
$outputFileName = [System.IO.Path]::GetFileNameWithoutExtension($inputFile.FullName) + ".mp3";
$outputFileName = [System.IO.Path]::Combine($inputFile.DirectoryName, $outputFileName);
$programFiles = ${env:ProgramFiles(x86)};
if($programFiles -eq $null) { $programFiles = $env:ProgramFiles; }
$processName = $programFiles + "\VideoLAN\VLC\vlc.exe"
@fljdin
fljdin / do_things.sql
Last active September 21, 2017 09:12
Increase redolog groups
alter database add logfile ('+DATA', '+DATA') size 100m;
...
alter database drop logfile group 1;
...
alter system switch logfile;
alter system checkpoint;
col COMPATIBILITY form a10
col DATABASE_COMPATIBILITY form a10
col NAME form a20
select group_number, name, compatibility, database_compatibility from v$asm_diskgroup;
@fljdin
fljdin / password_limits.sql
Last active September 21, 2017 09:12
Enhanced password policy
select * from user_password_limits;
SET lines 250
COL enabled FOR a8
COL last_start_date FOR a18
COL next_run_date FOR a18
SELECT owner, job_name, enabled,
to_char(last_start_date, 'YYYY-MM-DD HH24:MI:SS') last_date,
to_char(next_run_date, 'YYYY-MM-DD HH24:MI:SS') next_date
FROM dba_scheduler_jobs
WHERE owner = 'PERFSTAT' AND job_name LIKE 'SP_%';
set line 200
col columns for a100
select i.table_name, i.index_name, listagg(i.column_name, ',') within group (order by i.column_position) columns
from dba_ind_columns i
left join dba_constraints c on i.index_name = c.index_name
where i.index_owner = '&owner' and i.table_name = '&table'
group by i.table_name, i.index_name;
set long 1000
set pagesize 0
select DBMS_METADATA.GET_DDL('OPS$DBO.INDEX','') from DUAL;