数据对象和权限

1、grant create session to   t2;

2、conn t3/t2;

3、conn t1/t1;

4、conn t2/t2;

5、grant create table to t3;

6、revoke from 

7、grant  to

角色  role

 

系统

对象

 

8、DML:删改查增  数据操作

     DDL:数据定义

9、grant create table to t2 with admin option;

10、grant create table to t3;

11、

dba   --->   t1

admin option

t1 ---> t2

没有admin

dba ---> t1 ---> t2 ---> t3

  adm  adm

dba

revoke create table from t1;

conn t2/t2;

create table tttt(id number(10));

系统权限给出去就收不回了;

select table_name from user_tables;

drop table tt;

drop table t;

conn / as sysdba;

alter user t3 identified by t3;

conn / as sysdba;

show user;

desc test;

insert into test values (sysdate(), ‘AAAA’);

select * from test;

select * from sys.test;

grant select on test to  t1;

select * from sys.test;

grant select on test to t2;

revoke select on test from t1;

grant select on test to t1 with grant option;

grant select on test to t2;

grant select on sys.test to t2;

select * from sys.test;

grant select on test to t2;

grant select on sys.test to t2;

revoke select on test from t1;

grant select on test to t1 with grant option;

--------------------------------------------------------

一组权限的组合   Roles

select table_name from dict where table_name like '%PRIV%';

desc USER_SYS_PRIVS;

select username from USER_SYS_PRIVS;

select unique(username) from USER_SYS_PRIVS;

select count(1) from USER_SYS_PRIVS;

grant connect, resource to t1;

 

select table_name from dict where table_name like '%PROFILE%';

select resource_name, limit from dba_profiles;

userprofile;

Schema

方案

结构

模式

纲要

用户对象的集合---Schema

create  public synonym test for  sys.test;

 约束

constraint

主外键

primary key

foreign key   | reference key

范式

formative

约束类型:

    非空  not null,唯一  unique, 条件   check

    主键   primary key (非空、唯一、index)

    外键   foreign key    (reference key)

 

两张表,有主表,子表,有主外键关系

主表不能删,可以子表去删。

级联删除,如果子表删,主表对应内容要删,建外键约束时,要 on delete cascade

create table test (id number primary key,  day date) ;

alter table add constraint PR_NAME primary key (id);

alter table add constraint PR_NAME foreign key (id) reference P_table (P_column);

 

约束属性开关   able validate, 但是  disable validate 是没有的

alter table modify constraint PR_NAME enable validate;

对于约束的检验  在什么时候?commit活语句发生时?

alter table p1 modify constraint uni_id unique(region_id) INITIALLY DEFERRED;

alter table p1 modify constraint uni_id INITIALLY NONDEFERRED;

 

删除约束

alter table drop constraint Con_name

--------------------------------------------------------

约束笔记:

--------------

约束类型:
  非空not null,唯一unique, 条件 check
 主键 primary key (非空,唯一,index)
 外键 foreign key (reference)

两张表,有主表,子表,有主外键关系
主表不能删,可以子表去删。
级联删除,如果字表删,主表对应内容要删,建外键约束时,要 on delete cascade
create table test (id number primary key,day date);
alter table add consraint PR_NAME primary key (id);
alter table add consraint PR_NAME foregin key (id) reference P_table (P_column);

约束属性开关 able validate 四种组合三种有效,但是 disable validate 无效的
alter table modify consraint PR_NAME enable validate;
 
对于约束的检验 在什么时候?commit或语句发生时?
alter table p1 add constraint uni_id unique(region_id) INITIALLY DEFERRED;
alter table p1 modify constraint uni_id INITIALLY NONDEFERRED;

删除约束
alter table drop constraint Con_name
--------------------------------------------------------------

drop  table p1;

drop table p2 purge;   --  进回收站

 

posted @ 2019-04-27 11:21  zhouhaiwu  阅读(381)  评论(0编辑  收藏  举报