热烈祝贺台州朗动科技的站长论坛隆重上线!(2012-05-28)    热烈庆祝伟大的祖国60周年生日 点击进来我们一起为她祝福吧(2009-09-26)    站长论坛禁止发布广告,一经发现立即删除。谢谢各位合作!.(2009-08-08)    热烈祝贺台州网址导航全面升级,全新版本上线!希望各位一如既往地支持台州网址导航的发展.(2009-03-28)    台州站长论坛恭祝各位新年快乐,牛年行大运!(2009-01-24)    台州Link正式更名为台州网址导航,专业做以台州网址为主的网址导航!(2008-05-23)    热烈祝贺台州Link资讯改名为中国站长资讯!希望在以后日子里得到大家的大力支持和帮助!(2008-04-10)    热烈祝贺台州Link论坛改名为台州站长论坛!希望大家继续支持和鼓励!(2008-04-10)    台州站长论坛原[社会琐碎]版块更名为[生活百科]版块!(2007-09-05)    特此通知:新台州站长论坛的数据信息全部升级成功!">特此通知:新台州站长论坛的数据信息全部升级成功!(2007-09-01)    台州站长论坛对未通过验证的会员进行合理的清除,请您谅解(2007-08-30)    台州网址导航|上网导航诚邀世界各地的网站友情链接和友谊联盟,共同引领网站导航、前进!(2007-08-30)    禁止发广告之类的帖,已发现立即删除!(2007-08-30)    希望各位上传与下载有用资源和最新信息(2007-08-30)    热烈祝贺台州站长论坛全面升级成功,全新上线!(2007-08-30)    
便民网址导航,轻松网上冲浪。
台州维博网络专业开发网站门户平台系统
您当前的位置: 首页 » MySQL/MSSQL编程 » 八个学习点帮助你全面认识Oracle数据库

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

论坛链接
  • 八个学习点帮助你全面认识Oracle数据库
  • 发布时间:2007-10-06 23:10:00    浏览数:6335    发布者:jinlj    设置字体【   
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;
娱乐休闲专区A 影视预告B 音乐咖啡C 英语阶梯D 生活百科
网页编程专区E AMPZF HTMLG CSSH JSI ASPJ PHPK JSPL MySQLM AJAX
Linux技术区 N 系统管理O 服务器架设P 网络/硬件Q 编程序开发R 内核/嵌入
管理中心专区S 发布网址T 版主议事U 事务处理