Oracle学习笔记(四)
来源:asp之家 发布时间:2012-01-05 18:57:33
一、控制用户存取
1、创建修改用户Creating Users
Create/alter user new_user identified by password;
例:create user user_1 indentified by pwd_1
alter user user_1 identified by pwd_2
2、给用户授予权限
grant privilege[,privilege] to user [,user|role,public...]
一些系统权限:
create session/table/sequence/view/procedure
alter/delete/execute/index/insert/references/select/update
grant object_priv [(columns)]
on object
to {user|role|public}
[with grant option]
例如:
给用户user_1授予查询tt1表的权限
grant select on tt1表 to user_1
给用户user_1授予修改“表1”中(列1,列2)的权限
grant update(列1,列2) on 表1 to user_1;
给用户user_1 授予查询权限并可以把该权限授予其他用户的权限
grant select
on tt1表
to user_1
with grant option
把权限授予所有用户
grant select
on 表1
to public;
给用户user_1授权
grant create session to user_1;
二、创建角色并给角色授权
1、创建角色
create role mangager;
例如:create role test_role1;
2、给角色授权
grant create table,create view to manager;
例如:grant create table to test_role1;
3、把角色授予用户
grant manager to user_1,user_2...
grant test_user1 to user_1;
三、取消用户权限
revoke {privilege [,privilege...]|all}
on object
from {user[,user...]|role|public}
[cascade constraints];
revoke select on 表1 from user_1;
四、Database Links
create public database link hq.acme.com using 'sales';
select * from emp@hq.acme.com;
五、 oracle取并集、交集、差集
所取的列的数据类型必须兼容
1、取并集
union :会对数据排序,重复记录压缩,union all不会
select employee_id,job_id from employess
union
select employee_id,job_id from job_history;
取所有并集不去除重复数据
select employee_id,job_id from employess
union all
select employee_id,job_id from job_history;
2、取交集
select employee_id,job_id from employess
intersect
select employee_id,job_id from job_history;
3、差集
表employess去掉共同拥有的数据
select employee_id,job_id from employess
minus
select employee_id,job_id from job_history;
六、日期时间函数
求时差
select tz_offset('US/Eastern') from dual;
alter session set time_zone='-8:0';
select sessiontimezone,current_date from dual;
alter session set time_zone='-8:0';
select sessiontimezone,current_timestamp from dual;
alter session set time_zone='-8:0';
select current_timestamp,localtimestamp from dual;
select dbtimezone,sessiontimezone from dual;
select from_tz(timestamp'2000-03-23 08:00:00','3:00') from dual;
select to_timestamp('2000-02-01 11:00:00','YYYY-MM-DD HH:MI:SS')from dual;
select to_timestamp_tz('2000-02-01 11:00:00','YYYY-MM-DD HH:MI:SS TZH:TZM')from dual;
to_ymininterval()
猜你喜欢
- 我的长博文不少,比较影响阅读体验,有必要添加一个文章目录功能。相比 Wordpress, Typecho 的插件就比较少了。我想找一个像掘金
- MaxDB和MySQL是独立的数据库管理服务器。系统间的协同性是可能的,通过相应的方式,系统能够彼此交换数据。要想在MaxDB和MySQL之
- 代码如下:CREATE FUNCTION [dbo].[udf_DaysInMonth] ( @Date DATETIME )
- 数字序号① ①② ②③ &
- 在使用ASP来进行后端的数据合法性校验的时候,有些人为满足不同环境下面的数据校验,编写了很多的函数来实现,比如,我们想要校验用户输入的URL
- 好记星不如烂笔头,适时的总结梳理知识让人更轻松愉快。今天总结下学习和开发中遇到的JavaScript执行顺序的问题,今天挖个坑,以后会慢慢填
- 最近随着狂风计划的席卷,我也终于开始橱窗产品位列表展示的编码工作,这只是一个改进项目,因此有原代码可供参考。但是当我打开原代码模板的时候便愣
- 我从11岁开始编程,并且一直都很喜欢技术和编程。这些是我一直以来获得的经验教训。作为一个程序员,你可能需要这样的忠告。我更希望每个人在获取这
- 以下以 IE 代替 Internet Explorer,以 MF 代替 Mozzila FF1. document.form.item 问题
- XPath(XML Path language)是一种处理XML文档段的语言。XSLT(Extensible Stylesheet Lang
- 事实上,互联网用户浏览网页的习惯和顾客浏览商店中物品的习惯没有多大差别。用户打开一个新的页面,扫视一些文字,并点击第一个引起他兴趣的链接。在
- 解决MySQL中文乱码的问题看到从数据库中取出的数据全部是“?????”,太让人郁闷了。网上有很多方法来解决这个问
- 内容摘要:MySQL易学易用,附带丰富的技术文档,这两个因素使之被广泛应用。然而,随着MySQL发展加快,即使一个MySQL老手有时也会为该
- 需要写个js滑动展开折叠(收缩)的效果,搜索到无忧脚本的一篇贴子,稍加修改了下使其在FF也可应用,代码如下: <
- SQL是用于访问ORACLE数据库的语言,PL/SQL扩展和加强了SQL的功能,它 同时引入了更强的程序逻辑。 PL/SQL支持DML命令和
- 从MySQL 5.0.2开始,通过mysql_stmt_attr_set() C API函数实现了服务器端光标。服务器端光标允许在服务器端生
- 微软在去年可谓是动作比较大的一年,在去年3月份推出了最新版的IE8浏览器,而在年底又发布全新的操作系统Windows 7,自此新产品的市场占
- 问题描述:使用 SQL 2005 w/ SP2 的汇出汇入精灵将数据从 Access 汇入到 SQL2005 发生了错误,但使用在SQL 2
- 这是一个网页设计中经常会用到的图片特效,实现多个图片之间的轮换,并分别带有连接。以前的代码只能适用于IE,在FF下始终没有得到很好的解决今天
- 阅读上一章:Chapter 7 锚点 Chapter 8 再谈清单先前在第一章,我们讨论过几种标记清单的做法,研究以<ul>和&