<b>八个学习点帮忙你全面熟习Oracle数据库</b>[Oracle防范]
本文“<b>八个学习点帮忙你全面熟习Oracle数据库</b>[Oracle防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
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; |
以上是“<b>八个学习点帮忙你全面熟习Oracle数据库</b>[Oracle防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |