科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道八个学习点帮你认识Oracle数据库(2)

八个学习点帮你认识Oracle数据库(2)

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

本文提供八个学习点帮助你全面认识Oracle数据库

作者:changelive 来源:赛迪网 2007年9月3日

关键字: 数据 数据库 ORACLE

  • 评论
  • 分享微博
  • 分享邮件

Synonym

创建同义词示例:

create public synonym xxx for myuser.t_user
create synonym t_user for myuser.t_user
select * from dba_synonyms where table_name='T_USER'

跨数据库查询

create database link dblinkzgl 
connect to myuser identified by a using 'mydb'
Select * From t_user@dblinkzgl

course示例

示例1:

create or replace procedure pro_test_cursor is
userRow t_user%rowtype;
cursor userRows is
select * from t_user;
begin
for userRow in userRows loop
dbms_output.put_line
(userRow.Id||','||userRow.Name||','||userRows%rowcount);
end loop;
end pro_test_cursor;

示例2:

create or replace procedure 
pro_test_cursor_oneRow(vid in number) is
userRow t_user%rowtype;
cursor userCur is
select * from t_user where id=vid;
begin
open userCur;
fetch userCur into userRow;
if userCur%FOUND then
dbms_output.put_line
(userRow.id||','||userRow.Name);
end if;
close userCur;
end pro_test_cursor_oneRow;

record示例

create or replace 
procedure pro_test_record(vid in varchar2) is
type userRow is record(
id t_user.id%type,
name t_user.name%type
);
realRow userRow;
begin
select id,name into 
realRow from t_user where id=vid;
dbms_output.put_line
(realRow.id||','||realRow.name);
end pro_test_record;

rowtype示例

create or replace procedure 
pro_test_rowType(vid in varchar2) is
userRow t_user%Rowtype;
begin
select * into userRow from t_user where id=vid;
dbms_output.put_line
(userRow.id||','||userRow.name);
end pro_test_rowType;
(T006)
    • 评论
    • 分享微博
    • 分享邮件
    闂侇収鍠曞▎銏㈡媼閵忋倖顫�

    濠碘€冲€归悘澶愬箖閵娾晜濮滈悽顖涚摃閹烩晠宕氶崶鈺傜暠闁诡垰鍘栫花锛勬喆椤ゅ弧濡澘妫楅悡娆撳嫉閳ь剟寮0渚€鐛撻柛婵呮缁楀矂骞庨埀顒勫嫉椤栨瑤绻嗛柟顓у灲缁辨繈鏌囬敐鍕杽閻犱降鍨藉Σ鍕嚊閹跺鈧﹦绱旈幋鐐参楅柡鍫灦閸嬫牗绂掔捄铏规闁哄嫷鍨遍崑宥夋儍閸曨剚浠樺ù锝嗗▕閳ь剚鏌ㄧ欢鐐寸▕鐎b晝顏遍柕鍡嫹

    重磅专题
    往期文章
    最新文章