oracle 常用指令

--授权pkg_gps_audit 包给用户simmon

grant execute on pkg_gps_audit to simmon

 

 

--删除simmon访问pkg_gps_audit 的 权限

revoke execute on pkg_gps_audit from simmon

 

 

 

--创建临时表指令
create global temporary table
 test232(id number(10) primary key,name varchar2(100) not null)
  on commit delete rows;
 
 
--带有rollup操作符的group by用于产生 一个包含常规分组行和小计行的结果集(常用于统计报表),
--带有cube操作符的group by 用于产生group by 子句中所指定的分组的所有可能组合(常用于统计报表)
--例如:
select code,sum(price) from economy group by cube(code);
select code,name,sum(price) from economy group by cube(code,name);

select code sum(price) from economy group by rollup(code);
select code,name,sum(price) from economy group by rollup(code,name);

--union,union all,minus,intersect常用的集合操作字符
select id  from test_temp minus select id   from test_temp2; --交集
select id from test_temp union select id from test_temp2; --并集
select id from test_temp intersect select id from test_temp2 ; --除去交集部分的并集
select * from test_temp where id in (select id from test_temp minus select id from test_temp2) ;


--事务锁
begin
  select * from test_temp where id = 2 for update wait 10;
  update test_temp set name = 'yoncher' where id= 2;
  commit;
 
exception when others then rollback;
end;


--同义词synonym
 grant all on account to myspace; --授权account表给myspace用户
 create or replace synonym account for tempuser.account; --创建tempuser用户的account表的同义词
 create or replace synonym account for account@tempuser_102; --创建tempuser_102的DB_LINK的同义词
 drop synonym account; --删除同义词


--创建视图
--视图的优点:
--1、可以将几张相关联的表数据,简单化成一个视图,以方便其他的用户使用数据,而不用关心数据是如何产生的。
--2、同时,视图也提供了一外一种安全级别措施,确保数据的安全性。
--以下是使用视图时应该注意的几个要点:
--A)视图的查询不能选择伪列,如currval 和nextval。
--B)如果视图的查询中包含联系(键保留表除外)、集合操作符、分组函数或distinct子句,则不能执行删除、更新和插入删除。
--C)在视图中所作的修改将影响基表,反之亦然。
drop table order_master;
create table order_master(
  orderno varchar2(5) primary key,
  odate date,
  vencode varchar2(5),
  ostatus char(1),
  del_date date

);
 

drop table order_detail;
create table order_detail(
  itemcode varchar2(5) primary key,
  qty_ord number(5),
  qty_deld number(5),
  orderno varchar2(5),
  foreign key(orderno) references order_master(orderno)
);

insert into order_master values('a001',sysdate,'CHINA','p',sysdate);
insert into order_detail values('b10',200,200,'a001');

create or replace view orders as
select o.orderno,o.odate,o.vencode,d.itemcode,d.qty_ord
from order_master o,order_detail d
where o.orderno = d.orderno
with check option;  --还有另外一个模式with read only,只读模式,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值