Print current Oracle character set

Short PL/SQL block to print the characters in range [033..256]

set serveroutput on

declare
i number;
j number;
k number;
begin
for i in 2..15 loop
for j in 1..16 loop
k:=i*16+j;
dbms_output.put((to_char(k,'000')) || ':' || chr(k) || ' ' );
if k mod 8 = 0 then
dbms_output.put_line('');
end if;
end loop;
end loop;
end;

Process all databases in Sybase


#!/usr/bin/ksh
echo "Started..."

print -u2 -n "Enter password:"
stty -echo
read PASS
stty echo
print

rm -f databases.lst
isql -U sa -S $DSQUERY -w 999< databases.lst
$PASS
select 'DBLABEL' "XXX", name from master..sysdatabases
go
exit
EOF

for DB in $(cat databases.lst) ; do

print -u2 "Processing $DB ..."
isql -U sa -S $DSQUERY -w 999 -D $DB <

Find the Oracle object by name

If You don’t remember exactly the name of the view or table, so this query is for You:


col SHORT_OBJECT_NAME for a30
select
substr( ob.OBJECT_NAME,1,30)"SHORT_OBJECT_NAME",
substr( ob.OWNER,1,15)"SHORT_OWNER" ,
ob.OBJECT_TYPE,ob.CREATED
from dba_objects ob
where object_name like upper('%&template%') escape '\'
order by 1,2;

Start sqlplus in Windows .BAT script

Here is the example of emulating “HERE-documents” in Windows shell.


@ECHO OFF

FIND "/*%none% some_label" <%0 |sqlplus USER/PASS@SERVER GOTO end : ----------- embedded SQL------------------------- /* some_label */ select count(*) from dba_free_space; /* some_label */ select tablespace_name from dba_tablespaces; : ----------- end of embedded SQL------------------------- :end

It's also possible to use procedures in .bat files.
%none% is replaced by empty string.
Spaces are mandadory in "/* some_label */" string.

Another possibility:
[cc lang="dos"]
@(
echo select global_name from global_name ;
) | sqlplus USER/PASS@SERVER
[/cc]

[amazon-product]0735622620[/amazon-product]

Show hidden parameters in Oracle

Check the hidden underscore parameters


col "Parameter" for a50
col "Session Value" for a15
col "Instance Value" for a15

select a.ksppinm "Parameter",
b.ksppstvl "Session Value",
c.ksppstvl "Instance Value"
from x$ksppi a, x$ksppcv b, x$ksppsv c
where a.indx = b.indx and a.indx = c.indx
and substr(ksppinm,1,1)='_'
and lower(a.ksppinm) like lower('%&param%')
order by a.ksppinm;

Setting the parameter:

alter system set "&param." = value scope = &scope. ;

scope is one of the following: “both”, “memory”, “spfile”

To remove completely the hidden parameter from the spfile:

alter system reset "&param." scope=spfile SID='*';