2007-06-04

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

来源: 本站收集整理 作者:佚名 评论 0 条
 

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示例


(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:在操作系统损坏时恢复Oracle10g全过程  
下一篇:数据批量导入Oracle数据库
    评论加载中…
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;
共3页: 上一页 [1] 2 [3] 下一页
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号