Sample Code used to create a tablespace in Oracle

Source: Internet
Author: User

The following articles mainly use the relevant Code to introduce how to create a tablespace in Oracle and grant permissions to users, the following describes how to view related permissions and how to create temporary tablespace in Oracle. We hope this will be helpful in your future study.

SQL code

 
 
  1. CREATE TEMPORARY TABLESPACE test_temp   
  2. TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf'   
  3. SIZE 32M   
  4. AUTOEXTEND ON   
  5. NEXT 32M MAXSIZE 2048M   
  6. EXTENT MANAGEMENT LOCAL;   
  7. CREATE TEMPORARY TABLESPACE test_temp  
  8. TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf'  
  9. SIZE 32M  
  10. AUTOEXTEND ON  
  11. NEXT 32M MAXSIZE 2048M  
  12.  

Extent management local; Oracle creates user tablespace

SQL code

 
 
  1. CREATE TABLESPACE test_data   
  2. LOGGING   
  3. DATAFILE 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\TEST_DATA01.DBF'   
  4. SIZE 32M   
  5. AUTOEXTEND ON   
  6. NEXT 32M MAXSIZE 2048M   
  7. EXTENT MANAGEMENT LOCAL;   
  8. CREATE TABLESPACE test_data  
  9. LOGGING  
  10. DATAFILE 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\TEST_DATA01.DBF'   
  11. SIZE 32M   
  12. AUTOEXTEND ON   
  13. NEXT 32M MAXSIZE 2048M  
  14.  

Extent management local; Delete tablespaces including physical data files)

SQL code

 
 
  1. drop tablespace egov0 including contents and datafiles;   
  2. drop tablespace egov0 including contents and datafiles;  

Create a user and customize a space in Oracle

SQL code

 
 
  1. CREATE USER username IDENTIFIED BY password   
  2. DEFAULT TABLESPACE TEST_DATA   
  3. TEMPORARY TABLESPACE TEST_TEMP;   
  4. CREATE USER username IDENTIFIED BY password  
  5. DEFAULT TABLESPACE TEST_DATA  
  6. TEMPORARY TABLESPACE TEST_TEMP;   

Empower users

SQL code

 
 
  1. GRANT   
  2. CREATE SESSION, CREATE ANY TABLE, CREATE ANY VIEW ,CREATE ANY INDEX, CREATE ANY PROCEDURE,   
  3. ALTER ANY TABLE, ALTER ANY PROCEDURE,   
  4. DROP ANY TABLE, DROP ANY VIEW, DROP ANY INDEX, DROP ANY PROCEDURE,   
  5. SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE, DELETE ANY TABLE   
  6. TO username;   
  7. GRANT   
  8. CREATE SESSION, CREATE ANY TABLE, CREATE ANY VIEW ,CREATE ANY INDEX, CREATE ANY PROCEDURE,  
  9. ALTER ANY TABLE, ALTER ANY PROCEDURE,  
  10. DROP ANY TABLE, DROP ANY VIEW, DROP ANY INDEX, DROP ANY PROCEDURE,  
  11. SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE, DELETE ANY TABLE  
  12. TO username;   

View User Permissions

View All Users

SQL code

 
 
  1. SELECT * FROM DBA_USERS;   
  2. SELECT * FROM ALL_USERS;   
  3. SELECT * FROM USER_USERS;   
  4. SELECT * FROM DBA_USERS;  
  5. SELECT * FROM ALL_USERS;  
  6. SELECT * FROM USER_USERS;   
  7.  

View User System Permissions

SQL code

 
 
  1. SELECT * FROM DBA_SYS_PRIVS;   
  2. SELECT * FROM USER_SYS_PRIVS;   
  3. SELECT * FROM DBA_SYS_PRIVS;  
  4. SELECT * FROM USER_SYS_PRIVS;   
  5.  

View user objects or role Permissions

SQL code

 
 
  1. SELECT * FROM DBA_TAB_PRIVS;   
  2. SELECT * FROM ALL_TAB_PRIVS;   
  3. SELECT * FROM USER_TAB_PRIVS;   
  4. SELECT * FROM DBA_TAB_PRIVS;  
  5. SELECT * FROM ALL_TAB_PRIVS;  
  6.  

SELECT * FROM USER_TAB_PRIVS; view all roles

SQL code

 
 
  1. SELECT * FROM DBA_ROLES;  

SELECT * FROM DBA_ROLES; view roles owned by a user or role

SQL code

 
 
  1. SELECT * FROM DBA_ROLE_PRIVS;   
  2. SELECT * FROM USER_ROLE_PRIVS;   
  3. SELECT * FROM DBA_ROLE_PRIVS;  
  4. SELECT * FROM USER_ROLE_PRIVS;   

Delete all tables created in the tablespace

SQL code

 

 
 
  1. Declare
  2. Vsql varchar2 (200 );
  3. Cursor c1 is
  4. Select 'drop table' | table_name | 'cascade constraints 'v_name
  5. From user_tables where tablespace_name = 'tablespace name ';
  6. BEGIN
  7. For I in c1 loop
  8. Vsql: = I. v_name;
  9. Execute immediate vsql;
  10. End loop;
  11. End;

The above content is related to creating tablespaces for Oracle, assigning permissions to users, and viewing the introduction of permissions. I hope you will get some benefits.

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.