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.