1.以sys用户登录PLSQL,连接方式选择SYSDBA:
2.查询数据库名:
select sys_context('userenv', 'con_name') from dual;
3.启用可插播数据库:
alter pluggable database orclpdb open;
其中orclpdb是可插播数据库名
4.切换到orclpdb数据库
alter session set container=orclpdb;
5.创建表空间:
create tablespace HIS_DATA(表空间名字) datafile 'E:\Oracle19c\oradata\ORCL\HIS_DATA.dbf'(路径) size 20G(大小) autoextend on next 64m;
create tablespace HIS_INDX(表空间名字) datafile 'E:\Oracle19c\oradata\ORCL\HIS_INDX.dbf'(路径) size 8G(大小) autoextend on next 64m;
6.创建用户并授权:
create user 用户名 identified by 密码 default tablespace 表空间名字;
grant connect , resource ,dba to 用户名;
7.数据导入:
以管理员方式打开cmd执行下面的命令
Impdp 用户名/密码@127.0.0.1:1521/orclpdb(数据库)
file=202211181751.dmp(dmp文件名)
logfile=202211181751.log(日志名)
REMAP_SCHEMA=xxxxx(导出dmp文件用户):yyyyy(导入dmp文件用户)
8.其他:
扩建表空间
alter tablespace HIS_DATA add datafile 'E:\Oracle19c\oradata\ORCL\HIS_DATA1.dbf' size 10G autoextend on next 64m;
查询表空间相关信息
SELECT a.tablespace_name ,--表空间
Round(a.bytes/(1024*1024*1024),3),-- 大小G
Round(b.bytes/(1024*1024*1024)), --已使用G
Round(c.bytes/(1024*1024*1024)) ,--剩余G
Round(b.bytes*100/a.bytes,3), --使用百分比%
Round(c.bytes*100/a.bytes,3) --剩余百分比%
FROM sys.Sm$ts_Avail a, sys.Sm$ts_Used b,sys.sm$ts_free c
WHERE a.tablespace_name=b.tablespace_name AND a.tablespace_name=c.tablespace_name;