oracle 用户管理
系统权限: 回收时不会产生级联回收
conn / as sysdba;
create user t1 identified by t1;
create user t2 identified by t2;
grant connect to t1,t2;
grant create table, create view to t1 with admin option;
conn t1/t1
grant create table to t2;
conn / as sysdba;
select * from dba_sys_privs where grantee in('T1', 'T2');
GRANTEE PRIVILEGE ADM
------------------------------ ---------------------------------------- ---
T1 CREATE TABLE YES
T1 CREATE VIEW YES
T2 CREATE TABLE NO
with admin option 可使被授予权限者有权转授其他人。
revoke create table, create view from t1;
select * from dba_sys_privs where grantee in('T1', 'T2');
GRANTEE PRIVILEGE ADM
------------------------------ ---------------------------------------- ---
T2 CREATE TABLE NO
不会级联删除已经授予的系统权限。
对象权限:级联回收所有权限
conn test/test
grant select on t to t1 with grant option;
conn t1/t1
grant select on test.t to t2;
conn test/test
select * from dba_tab_privs where grantee in('T1', 'T2');
GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE
------------------------------ ------------------------------ ------------------------------ ------- --------------------------------
T2 TEST T T1 SELECT
T1 TEST T TEST SELECT
revoke select on t from t1;
select * from dba_tab_privs where grantee in('T1', 'T2');
SQL> select * from dba_tab_privs where grantee in('T1', 'T2');
级联删除已经授予的对象权限。
角色权限:级联回收所有权限
create role ttt;
grant create table, create user, create session to ttt with admin option;
grant select on test.t to ttt with grant option;
SQL> grant select on test.t to ttt with grant option;
grant select on test.t to ttt with grant option
ORA-01926:
无法使用with grant option选项给角色授权。
grant select on test.t to ttt;
create user d identified by d;
create user e identified by e;
grant ttt to d with admin option;
conn d/d
grant ttt to e;
select * from test.t;
SQL> select * from test.t;
conn / as
相关文档:
1,列出最低薪金大于1500的各种工作及从事此工作的全部雇员人数。
select job,count(empno) from emp
where job in(select job from emp group by job having min(sal)>1500)
group by job;
2,列出薪金高于公司平均薪金的所有员工所在部门,上级领导,公司的工资等级。
select e.ename,d.dname,m.ename,e.sal,sa. ......
创建表
create table person (pid int,name varchar2(20) unique,
age int check(age between 0 and 150),sex varchar(4) default '男',tp int,
address varchar(200),constraint person_pid_pk primary key(pid));
插入数据
insert into person values(0011,'刘三姐',25,'男',13930123021,'河北省曲阳县');
创建子表 ......
Oracle中start with…connect by prior子句用法
connect by 是结构化查询中用到的,其基本语法是:
select … from tablename
start with 条件1
connect by 条件2
where 条件3;
例:
select * from table
start with org_id = ‘HBHqfWGWPy’
connect by prior org_id = parent_id;
  ......
oracle如何记录用户的登陆信息
可以做一个触发器
用以下的方式可以监控登入登出的用戶:
创建一张记录登录TABLE,如下:
CREATE TABLE SYSTEM.LOGIN_LOG
(
SESSION_ID &nb ......
教你用Linux完成Oracle自动物理备份
http://www.cngr.cn/article/63/390/2006/2006071919004.shtml
本文的目标是通过执行一Shell脚本来完成Oracle数据库自动备份的全过程,而且能够在当前目录下生成其压缩文件。具体实现步骤如下:
1.以Oracle用户身份登录到Linux系统下。
2.建立database.srcipt文 ......