源码-Oracle数据库管理-第十九章-数据库安全性管理-Part 1_1(用户管理)

哈哈,总算熬到了最后一篇:Oracle维护。

这部分内容在目前的工作中基本没用到过,因为咱不是DBA。

但实际上这些内容是最基本的,多了解一些肯定有用,“撸起袖子干!”奋斗

--20170213
--第5篇 Oracle维护
--第19章 数据库安全性管理
--19.1 用户管理
--19.1.1 用户与方案简介

--方案是指特定用户拥有的数据库对象的集合
--sys账户:可以执行所有数据管理任务,存储数据字典的基表和视图
--system账户:可以执行所有数据管理任务,存储一些用于显示管理信息的表和视图
system_pd@ORCL> show user
USER 为 "SYSTEM"
system_pd@ORCL> conn sys as sysdba
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
sys_pd@ORCL

sys_pd@ORCL> show user
USER 为 "SYS"
sys_pd@ORCL> --最少权限原则:只对需要的功能分配权限
sys_pd@ORCL> --用户类型:普通用户(拥有对自己创建的对象的权限);特权用户(sysdba/sysoper等用户,可对数据库进行管理)
sys_pd@ORCL> --19.1.2 创建用户
sys_pd@ORCL> create user pdh identified by 123;

用户已创建。

sys_pd@ORCL> select default_tablespace, temporary_tablespace
  2  from dba_users
  3  where username='PDH';

DEFAULT_TABLESPACE
------------------------------------------------------------
TEMPORARY_TABLESPACE
------------------------------------------------------------
USERS
TEMP


sys_pd@ORCL> select property_value from database_properties where peroperty_name='DEFAULT_PERMANENT_TABLESPACE';
select property_value from database_properties where peroperty_name='DEFAULT_PERMANENT_TABLESPACE'
                                                     *
第 1 行出现错误:
ORA-00904: "PEROPERTY_NAME": 标识符无效


sys_pd@ORCL> select property_value from database_properties where property_name='DEFAULT_PERMANENT_TABLESPACE';

PROPERTY_VALUE
----------------------------------------------------------------------------------------------------
USERS

sys_pd@ORCL> conn pdh
ERROR:
ORA-01045: user PDH lacks CREATE SESSION privilege; logon denied


警告: 您不再连接到 ORACLE。
sys_pd@ORCL> conn pdh
ERROR:
ORA-01045: user PDH lacks CREATE SESSION privilege; logon denied


sys_pd@ORCL> grant create session to pdh
  2  ;
SP2-0640: 未连接
sys_pd@ORCL> conn system
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
system_pd@ORCL

system_pd@ORCL> grant create session to pdh
  2  ;

授权成功。

system_pd@ORCL> conn pdh/123;
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
pdh_pd@ORCL

pdh_pd@ORCL> --创建一个永久表空间data_ts_temp,初始大小为50MB,采用本地段管理,并且会自动增长空间
pdh_pd@ORCL> create tablespace data_ts_temp datafile '/home/oracle/data_ts_temp.dbf' size 50M
  2  extent management local
  3  segement space management auto;
segement space management auto
*
第 3 行出现错误:
ORA-02180: 无效的 CREATE TABLESPACE 选项


pdh_pd@ORCL> create tablespace data_ts_temp datafile '/home/oracle/data_ts_temp.dbf' size 50M
  2  extent management local
  3  segment space management auto;
create tablespace data_ts_temp datafile '/home/oracle/data_ts_temp.dbf' size 50M
*
第 1 行出现错误:
ORA-01031: 权限不足


pdh_pd@ORCL> conn system
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
system_pd@ORCL

system_pd@ORCL> create tablespace data_ts_temp datafile '/home/oracle/data_ts_temp.dbf' size 50M
  2  extent management local
  3  segment space management auto;
create tablespace data_ts_temp datafile '/home/oracle/data_ts_temp.dbf' size 50M
*
第 1 行出现错误:
ORA-01119: 创建数据库文件 '/home/oracle/data_ts_temp.dbf' 时出错
ORA-27040: 文件创建错误, 无法创建文件
OSD-04002: ???????
O/S-Error: (OS 3) The system cannot find the path specified.


system_pd@ORCL> create tablespace data_ts_temp datafile 'd:/sql/data_ts_temp.dbf' size 50M
  2  extent management local
  3  segment space management auto;

表空间已创建。

system_pd@ORCL> --创建用户并指定默认表空间(如果不指定,则将使用system表空间作为默认表空间,有可能导致数据库崩溃)
system_pd@ORCL> creater user hpd
SP2-0734: 未知的命令开头 "creater us..." - 忽略了剩余的行。
system_pd@ORCL> create user hpd identified by
  2  123
  3  default tablespace data_ts_temp
  4  quota 500k on data_ts_temp
  5  temporary tablespace temp;

用户已创建。

system_pd@ORCL> select default_tablespace from dba_users where username='HPD';

DEFAULT_TABLESPACE
------------------------------------------------------------
DATA_TS_TEMP

system_pd@ORCL> conn hpd/123
ERROR:
ORA-01045: user HPD lacks CREATE SESSION privilege; logon denied


警告: 您不再连接到 ORACLE。
system_pd@ORCL> conn pdh/123
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
pdh_pd@ORCL

pdh_pd@ORCL> create table temp as (select 25*25 from dual);
create table temp as (select 25*25 from dual)
                               *
第 1 行出现错误:
ORA-00998: 必须使用列别名命名此表达式


pdh_pd@ORCL> create table temp as (select 25*25 quickCal from dual);
create table temp as (select 25*25 quickCal from dual)
                                                 *
第 1 行出现错误:
ORA-01031: 权限不足


pdh_pd@ORCL> conn system
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
system_pd@ORCL

system_pd@ORCL> grant create table to pdh;

授权成功。

system_pd@ORCL> conn pdh/123
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
pdh_pd@ORCL

pdh_pd@ORCL> create table temp as (select 25*25 quickCal from dual);
create table temp as (select 25*25 quickCal from dual)
                                                 *
第 1 行出现错误:
ORA-01950: 对表空间 'USERS' 无权限


pdh_pd@ORCL> grant create session, create table to hpd;
grant create session, create table to hpd
*
第 1 行出现错误:
ORA-01031: 权限不足


pdh_pd@ORCL> conn system
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
system_pd@ORCL

system_pd@ORCL> grant create session, create table to hpd;

授权成功。

system_pd@ORCL> conn hpd/123
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
hpd_pd@ORCL

hpd_pd@ORCL> create table temp as (select 25*25 quickCal from dual);

表已创建。

hpd_pd@ORCL> select * from temp;

  QUICKCAL
----------
       625

hpd_pd@ORCL> --19.1.3 修改用户
hpd_pd@ORCL> conn system
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
system_pd@ORCL

system_pd@ORCL> alter user hpd identified by 321
  2  ;

用户已更改。

system_pd@ORCL> conn hpd/321;
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
hpd_pd@ORCL

hpd_pd@ORCL> --创建临时表空间
hpd_pd@ORCL> conn system
已连接。

GLOBAL_NAME
----------------------------------------------------------------------------------------------------
system_pd@ORCL

system_pd@ORCL> create temporary tablesapce temp_ts_temp tempfile 'd:/sql/temp_ts_temp.dbf';
create temporary tablesapce temp_ts_temp tempfile 'd:/sql/temp_ts_temp.dbf'
       *
第 1 行出现错误:
ORA-00901: 无效 CREATE 命令


system_pd@ORCL> create temporary tablespace temp_ts_temp tempfile 'd:/sql/temp_ts_temp.dbf';
create temporary tablespace temp_ts_temp tempfile 'd:/sql/temp_ts_temp.dbf'
*
第 1 行出现错误:
ORA-01119: 创建数据库文件 'd:/sql/temp_ts_temp.dbf' 时出错
ORA-17610: 文件 'd:/sql/temp_ts_temp.dbf' 不存在, 大小也未指定
ORA-27041: 无法打开文件
OSD-04002: ???????
O/S-Error: (OS 2) The system cannot find the file specified.


system_pd@ORCL> create temporary tablespace temp_ts_temp tempfile 'd:/sql/temp_ts_temp.dbf';
create temporary tablespace temp_ts_temp tempfile 'd:/sql/temp_ts_temp.dbf'
*
第 1 行出现错误:
ORA-01119: 创建数据库文件 'd:/sql/temp_ts_temp.dbf' 时出错
ORA-17610: 文件 'd:/sql/temp_ts_temp.dbf' 不存在, 大小也未指定
ORA-27041: 无法打开文件
OSD-04002: ???????
O/S-Error: (OS 2) The system cannot find the file specified.


system_pd@ORCL> create temporary tablespace temp_ts_temp tempfile 'd:/sql/temp_ts_temp.dbf' size 50m;

表空间已创建。

system_pd@ORCL> --为用户指定表空间
system_pd@ORCL> alter user pdh default tablespace data_ts_temp
  2  temporary tablespace temp_ts_temp;

用户已更改。

system_pd@ORCL> select default_tablespace, tempoary_tablespace from dba_users where username='PDH';
select default_tablespace, tempoary_tablespace from dba_users where username='PDH'
                           *
第 1 行出现错误:
ORA-00904: "TEMPOARY_TABLESPACE": 标识符无效


system_pd@ORCL> select default_tablespace, temporary_tablespace from dba_users where username='PDH';

DEFAULT_TABLESPACE
------------------------------------------------------------
TEMPORARY_TABLESPACE
------------------------------------------------------------
DATA_TS_TEMP
TEMP_TS_TEMP


system_pd@ORCL> spool out

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值