[Oracle]Oracle镜像安装及使用教程

Oracle镜像安装及使用教程

一、环境:

系统:Ubuntu 18.04

二、Oracle镜像安装及使用

  • 下载oracle镜像

  docker pull registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g

  • 查看镜像

   docker images

  • 创建并启动容器

 docker run -d -p 1521:1521 --name oracle11 registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g

  • 查看当前运行的容器

  docker ps

  • 进入已经启动的oracle的容器

  docker exec -it oracle11 /bin/bash

  • 进入sqlplus

sqlplus /nolog;

  • 使用sysdba角色登录sqlplus

conn sys/oracle as sysdba;

 

  • 查看当前实例下的数据库

select instance_name from v$instance;

  • 查看有多少个数据表

select count(*) from user_tables;

  • 创建表空间

create tablespace cyberpeace datafile '/u01/app/oracle/oradata/XE/cyberpeace.dbf' size 100m autoextend on next 10m;

  • 创建用户并指定表空间

create user cyberpeace identified by 123456 default tablespace cyberpeace;

  •  授予用户dba权限

grant dba to cyberpeace;

  • 设置自增序列
create sequence img_id
minvalue 1
nomax value
increment by 1
start with 1
nocache;

create or replace trigger img_tg_insertId
before insert on IMAGE for each row
begin
  select img_id.Nextval into:new.id from dual;
end;
原文地址:https://www.cnblogs.com/ttkl/p/14482216.html