search
HomeDatabaseMysql TutorialOracle--用户管理与权限分配

以下都是用结合例子来理解Oracle的知识点 用户登录 (跳开用户名和密码登录) : sqlplus /nolog connect / as sysdba 一.用户 1.

以下都是用结合例子来理解Oracle的知识点

用户登录 (跳开用户名和密码登录)  :

sqlplus /nolog

connect / as sysdba

一.用户

1.    创建用户(例子)

create user olay identified by 123;

2.  删除用户(连同用户所拥有的对象一起删除)

drop user olay cascade;

3  .修改用户密码(口令)

alter user olay identified by 123456;

4.  解锁被锁的用户

alter user olay account unlock;

二:表空间

1  .创建表空间(创建一个用户为olay,口令为123,并设置默认表空间为users,临时表空间为temp)

create user olay identified by 123 default  tablespace  users  temporary  tablespac  e temp;

如果该用户在users表空间上最多可使用大小为10MB,则

create user olay identified by 123 default tablespace users temporary tablespace temp

quota  10m on users;

如果该用户使用users表空间不受大小控制,则

create user olay identified by 123 default tablespace users temporary tablespace temp 

          quota  unlimited on users;

注:如果要禁用用户使用某个表空间,,则通过quota 设置限额为0即可

2.    删除表空间(XXX为表空间名)

drop tablespace    XXX    including      contents    and    datafiles;

温馨提示:

在创建完用户之后,需要注意一下几点:

1.    如果创建用户时不指定默认表空间,oracle会将System 表空间作为用户默认表空间

2.  如果创建用户时不指定临时表空间,oracle会将默认表空间作为用户的临时表空间

3.    初始建立用户时没有任何权限的,必须授权后才可操作

4.    如果建立用户没有为设置用户在表空间的使用大小,那么用户在该表空间的配额为0

三:用户权限管理

oracle数据库中将权限分为两大类:系统权限和对象权限

以下分别介绍着两种权限

1    系统权限

(1)系统权限是指执行特定类型sql命令的权利。它用于控制用户可以执行的一个或是一组数据库操作

oracle提供了160多种系统权限,常用有:

create session  连接数据库            create table  建表        create view  建视图      create public synonym  建同义词

create procedure  建过程 函数  包              create trigger  建触发器          create cluster  建簇

更多的可以查数据字典(system_privilege_map)

            select * from system_privilege_map order by name;

(2)授权

如果数据库管理员用grant 命令给用户A授予系统权限时带有with  admin  option,则该用户A就有权限将系统授予的权限授予给用户B。在这种情况下,

如果管理员使用revoke命令撤销A用户的系统权限,则用户B的系统权限仍然有效(这点有区别与对象权限)

案例:创建两个用户ken,tom。system给用户ken授予(create session 和  create table)两个权限 并且授予时带 with  admin  option

grant  create session, create table to ken  with  admin  option;

此时ken就可以把它得到的两个权限继续向别的用户转发。这样就可以登陆ken用户给tom授权了

回收系统权限

revoke create session, create table  from    ken;

2.  对象权限

指访问其它方案对象的权利,用户可以直接访问自己方案的对象,但是如果要访问别的方案的对象,就必须具有访问该对象的权限

常用的对象权限有:

alter  delete    select    insert          update          index(索引)        references(引用)    execute(执行)

更多可以查看oracle提供的所有对象权限

select distinct  privilege  from aba_tab_privs;

比如smith用户要访问scott.emp表(scott:方案 ,emp:表)  ,则必须在scott.emp表上具有对象的权限。

grant  select , insert , delete on scott.emp to  smith;

回收对象权限

revoke select , insert , delete on scott.emp  from  smith;

温馨提示:

如果数据库管理员用revoke命令回收A用户的对象权限,用户B的对象权限也被回收。

参考阅读:

Oracle教程:用户管理的备份

推荐阅读:

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are stored procedures in MySQL?What are stored procedures in MySQL?May 01, 2025 am 12:27 AM

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

How does query caching work in MySQL?How does query caching work in MySQL?May 01, 2025 am 12:26 AM

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

What are the advantages of using MySQL over other relational databases?What are the advantages of using MySQL over other relational databases?May 01, 2025 am 12:18 AM

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.