Posts

Showing posts from May, 2017

Basic Shell script

cat analyze_tab_28012016.sh #!/bin/ksh sqlplus / as sysdba <<EOF set feed on  time on echo on spool analyze_tab_28012016.log @analyze_tab_28012016.sql select name from v\$database; spool off EXIT 

Tablespace queries

======================================================================== select a.tablespace_name,a.total_space,b.free_space, round((b.free_space*100)/a.total_space,2) as pct_free from (select tablespace_name, round(sum(bytes)/1048576,2) Total_space from dba_data_files group by tablespace_name) a, (select tablespace_name, round(sum(bytes)/1048576,2) free_space from dba_free_space group by tablespace_name) b where a.tablespace_name=b.tablespace_name(+) order by 4 desc / To check free persent of tablespace usage; =========================================== SELECT m.tablespace_name,     round(max(m.used_percent),1) PERCM,     round(((sum(d.bytes)*count(distinct d.file_id))/count(d.file_id)-NVL(sum(f.bytes),0)/count(distinct d.file_id))*100/(sum(d.bytes)*count(distinct d.file_id)/count(d.file_id)),1) PERC,     round(max(m.tablespace_size*t.block_size/1024/1024/1024),1) TOTALM,     round(max(m.used_space*t.block_size/1024/1024/1024),1) USED,     round(max((m.tablespace_size-m.used_space)*t.

Start PDB database

Start PDB database: SQL> set lines 375 pages 375 SQL> select * from v$pdbs;     CON_ID       DBID    CON_UID GUID                             NAME                           OPEN_MODE  RES OPEN_TIME                                     CREATE_SCN TOTAL_SIZE BLOCK_SIZE RECOVERY SNAPSHOT_PARENT_CON_ID ---------- ---------- ---------- -------------------------------- ------------------------------ ---------- --- -------------------------------------- ------------------------------------- ---------- ---------- ---------- -------- ----------------------          2 1546047038 1546047038 113A0688B395403B9DB00AF18C2E8C5F PDB$SEED                       READ ONLY  NO  31-MAY-17 04.21.04.477 PM +05:30                                        2233959  796917760       8192 ENABLED                       0          3 1713795759 1713795759 38482EDFE2E348B3BDD3467D5AC2698E PDB12                          MOUNTED                                2242657          0       8192 ENABLED                      

Change character set of Oracle database and using CSSAN and DMU

Change character set of Oracle database: shutdown the db: 1.shutdown immediate database start in restrict mode 2.startup restrict change the character set internal use 3.Alter database character set internal_use AL32UTF8; change the character set 4.Alter database character set AL32UTF8; bounce the database 5.shutdown immediate; 6. startup;  SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET'; ===================== Change character set from WE8MSWIN1252 to AL32UTF8: SQL> SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET'; VALUE$ --------------------------------------------------------------------------- WE8MSWIN1252 SQL> SELECT value$ FROM sys.props$ WHERE name = 'NLS_NCHAR_CHARACTERSET'; VALUE$ --------------------------------------------------------------------------- AL16UTF16 SQL> exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and