1、下载镜像
docker pull registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c
2、查看镜像
sudo docker images
看到已经有了 19c
3、挂载文件
# 创建文件 mkdir -p /home/data/oracle/datas # 授权,不授权会导致后面安装失败 chmod 777 /home/data/oracle/datas
4、启动镜像
docker run -d -p 1521:1521 -p 5500:5500 -e ORACLE_SID=ORCLCDB -e ORACLE_PDB=ORCLPDB -e ORACLE_PWD=123456 -e ORACLE_EDITION=standard -e ORACLE_CHARACTERSET=AL32UTF8 -v /home/data/oracle/data:/opt/oracle/data --name orcl19c registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c
如果报错,用下面这段:
sudo docker run -d -p 1521:1521 -p 5500:5500 -e ORACLE_SID=ORCLCDB -e ORACLE_PDB=ORCLPDB -e ORACLE_PWD=123456 -e ORACLE_EDITION=standard -e ORACLE_CHARACTERSET=AL32UTF8 -v /home/data/oracle/data:/opt/oracle/data --name orcl19c registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c
5、连接oracle
docker exec -it orcl19c /bin/bash sqlplus / as sysdba show pdbs;
show pdbs; 必须要有READ WRITE 不然会有问题
6、一系列操作
--查看当前容器数据库 select sys_context('USERENV','CON_NAME') from dual; --打开PDB容器数据库 alter pluggable database ORCLPDB open; --切换容器数据库 alter session set container=ORCLPDB;
7、创建表空间
create tablespace "你自己的表空间名" datafile '/opt/oracle/data/ORCLCDB/ORCLPDB/你自己的表空间文件名.dbf' size 250M autoextend on
注意目录有可能不一样
8、删除表空间
DROP TABLESPACE 表空间名 INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;
9、查看所有表空间
select TABLESPACE_NAME,STATUS from dba_tablespaces;
10、创建用户及授权等一系列操作
1.首先,创建(新)用户: create user username identified by password; username:新用户名的用户名 password: 新用户的密码 也可以不创建新用户,而仍然用以前的用户,如:继续利用scott用户 2.创建表空间: create tablespace tablespacename datafile 'd:\data.dbf' size xxxm; tablespacename:表空间的名字 d:\data.dbf':表空间的存储位置 xxx表空间的大小,m单位为兆(M) 3.将空间分配给用户: alert user username default tablespace tablespacename; 将名字为tablespacename的表空间分配给username 4.给用户授权: grant create session,create table,unlimited tablespace to username; 5.然后再以楼主自己创建的用户登录,登录之后创建表即可。 conn username/password;6.查看服务名env |grep SID 7.授予dba权限grant dba to username7.使用上面的用户名、密码、sid登录plsql 每步执行的sql:(sjzx是数据库名、用户名、密码、表空间名) (1)create user sjzx identified by sjzx (2)create tablespace sjzx datafile 'D:\db\app\oradata\orcl\sjzx.dbf' size 100m autoextend on next 32m maxsize 2048m (3)alter user sjzx default tablespace sjzx (4)grant create session,create table,unlimited tablespace to sjzx 1.创建用户 create user user_name identified by "user_password" default tablespace tbs_name temporary tablespace temp profile DEFAULT; 2.授权 grant connect to user_name; grant create indextype to user_name; grant create job to user_name; grant create materialized view to user_name; grant create procedure to user_name; grant create public synonym to user_name; grant create sequence to user_name; grant create session to user_name; grant create table to user_name; grant create trigger to user_name; grant create type to user_name; grant create view to user_name; grant unlimited tablespace to user_name; alter user user_name quota unlimited on tbs_name; 在oracle命令行中,查看oracle表空间数据文件位置 select t1.name,t2.name from v$tablespace t1,v$datafile t2 where t1.ts# = t2.ts#;