SoFunction
Updated on 2025-04-08

Oracle creates tablespaces and user methods

1. Create table space and user (document mode)

user

Establish:create user username identified by "password";
Authorization:grant create session to username;
            grant create table to  username;
            grant create tablespace to  username;
            grant create view to  username;

Tablespace

Create a table space (usually create N table spaces that store data and an index space):

create tablespace Tablespace name
datafile ' path(要先建好path)\***.dbf  ' size *M
tempfile ' path\***.dbf ' size *M
autoextend on  --Automatic growth
--There are also some commands that define sizes,See if you need it
 default storage(
 initial 100K,
 next 100k,
);

Example: Create a tablespace

create tablespace DEMOSPACE 
datafile 'E:/oracle_tablespaces/DEMOSPACE_TBSPACE.dbf' 
size 1500M 
autoextend on next 5M maxsize 3000M;
Delete tablespace
drop tablespace DEMOSPACE including contents and datafiles

User permissions

Grant user permissions to use tablespaces:

alter user username quota unlimited on Tablespace;
or alter user username quota *M on Tablespace;

2. Complete example (lazy mode)

--Tablespace
CREATE TABLESPACE sdt
DATAFILE 'F:\tablespace\demo' size 800M
         EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; 
--索引Tablespace
CREATE TABLESPACE sdt_Index
DATAFILE 'F:\tablespace\demo' size 512M         
         EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;     

--2.Create a user
create user demo identified by demo 
default tablespace sdt;
 
--3.Empowerment
grant connect,resource to demo;
grant create any sequence to demo;
grant create any table to demo;
grant delete any table to demo;
grant insert any table to demo;
grant select any table to demo;
grant unlimited tablespace to demo;
grant execute any procedure to demo;
grant update any table to demo;
grant create any view to demo;

3. Database import and export

--Import and export command   
ipExport method: exp demo/[email protected]:1521/orcl file=f:/ full=y
exp demo/demo@orcl file=f:/ full=y
imp demo/demo@orcl file=f:/ full=y ignore=y

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.