ORACLE 12.2 分区梳理之01-(创建用户环境)

ORACLE 12.2 分区梳理之01-(创建用户环境)

  1. 创建表空间
[oracle@xag182 ~]$ sql system/[email protected]:1521/PDB1

SQL> SET SQLFORMAT ansiconsole
SQL> show user;
USER is "SYSTEM"
SQL> show pdbs;
CON_ID  CON_NAME  OPEN MODE   RESTRICTED  
3       PDB1      READ WRITE  NO          

#UNDO梳理
SQL> select tablespace_name,file_name,bytes/1024/1024 mb from dba_temp_files 
     union all 
     select tablespace_name,file_name,bytes/1024/1024 mb from dba_data_files;
TABLESPACE_NAME  FILE_NAME                                  MB   
TEMP1            /u02/oradata/MPAPEX/pdb1/TEMP1_1.dbf       256  
TEMP1            /u02/oradata/MPAPEX/pdb1/TEMP1_2.dbf       256  
TEMP2            /u02/oradata/MPAPEX/pdb1/TEMP2_1.dbf       256  
SYSTEM           /u02/oradata/MPAPEX/pdb1/system01.dbf      370  
SYSAUX           /u02/oradata/MPAPEX/pdb1/sysaux01.dbf      380  
UNDOTBS1         /u02/oradata/MPAPEX/pdb1/undotbs01.dbf     300  

#此处为测试环境故设置500M,生产环境要放大10G以上
SQL> ALTER DATABASE DATAFILE '/u02/oradata/MPAPEX/pdb1/undotbs01.dbf' RESIZE 500M;
SQL> ALTER DATABASE DATAFILE '/u02/oradata/MPAPEX/pdb1/undotbs01.dbf' AUTOEXTEND ON NEXT 100M;

#TEMP 梳理
CREATE TEMPORARY TABLESPACE TD_XAG TEMPFILE
'/u02/oradata/MPAPEX/pdb1/TD_XAG_1.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M  MAXSIZE 1G,
'/u02/oradata/MPAPEX/pdb1/TD_XAG_2.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M  MAXSIZE 1G
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

ALTER TABLESPACE TD_XAG TABLESPACE GROUP TDG_XAG;

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TDG_XAG;
#如存在缺省的TEMP则删除,如无法删除则需重启db
drop tablespace TEMP including contents and datafiles;

SQL> select * from dba_tablespace_groups;
  GROUP_NAME  TABLESPACE_NAME  
  TDG_XAG     TD_XAG 

#整理用户表空间
create tablespace D_XAG datafile 
'/u02/oradata/MPAPEX/pdb1/D_XAG1.dbf' size 16M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED,                  
'/u02/oradata/MPAPEX/pdb1/D_XAG2.dbf' size 16M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED 
default storage (initial 128K next 2M pctincrease 0);

Create tablespace I_XAG datafile 
'/u02/oradata/MPAPEX/pdb1/I_XAG1.dbf' size 16M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED,            
'/u02/oradata/MPAPEX/pdb1/I_XAG2.dbf' size 16M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED  
default storage (initial 128K next 2M pctincrease 0);

ALTER DATABASE DEFAULT TABLESPACE D_XAG ;

#如存在缺省的 USERS 则删除
drop tablespace USERS including contents and datafiles;

2.创建用户

SQL> CREATE USER XAG1 IDENTIFIED BY "123456" DEFAULT TABLESPACE D_XAG TEMPORARY TABLESPACE TDG_XAG;

SQL> GRANT DBA to XAG1;

SQL> conn xag1/[email protected]:1521/PDB1
#查询缺省表空间
SQL> SELECT PROPERTY_VALUE FROM database_properties WHERE PROPERTY_NAME ='DEFAULT_PERMANENT_TABLESPACE';
  PROPERTY_VALUE  
  D_XAG 

你可能感兴趣的:(ORACLE 12.2 分区梳理之01-(创建用户环境))