您当前的位置: 首页 > 数据库教程 > Oracle教程 > 八个学习点帮助你全面认识Oracle数据库

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

作者:guanchaofeng 来源:不详 发布时间: 2009-09-30 08:38 点击:
TableSpace 表空间: 一个表空间对应多个数据文件(物理的dbf文件) 用语法方式创建tablespace,用sysdba登陆: --创建表空间mytabs,大小为10MB: createtablespacemytabsdatafile'C:\oracle\oradata\mydb\mytabs1.dbf'size10M;alteruserzgldefaulttablespacem

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

  TableSpace
  
  表空间:
  
  一个表空间对应多个数据文件(物理的dbf文件)
  
  用语法方式创建tablespace,用sysdba登陆:
  
  --创建表空间mytabs,大小为10MB:
  
  createtablespacemytabsdatafile'C:\oracle\oradata\mydb\mytabs1.dbf'size10M;alteruserzgldefaulttablespacemytabs;--把tabs做为zgl的默认表空间。grantunlimitedtablespacetozgl;--将操作表空间的权限给zgl。
  
  Exception
  
  示例:
  
  createorreplaceprocedurepro_test_exception(vidinvarchar2)isuserNamevarchar2(30);beginselectnameintouserNamefromt_userwhereid=vid;dbms_output.put_line(userName);exceptionwhenno_data_foundthendbms_output.put_line('没有查到数据!');whentoo_many_rowsthendbms_output.put_line('返回了多行数据!');endpro_test_exception;
  
  安全管理
  
  以下语句以sysdba登陆:
  
  用户授权:
  
  alteruserzglaccountlock;--锁定帐号。
  
  alteruserzglidentifiedbyzgl11;--修改用户密码。
  
  alteruserzglaccountunlock;--解除帐号锁定。
  
  alteruserzgldefaulttablespacett;--修改用户zgl的默认表空间为tt。
  
  createuserqqqidentifiedbyqqq123defaulttablespacett;--创建用户。
  
  grantconnecttoqqq;--给qqq授予connect权限。
  
  grantexecuteonzgl.proc01totest;--将过程zgl.proc01授予用户test。
  
  grantcreateusertozgl;--给zgl授予创建用户的权限。
  
  revokecreateuserfromzgl;--解除zgl创建用户的权限。
  
  角色授权:
  
  createrolemyrole;--创建角色myrole
  
  grantconnecttomyrole;--给myrole授予connect权限
  
  grantselectonzgl.t_usertomyrole;--把查询zgl.t_user的权限授予myrole
  
  grantmyroletotest;--把角色myrole授予test用户
  
  概要文件(配置文件):
  
  全局设置,可以在概要文件中设置登陆次数,如超过这次数就锁定用户。
  
  Synonym
  
  创建同义词示例:
  
  createpublicsynonymxxxformyuser.t_usercreatesynonymt_userformyuser.t_userselect*fromdba_synonymswheretable_name='T_USER'
  
  跨数据库查询
  
  createdatabaselinkdblinkzglconnecttomyuseridentifiedbyausing'mydb'Select*Fromt_user@dblinkzgl
  
  course示例
  
  示例1:
  
  createorreplaceprocedurepro_test_cursorisuserRowt_user%rowtype;cursoruserRowsisselect*fromt_user;beginforuserRowinuserRowsloopdbms_output.put_line(userRow.Id||','||userRow.Name||','||userRows%rowcount);endloop;endpro_test_cursor;
  
  示例2:
  
  createorreplaceprocedurepro_test_cursor_oneRow(vidinnumber)isuserRowt_user%rowtype;cursoruserCurisselect*fromt_userwhereid=vid;beginopenuserCur;fetchuserCurintouserRow;ifuserCur%FOUNDthendbms_output.put_line(userRow.id||','||userRow.Name);endif;closeuserCur;endpro_test_cursor_oneRow;
  
  record示例
  
  createorreplaceprocedurepro_test_record(vidinvarchar2)istypeuserRowisrecord(idt_user.id%type,namet_user.name%type);realRowuserRow;beginselectid,nameintorealRowfromt_userwhereid=vid;dbms_output.put_line(realRow.id||','||realRow.name);endpro_test_record;
  
  rowtype示例
  
  createorreplaceprocedurepro_test_rowType(vidinvarchar2)isuserRowt_user%Rowtype;beginselect*intouserRowfromt_userwhereid=vid;dbms_output.put_line(userRow.id||','||userRow.name);endpro_test_rowType;

分享到:
本文"八个学习点帮助你全面认识Oracle数据库"由远航站长收集整理而来,仅供大家学习与参考使用。更多网站制作教程尽在远航站长站。
顶一下
(0)
0%
踩一下
(0)
0%
[点击 次] [返回上一页] [打印]
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
关于本站 - 联系我们 - 网站声明 - 友情连接- 网站地图 - 站点地图 - 返回顶部
Copyright © 2007-2013 www.yhzhan.com(远航站长). All Rights Reserved .
远航站长:为中小站长提供最佳的学习与交流平台,提供网页制作与网站编程等各类网站制作教程.
官方QQ:445490277 网站群:26680406 网站备案号:豫ICP备07500620号-4