网站首页
JSP空间
动态资讯
开源项目
技术文档
资源下载
J2EE资源
客户论坛
在线支付
 
  技术文档>>数据库技术>>Oracle技术>>Oracle开发>查看文档  
  八个学习点帮助你全面认识Oracle数据库TableSpace     
  文章作者:未知  文章来源:未知  
  查看:176次  录入:管理员--2007-06-03  
 

TableSpace

表空间:

一个表空间对应多个数据文件(物理的dbf文件)

用语法方式创建tablespace,用sysdba登陆:

--创建表空间mytabs,大小为10MB:

create tablespace mytabs datafile 
'C:\oracle\oradata\mydb\mytabs1.dbf' size 10M;
alter user zgl default tablespace mytabs;
--把tabs做为zgl的默认表空间。
grant unlimited tablespace to zgl;
--将操作表空间的权限给zgl。

Exception

示例:

create or replace procedure
pro_test_exception(vid in varchar2) is
userName varchar2(30);
begin
select name into userName from t_user where id=vid;
dbms_output.put_line(userName);
exception
when no_data_found then
dbms_output.put_line('没有查到数据!');
when too_many_rows then
dbms_output.put_line('返回了多行数据!');
end pro_test_exception;

安全管理

以下语句以sysdba登陆:

用户授权:

alter user zgl account lock;--锁定帐号。

alter user zgl identified by zgl11;--修改用户密码。

alter user zgl account unlock;--解除帐号锁定。

alter user zgl default tablespace tt;--修改用户zgl的默认表空间为tt。

create user qqq identified by qqq123 default tablespace tt;--创建用户。

grant connect to qqq;--给qqq授予connect权限。

grant execute on zgl.proc01 to test;--将过程zgl.proc01授予用户test。

grant create user to zgl;--给zgl授予创建用户的权限。

revoke create user from zgl;--解除zgl创建用户的权限。

角色授权:

create role myrole;--创建角色myrole

grant connect to myrole;--给myrole授予connect权限

grant select on zgl.t_user to myrole;--把查询zgl.t_user的权限授予myrole

grant myrole to test;--把角色myrole授予test用户

概要文件(配置文件):

全局设置,可以在概要文件中设置登陆次数,如超过这次数就锁定用户。

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;
 
 
上一篇: 讲解基于Oracle高性能动态SQL程序开发    下一篇: 不要忽视Oracle 10g STATSPACK新功能
  相关文档
实例解析:怎样获得当前 数据库的scn值 11-15
单机创建物理Oracle9istandby数据库 05-13
Oracle两个基本概念帮你了解体系结构 05-13
数据库不在open状态下的冷备份恢复步骤 02-29
使用"oracle"解析函数快速检查序列间隙 02-02
深刻理解Oracle数据库的启动和关闭 01-15
数据变更日志记录表及触发器的自动生成脚本 03-04
教你在Oracle中实现SELECT TOP N的方法 06-03
在oracle数据库中移动数据文件的具体方法 08-04
使用简化连接时如何才能不显示输入密码 03-07
解析:基于oracle高性能动态sql程序开发 11-15
Oracle数据库字符集转换规律全面剖析 04-11
轻松掌握优化oracle网络设置的解决方案 (1) 01-25
多方面讲解pl/sql编程存在的几个缺点 (1) 04-16
监控Oracle数据库的常用shell脚本 01-15
如何使用 10203事件 跟踪 oracle块清除 11-20
查看前五个最占用cpu的oracle会话进程 02-01
oracle 9i数据库的用户创建以及权限分配 05-07
全面剖析Oracle数据库中的分区功能 04-11
在Windows系统下完全卸载Oracle的好方法 09-29
返回首页 | 关于我们 | J网章程 | JSP空间合租 | 客服中心 | 免责声明 | 常见问题 | 参观机房
本站主机空间代理至厦门市华众网络科技有限公司
《中华人民共和国增值电信业务经营许可证》
编号:闽B2-20050079
@2005-2008福建JSP技术网 版权所有 闽ICP备05000928号
厦门(总部):13616026886 福州:0591-87655121
邮箱:admin@fjjsp.com 站长QQ,点击这里给我发消息