Restrict DBA-level users to create tables in any tablespace

Source: Internet
Author: User
Generally, database users are granted the connect, resource, and DBA roles. Users with these permissions can perform operations conveniently but arbitrarily. It is common to create an object in the users tablespace. I think of a technical method. The procedure is as follows:
Step 1: create a user and handle Permissions

SQL> Conn/As sysdba
Connected.
SQL> create user usr_xx identified by usr_xx default tablespace tbs_yy;

User Created.

SQL> grant connect, resource, DBA to usr_xx;

Grant succeeded.

SQL> revoke unlimited tablespace from usr_xx;

Revoke succeeded.

Key Point: cancel the unlimited tablespace system permission. After cancellation, the new user has no quota in any tablespace.
Therefore, the creation of objects in any tablespace is objectively restricted.

Step 2: Test the effect

SQL> conn usr_xx/usr_xx
Connected.
SQL> Create Table t_yy (a date, B number, C varchar2 (10 ));
Create Table t_yy (a date, B number, C varchar2 (10 ))
*
Error at line 1:
ORA-01950: no privileges on tablespace 'tbs _ yy'

The table cannot be created on the default tablespace.

Step 3: grant the table space quota

SQL> Conn/As sysdba
Connected.
SQL> alter user usr_xx quota unlimited on tbs_yy;

User altered.

SQL> conn usr_xx/usr_xx
Connected.
SQL> Create Table t_yy (a date, B number, C varchar2 (10 ));

Table created.

You can create a table in the default tablespace. We will test the operations for creating tables in other tablespaces.

SQL> Create Table t_yy_users (a date, B number, C varchar2 (10) tablespace users;
Create Table t_yy_users (a date, B number, C varchar2 (10) tablespace users
*
Error at line 1:
ORA-01950: no privileges on tablespace 'users'

The results show that it cannot be created in other empty table spaces.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.