Oracle学习笔记(四)
发布时间:2024-01-28 20:00:57
一、控制用户存取
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()


猜你喜欢
- 要想成功的进行字符串的匹配需要使用到正则表达式模块,正则表达式匹配规则以及需要被匹配的字符串。在这三个条件中,模块与字符串都是准备好的,只有
- 本文实例为大家分享了python画条形图的具体代码,供大家参考,具体内容如下在做毕设的过程中有些数据用表格来展现,会很难看出数据之间的差别,
- 如果需要一个简单的Web Server,而不是安装那些复杂的HTTP服务程序,比如:Apache,Nginx等。那么可以使用Python自带
- 已解决卸载pip重新安装的方法问题需求粉丝群里面的一个小伙伴遇到问题跑来私信我,想用卸载pip重新安装pip,但是发生了报错(当时他心里瞬间
- 1)doctest 使用doctest是一种类似于命令行尝试的方式,用法很简单,如下 def f(n): ""
- 简介Django数据库连接超过wait_timeout导致连接丢失时自动重新连接数据库https://github.com/zhanghao
- 本文为大家分享了python实现学生管理系统的具体代码,供大家参考,具体内容如下1.0版本学生管理系统''' 1.添
- 今天写爬虫偶然想到了初学正则表达式时候,看过一篇文章非常不错。检索一下还真的找到了。re模块re.search经常用match = re.s
- 感谢Mr.Cool 给asp之家投递精彩的文章!站长你好,我经常光临你的站点,因为我也特别喜欢ASP写网页,你的站点上提供的代码比较适用哈,
- dlib包安装失败 python安装dlib时报错:Running setup.py install for dlib &helli
- Python 类Python中的类提供了面向对象编程的所有基本功能:类的继承机制允许多个基类,派生类可以覆盖基类中的任何方法,方法中可以调用
- phpMyAdmin是一个用PHP编写的,可以通过互联网控制和操作MySQL。通过phpMyAdmin可以完全对数据库进行操作,例如建立、复
- 本文实例讲述了Python实现简单求解给定整数的质因数算法。分享给大家供大家参考,具体如下:接着做题遇到求解质因数分解的问题,思想很简单,就
- 一、系统简介实现一个学生信息的管理系统:主要功能有:添加学生信息删除学生信息修改学生信息查询学生信息显示学生信息退出当前系统二、步骤分析显示
- 本文实例讲述了Java使用正则表达式截取重复出现的XML字符串功能。分享给大家供大家参考,具体如下:public static void m
- 泛型,如果你学过Java ,应该对它不陌生吧。但你可能不知道在 Python 中(3.4+ ),也可以实现简单的泛型函数。在Python中只
- 首先比较下return 与 yield的区别:return:在程序函数中返回某个值,返回之后函数不在继续执行,彻底结束。yield: 带有y
- 在日常工作中,我们常常会用到需要周期性执行的任务,一种方式是采用 Linux 系统自带的 crond 结合命令行实现,另外一种方式是直接使用
- 如下所示:# coding = GBKa =[1,2,3,4,5]sum=0b = len(a)print("这个数组的长度为:&
- HTML实体符号被用作实现保留字符(reserved characters)或者表达键盘无法输入的一些常用字符。在大多数浏览器中默认的字符集