`

Oracle related

 
阅读更多

1. 权限传递:

系统权限传递:with admin option

对象权限传递:with grant option

 

2. 查看package的所有方法:

DESC DBMS_WORKLOAD_REPOSITORY;

 

3. 查看AWR setting

select * from dba_hist_wr_control;

 

4. package, procedure, function

function有返回值,有参数;

procedure无返回值,有参数;

package可包括function,procedure

package中只有各个方法的定义,package body中涉及具体的实现。

 

5. 块

DECLARE
  v_object_id NUMBER(4);
  v_object_type VARCHAR2(10);
BEGIN
  v_object_type := '&TYPE';
  SELECT OBJECT_ID INTO V_OBJECT_ID FROM DBA_OBJECTS WHERE OBJECT_NAME = 'DBA_HIST_WR_CONTROL' AND OBJECT_TYPE = v_object_type;
  dbms_output.put_line(v_object_id);
END;

 

6. 使用sqlplus 的时候,密码中有特殊字符。

./sqlplus 'user/"#Ee_l!f832"'@SID

 

 7. Wait event

"DFS lock handle": (due to ordered)

"row cache lock": (due to cache size too small)

 

8. Select space usage for each tablespaces

SELECT A.TABLESPACE_NAME,TOTAL,FREE,(TOTAL-FREE) USDED,ROUND((TOTAL-FREE)/TOTAL,4)*100 "USAGE %"
FROM  (SELECT TABLESPACE_NAME,SUM(BYTES) FREE FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME ) A,
(SELECT TABLESPACE_NAME,SUM(BYTES) TOTAL FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) B
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME ORDER BY TABLESPACE_NAME;

 

9. 转义 单引号

SELECT CHR(39) FROM DUAL;

select Q'[']' from dual;

 
10. BULK COLLECT & FORALL
DECLARE
  TYPE TYPE_INVST_ACCT_NUM IS TABLE OF TMP_SH_ACCT.INVST_ACCT_NUM%TYPE INDEX BY BINARY_INTEGER;
  V_INVST_ACCT_NUM TYPE_INVST_ACCT_NUM;
BEGIN
  
  SELECT INVST_ACCT_NUM BULK COLLECT INTO V_INVST_ACCT_NUM FROM TMP_SH_ACCT WHERE FUNCTION_TYPE = 'GFIX_EXEC';

  FORALL i IN V_INVST_ACCT_NUM.first..V_INVST_ACCT_NUM.last
  EXECUTE IMMEDIATE 'BEGIN SC_PRODUCT_CODE_RANDOM(:1, 1);END;' USING V_INVST_ACCT_NUM(i);
  COMMIT;
END;
/
 
11. 最高效的删除重复记录方法 (因为使用了ROWID)例子:
DELETE FROM EMP E WHERE E.ROWID > (SELECT MIN(X.ROWID) FROM EMP X WHERE X.EMP_NO = E.EMP_NO);
 
12. AWR report
SELECT * FROM DBA_HIST_SNAPSHOT ORDER BY BEGIN_INTERVAL_TIME desc;
SELECT OUTPUT FROM TABLE(DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML(2503047371,'1','110345','110346'));
SELECT OUTPUT FROM TABLE(DBMS_WORKLOAD_REPOSITORY.AWR_SQL_REPORT_HTML(2503047371,'1','110345','110346','d72f1bx3vsv1t'));
 
 

13. Java calls function & stored procedure.

# Stored procedure
CallableStatement ctmt = conn.prepareCall("{call TESTP()}");
 
CallableStatement ctmt = conn.prepareCall("{call TESTP(?)}");
ctmt.registerOutParameter(1, Types.VARCHAR);
 
# Function
PreparedStatement stmt = conn.prepareStatement("SELECT TESTF() FROM dual");
 
CallableStatement ctmt = conn.prepareCall("{? = call TESTF}");
ctmt.registerOutParameter(1, Types.VARCHAR);

 

 

分享到:
评论

相关推荐

    Oracle SQL Tuning with Oracle SQLTXPLAIN: Oracle Database 12c Edition

    This new edition has been expanded to include AWR, Oracle 12c Statistics, interpretation of SQL Monitor reports, Parallel execution, and Exadata-related features. Reading this book and using SQL ...

    Oracle Concepts中英文对照版

    purpose of a database is to store and retrieve related information 数据库服务器是解决信息管理问题的核心组件。大体上说,数据库服务器 的作用是可靠地管理多用户环境下的大规模数据,使多用户可以并发地访 问...

    Oracle Field Service Implementation Guide Release 11i

    GOVERNMENT RIGHTSPrograms, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" ...

    Oracle 11g Performance Tuning Recipes

    《Oracle 11g 性能调优技巧》是一本深度解析Oracle 11g数据库性能优化的专业书籍,涵盖了从表优化、索引选择与优化、实例内存优化、系统性能监控到SQL执行效率提升等全方位的性能调优策略。本书不仅适合Oracle DBA和...

    Oracle R12 Functional Guide

    Oracle R12 Financials Functional Guide, This book is ...analysis of the functionality and best practices related to Oracle's R12 E-Business Suite release. I am pleased to be able to recommend this book.

    Oracle Essbase

    Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Intel and Intel Xeon are trademarks or registered trademarks of ...

    oracle 官方手册

    - Programs, software, databases, and related documentation are provided under a license agreement containing restrictions on use and disclosure. #### 七、总结 《Oracle Database Administrator's Guide...

    oracle-interview-questions

    ### Oracle Interview Questions详解 #### 一、Co-related Subquery与Nested Subquery的区别 **知识点:** - **Co-related Subquery(关联子查询)**: 在这种类型的子查询中,内部查询只执行一次,并根据该结果来...

    Oracle EBS数据字典中文版

    Fold**: XXEUL_OM_RELATED_INFO **说明**: 完整的订单数据视图整合了与订单相关的所有信息,包括订单头、订单行以及与之关联的客户信息等,为用户提供了一个全面的订单视图。 **6. Fold**: XXEUL_OE_DILIVERY_...

    Oracle9i Database Error Messages

    Oracle9i Database Error Messages Release 2 (9.2) Contents Title and Copyright Information Send Us Your Comments Preface Audience Organization Related Documentation Conventions Documentation ...

    oracle事例代码

    5. **创建关联表(Creating Related Tables)**: `kc`表代表课程信息,包含课程号(`kch`)、课程名(`kcm`)、开课学期(`kkxq`)、选修人数(`xs`)和学分(`xf`)。同样,`xs_kc`表作为学生和课程成绩的关联表...

    Oracle® Database SQL Language Quick Reference

    - **Related Documents(相关文档)**:列出了与此文档相关的其他参考资料或手册,以便读者进一步深入学习。 - **Conventions(约定)**:说明了文档中使用的各种术语和符号的意义,帮助读者更好地理解文档内容。 ...

    ORACLE ERP 11i表结构字段中文名称

    - **QUANTITY_RELATED**: NUMBER 类型,相关数量。 - **SO_BASIS**: NUMBER 类型。 - **OPTIONAL**: NUMBER 类型,是否可选(1. 是;2. 否)。 - **MUTUALLY_EXCLUSIVE_OPTIONS**: NUMBER 类型,互斥标识(1. 是;2. 否)...

    Oracle EBS R12 Order Management_TRAIN

    Entering sales orders for service items typically involves specifying the service type and any related details. 2. **Order Fulfillment**: After the sales order is entered, it needs to be fulfilled ...

    Building.Database.Clouds.in.Oracle.12c.0134310861

    The authors first explain the key concepts underlying DBaaS, describe cloud computing implementations related to it, and outline the business and technology benefits. Next, they show how the Oracle ...

    Troubleshooting Oracle Performance, 2nd Edition

    database-related design problems that lead to suboptimal performance. Chapter 2, “Key Concepts,” describes the operations carried out by the database engine when parsing and executing SQL statements...

    Oracle Database 12c Performance Tuning Recipes

    Oracle Database 12c Performance Tuning Recipes is a ready reference for database administrators in need of immediate help with performance issues relating to Oracle Database. The book takes an example...

    Oracle 11g数据仓库2天培训指南

    ### Oracle 11g 数据仓库2天培训指南 #### 知识点概览 本文档为Oracle 11g 数据仓库两天培训指南的原版资料,涵盖了数据仓库的基础概念、安装配置过程、基本管理和维护技巧等内容。对于希望快速掌握Oracle 11g 数据...

    oracle 10g-admin1 考试试题

    Typically, questions involving this clause would ask about the implications or operations related to such constraints, such as altering tables or handling errors during constraint enforcement.

    TroubleshootingOraclePerformance_2ndEdition

    database-related design problems that lead to suboptimal performance. Chapter 2, “Key Concepts,” describes the operations carried out by the database engine when parsing and executing SQL statements...

Global site tag (gtag.js) - Google Analytics