惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Webroot Blog
Webroot Blog
U
Unit 42
A
About on SuperTechFans
宝玉的分享
宝玉的分享
月光博客
月光博客
C
CERT Recently Published Vulnerability Notes
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
P
Privacy & Cybersecurity Law Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Securelist
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
B
Blog
I
Intezer
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
V
V2EX
L
LangChain Blog
AI
AI
G
GRAHAM CLULEY
T
Tor Project blog
人人都是产品经理
人人都是产品经理
D
Docker
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
I
InfoQ
Y
Y Combinator Blog
C
Comments on: Blog
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
Vercel News
Vercel News
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿

博客园 - 思净

oracle中的公用同义词和私有同义词? 对C#下函数,委托,事件的一点理解! - 思净 - 博客园 经典悖论漫游(下) 经典悖论漫游中 经典悖论 精彩悖论 悖论漫谈之三 悖论漫谈(二) 经典悖论 Oracle数据库结构之物理存储结构 Oracle专家高级编程学习笔记( 二) Oracle 基本知识 简单的ORACLE存储过程 SQL子查询的一些例子 Oracle学习笔记---(三) Oracle学习笔记---(四) 掌握SQL四条最基本的数据操作语句 Oracle学习笔记---(五) Oracle学习笔记---(一)
Oracle专家高级编程学习笔记
思净 · 2007-06-05 · via 博客园 - 思净

Oracle专家高级编程学习笔记

一.准备工作
1.建立基本调试环境
Create demo schema(建立演示模式)
sqlplus>start $ORACLE_HOME/sqlplus/demo/demobld.sql
 
2.建立login.sql
---------------------------------
define_editor=vi
set serveroutput on size 1000000
set trimspool on
set long 500
set linesize 100
set pagesize 9999

column plan_plus_exp format a80
column global_name new_value gname

select lower(user)||'@'||decode(global_name,'WEBDB.FANYAMIN.NET','webdb',global_name) global_name from global_name;

set sqlprompt '&gname>'
set termout on
-------------------------------------------------
3.在sqlplus中配置AutoTrace
1)cd $ORACLE_HOME/rdbms/admin
log into sqlplus as system(connect system/manager@webdb)
run @utlxplan
run create public synonym plan_table for plan_table;
run grant all on plan_table to public;
2)
cd $ORACLE_HOME/sqlplus/admin
log into sqlplus as sys(connect sys/change_on_install@webdb)
run @plustrce
run grant plustrace to public;

二.内容
1.开发成功的Oracle应用程序
一条简单秘诀
if(possible) 就用单条SQL语句完成
else if(possible) 用plsql程序
else if(possible) 用java存储过程
else if(possible) 用C外部过程
else 考虑是否真有必要这样做

两个指导方针
1)不要在MTS下运行长事务<45s
2)使用绑定变量
system@webdb>alter system  flush shared_pool;
system@webdb>set timing on
执行这两个sql文件,一比较,发现使用绑定变量后,速度快多了
--bindtest1.sql, did not use bind variable
-----------------------------------------------------------------------------
declare
 type rc is ref cursor;
 l_rc rc;
 l_dummy all_objects.object_name%type;
 l_start number default dbms_utility.get_time;
begin
 for i in 1..1000
 loop
  open l_rc for
  'select object_name from all_objects where object_id='||i;
  fetch l_rc into l_dummy;
  close l_rc;
 end loop;
 dbms_output.put_line(round((dbms_utility.get_time-l_start)/100,2)||'seconds...');
end;
/
--bindtest2.sql,  use bind variable
-----------------------------------------------------------
declare
 type rc is ref cursor;
 l_rc rc;
 l_dummy all_objects.object_name%type;
 l_start number default dbms_utility.get_time;
begin
 for i in 1..1000
 loop
  open l_rc for 
  'select object_name from all_objects where object_id=:x'
  using i;
  fetch l_rc into l_dummy;
  close l_rc;
 end loop;
 dbms_output.put_line(round((dbms_utility.get_time-l_start)/100,2)||'seconds...');
end;
/
Oracle封锁策略
1)只有当修改时,oracle在行级上锁定数据,不要把锁定上升到块级或表级
2)Oracle决不会为读取而锁定数据,简单读取不能在数据行上设置锁定
3)数据的写入器不会阻塞数据读取器.
4)只有当另一个数据写入器已经锁定了某行数据后,才阻塞其他人对该行数据的写入.数据读取器决不会阻塞数据的写入器

Oracle的这种"不阻塞"方法用一个副作用,如果想要一次只有一个用户访问某行数据,在多用户环境中,必须经常使用在多线程程序设计用到的相似技巧,
select * from resources where resource-name=:room_name FOR UPDATE

Oracle的并行控制机制(多版本一致读)
一致性查询:在某一时刻查询产生一致结果
非阻塞查询:数据写入器从来不阻塞查询