`
robinfung
  • 浏览: 55103 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

myOracle

 
阅读更多
--To check the free memory of the shared pool
SELECT * FROM v$sgastat WHERE NAME = 'free memory';

--To flush the shared pool
Alter system flush shared_pool;

 

Tuning

select * from v$sqlarea;

 

set autotrace traceonly explain



SQLPlus DBMS_XPLAN
 EXPLAIN PLAN SET STATEMENT_ID = 'R1' FOR

  SELECT * FROM USER_TABLES;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY(null,'R1','typical'));

 

Autotrace defination:

recursive calls = basically sql performed on behalf of your sql.  So, if we had to PARSE
the query for example, we might have had to run some other queries to get data dictionary
info.  that would be recursive calls. 

db block gets = blocks gotten in "current" mode.  That is, blocks gotten as they exist
right now.  You'll see these for full table scans (segment headers are read in current
mode) and modification statements (we modify the block as it exists "right now")

consistent gets = blocks gotten in consistent read mode.  This is the mode we read blocks
in with a select for example.  Also, when you do a searched UPDATE/DELETE, we read the
blocks in consistent read mode and then get the block in current mode to actually do the
modification.  A select for update will do this as well.

physical reads = self explanatory, physical IO

redo size = self explanatory -- amount of redo generated

sorts (memory)/(disk) -- sorts done.

 

LISTAGG (measure_expr [, 'delimiter_expr'])
  WITHIN GROUP (order_by_clause) [OVER query_partition_clause]
 
with rb as(  
  select 500 population, 'China' nation ,'Guangzhou' city from dual union all  
  select 1500 population, 'China' nation ,'Shanghai' city from dual union all  
  select 500 population, 'China' nation ,'Beijing' city from dual union all  
  select 1000 population, 'USA' nation ,'New York' city from dual union all  
  select 500 population, 'USA' nation ,'Bostom' city from dual union all  
  select 500 population, 'Japan' nation ,'Tokyo' city from dual   
)

select population,  
       nation,  
       city,  
       listagg(city,',') within GROUP (order by city) over (partition by nation) rank  
from rb;


with temp as(  
  select 'China' nation ,'Guangzhou' city from dual union all  
  select 'China' nation ,'Shanghai' city from dual union all  
  select 'China' nation ,'Beijing' city from dual union all  
  select 'USA' nation ,'New York' city from dual union all  
  select 'USA' nation ,'Bostom' city from dual union all  
  select 'Japan' nation ,'Tokyo' city from dual   
)  
select nation,listagg(city,',') within GROUP (order by city)  
from temp  
group by nation  ;

 

clean session cache

ALTER SESSION SET events 'immediate trace name flush_cache';

 

Get the store procedure body

select text from user_source where name ='xx';

 

  List the procedures
select * from User_Procedures;  
Oracle statistic
select * from sys.aux_stats$;
Indexes
select index_name, index_type from user_indexes where index_name='XX';

select * from all_ind_columns where index_name =
  Database parameters
select * from v$parameter where upper(name) like upper('parallel_max_servers');
select * from v$parameter where upper(name) like upper('processes');
select * from v$parameter where upper(name) like upper('parallel_force_local');
select * from v$parameter where upper(name) like upper('open_cursors');
select * from v$parameter where upper(name) like upper('MEMORY_MAX_TARGET');
select * from v$parameter where upper(name) like upper('MEMORY_TARGET');
select * from v$parameter where upper(name) like upper('db_keep_cache_size');
select * from v$parameter where upper(name) like upper('parallel_max_servers');
select * from v$parameter where upper(name) like upper('processes');
select * from v$parameter where upper(name) like upper('parallel_force_local');
select * from v$parameter where upper(name) like upper('open_cursors');
select * from v$parameter where upper(name) like upper('MEMORY_MAX_TARGET');
select * from v$parameter where upper(name) like upper('MEMORY_TARGET');
select * from v$parameter where upper(name) like upper('db_keep_cache_size');
show parameter process
  
select * from v$process;


show parameter process;


select * from user_indexes where table_name = '' ;

select * from user_indexes where index_name = 'IDX_SY_DELEGATION_USR_FUN$1';

describe bj_sysadmin;

select * from user_indexes where upper(table_name) like upper('bj_sysadmin');


select POOL, round(bytes/1024/1024,0) FREE_MB
from v$sgastat
where name like '%free memory%';
 
how to get the available free memory space
select POOL, round(bytes/1024/1024,0) FREE_MB
from v$sgastat
where name like '%free memory%';
 Date format
DD-MON-RR HH.MI.SSXFF AM
    Cursor
/* check max cluster */
SELECT t.machine, t.user_name, t.sql_id, sql.sql_fulltext, t.total
FROM (
  SELECT s.machine, oc.user_name, oc.sql_id, count(1) AS total 
  FROM v$open_cursor oc, v$session s
  WHERE oc.sid = s.sid
  GROUP BY user_name, oc.sql_id, machine,oc.sql_id
  HAVING COUNT(1) > 2
) t
LEFT JOIN v$sql sql ON t.sql_id = sql.sql_id
WHERE sql.sql_fulltext like '%PAL_ADMIN%'
ORDER BY total DESC;

/* checking the cursor number and cursor SQL - start */
select o.sid, osuser, machine, count(*) num_curs
from v$open_cursor o, v$session s
where  o.sid=s.sid
group by o.sid, osuser, machine
order by machine, num_curs desc;

select q.sql_text, q.LAST_ACTIVE_TIME
from v$open_cursor o, v$sql q
where q.hash_value=o.hash_value and o.sid in (397, 493)
order by q.LAST_ACTIVE_TIME desc; 
/* checking the cursor number and cursor SQL - end */
  Check session lock
/*check lock */  
SELECT 
	(SELECT username FROM gv$session WHERE gv$session.sid = a.sid and rownum = 1) AS blocker,
	a.sid,
	sa.machine,
	sqla.sql_id,
	sqla.sql_fulltext,
	sqla.elapsed_time,
	'is blocking',
	(SELECT username FROM gv$session WHERE gv$session.sid = b.sid and rownum = 1) AS blockee,
	b.sid,
	sb.machine,
	sqlb.sql_id,
	sqlb.sql_fulltext,
	sqlb.elapsed_time
FROM gv$lock a
	INNER JOIN gv$lock b ON a.id1 = b.id1 AND a.id2 = b.id2
	INNER JOIN gv$session sa ON sa.sid = a.sid
	INNER JOIN gv$session sb ON sb.sid = b.sid
	LEFT JOIN gv$sqlarea sqla ON sa.sql_hash_value = sqla.hash_value AND sa.sql_address = sqla.address
	LEFT JOIN gv$sqlarea sqlb ON sb.sql_hash_value = sqlb.hash_value AND sb.sql_address = sqlb.address
WHERE a.block = 1
	AND b.request > 0
ORDER BY a.sid ASC, b.sid ASC; 
 invalid hex number
utl_raw.cast_to_raw('(BLOB)')
 check constraint
/*constraint*/
SELECT 
cons.constraint_name AS constraint_name,
source.table_name AS src_table,
source.column_name AS src_column,
destination.table_name AS dest_table,
destination.column_name AS dest_column
FROM user_constraints cons
	LEFT JOIN user_cons_columns source ON source.constraint_name = cons.constraint_name
	LEFT JOIN user_cons_columns destination ON destination.constraint_name = cons.r_constraint_name
WHERE cons.constraint_type = 'R'
	AND (source.table_name = UPPER('rp_run_param') OR destination.table_name = UPPER('rp_run_param'))
ORDER BY cons.constraint_name ASC, source.table_name ASC, 
    source.column_name ASC, destination.table_name ASC, destination.column_name ASC;
 AWR report Generation
SELECT * FROM dba_hist_snapshot ORDER BY begin_interval_time DESC; 

set pagesize 0;
set echo off heading on underline on; 
set lines 1500; 
set termout on; 
column inst_num  heading "Inst Num"  format 99999; 
column inst_name heading "Instance"  format a12; 
column dbid      heading "DB Id"     format 9999999999 just c;
SPOOL "C:/temp_awr/CLNTSPH2_1_20153108_1698_1699.HTML"
SELECT output
FROM TABLE(dbms_workload_repository.awr_report_HTML(2640918804,1,1698,1699));
SPOOL OFF

 
parameters setting
MEMORY_TARGET not supported on this system :
https://www.krenger.ch/blog/ora-00845-memory_target-not-supported-on-this-system/
https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt
 
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

    My oracle笔记

    5. 使用profile管理用户口令:`PROFILE`用于设置用户的资源限制和口令策略,如`ALTER USER user PROFILE my_profile`将用户分配给特定的profile。 三、PL/SQL编程 PL/SQL是Oracle特有的过程式语言,它结合了SQL与...

    myoracle123.sql

    myoracle123.sql

    Oracle数据库创建步骤

    control_files=(/home/app/oracle/product/10.1.0/oradata/myoracle/control01.ctl, /home/app/oracle/product/10.1.0/oradata/myoracle/control02.ctl, /home/app/oracle/product/10.1.0/oradata/myoracle/control...

    ORACLE透明网关访问mysql

    这里的`myoracle@'B'`代表从服务B(Oracle服务器)上的Oracle数据库通过指定的用户名`myoracle`访问服务A上的MySQL数据库`test`。确保在授权时使用了正确的主机名`'B'`,这样Oracle在尝试连接MySQL时才能被正确识别...

    Oracle Database Server 'TNS Listener'远程数据投毒漏洞(CVE-2012-1675)的解决文档

    1234 SolutionRecommendations for protecting against this vulnerability can be found at:My Oracle Support Note 1340831.1 for Oracle Database deployments that use Oracle Real Application Clusters (RAC)....

    oracle数据库监听配置

    在出现的数据库栏中输入全局数据库名,如 myoracle。注意这里的全局数据库名与数据库 SID 有所区别,全局数据库名实际通过域名来控制在同一网段内数据库全局命名的唯一性。 六、本地服务名配置(Tnsnames) 本地...

    oracle监听配置

    3. 配置数据库服务,输入全局数据库名(如myoracle.mydomain.com),并指定Oracle主目录和SID(如myoracle)。 4. 保存配置,监听器的配置文件(listener.ora)通常位于$ORACLE_HOME/network/admin目录下。 客户端...

    oracle 11g r2安装与卸载图解

    10. 新建自定义目录:在 d 盘下新建一个文件夹,取名为 myoracle, 进入这个文件夹,在里面新建一个文件夹,取名 oracle。 11. 继续安装,点击‘oracle 基目录’后面的那个浏览,选择刚新建的 d:\myoracle\oracle 这...

    Oracle 文档号搜集

    Oracle Metalink是Oracle公司提供给客户的技术支持门户,现在被称为My Oracle Support(MOS)。它包含了大量技术文档、故障解决方案、产品更新和安全补丁等信息,对于Oracle产品的用户来说,Metalink是一个极其宝贵...

    Oracle支持库

    8. **My Oracle Support**:Oracle的My Oracle Support是访问支持库的主要入口,用户可以在这里注册账户,追踪服务请求,获取个性化支持,并管理自己的支持合同。 通过充分利用Oracle支持库,无论是新手还是经验...

    创建Oracle数据库(以Oracle10g为例)

    control_files=(/home/app/oracle/product/10.1.0/oradata/myoracle/control01.ctl, /home/app/oracle/product/10.1.0/oradata/myoracle/control02.ctl, /home/app/oracle/product/10.1.0/oradata/myoracle/control...

    Linux 下 Tomcat 7 连接 Oracle 10g

    你需要在`<Context>`标签内添加以下代码来定义一个名为`jdbc/myoracle`的数据源,使用`thin`驱动连接到本地的Oracle数据库,用户为`scott`,密码为`tiger`,数据库服务标识符(SID)为`mysid`: ```xml ...

    oracle_patch_download_method

    1. **访问Oracle支持网站**:首先,你需要登录到Oracle支持网站(My Oracle Support)。这是Oracle官方提供补丁下载的平台。 2. **查找补丁**:在网站上输入相应的下载号,系统会显示与该下载号相关的补丁详情页面...

    vs2005+oracle

    在"myoracle"这个文件中,可能包含了一个具体的VS2005项目,该项目已经实现了与Oracle数据库的连接和操作。这可能包括了数据库连接字符串,SQL查询,以及可能的存储过程调用。通过阅读和分析这个项目的代码,我们...

    asp连接oracle9i数据库成功实例

    - `DataSource=myOracle`:这里的`myOracle`是指Oracle数据源名称(Data Source Name),通常是在ODBC数据源管理器中配置好的。 - `UID=scott` 和 `PWD=tiger`:分别是登录Oracle数据库的用户名和密码。 #### 解决...

    Oracle安装

    2. 在出现的“配置安全更新”窗口中,取消“我希望通过My Oracle Support接受安全更新”,单击“下一步”。 3. 在随后出现的“未提供电子邮件”警告对话框中点“是”。 4. 在“安装选项”窗口中,选择“创建和配置...

    oracle静默安装教程

    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false DECLINE_SECURITY_UPDATES=true oracle.installer.autoupdates.option=SKIP_UPDATES 全局替换 /home/oracle/netca.rsp 内容改为: [GENERAL] RESPONSEFILE_VERSION=...

Global site tag (gtag.js) - Google Analytics