Instalacja

Uruchomienie lokalne

Przykładowy tekst

1
2
3
4
5
6
7
├── config
│ └── xe11
│     ├── Dockerfile
│     ├── init.sql
│     └── script.sh
├── docker-compose.yml
└── README.md

Struktura

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
zrodlo
https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g

docker-compose  up --no-deps --build

zbuduj
docker-compose build

uruchom
docker-compose up

usun
docker-compose -f docker-compose.yml down

wejscie do kontenera
docker exec -it --user=oracle oracle11xe bash

README.md

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
version: '3.7'

services:
  oracle11xe:
    image: oracle11xe
    container_name: oracle11xe
    build: ./config/xe11
    ports:
      - 1521:1521
    networks:
      db_net:
        ipv4_address: 10.99.105.2

networks:
  db_net:
    ipam:
      driver: default
      config:
        - subnet: "10.99.105.0/24"

docker-compose.yml

1
2
3
4
5
6
FROM wnameless/oracle-xe-11g-r2

ADD init.sql /docker-entrypoint-initdb.d/
ADD script.sh /docker-entrypoint-initdb.d/

EXPOSE 1521

config/xe11/Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
CREATE USER USER_KAMIL IDENTIFIED BY USER_PASSWORD;
GRANT CONNECT, RESOURCE TO USER_KAMIL;
CREATE TABLESPACE TS_UTILS_DATA DATAFILE 'TS_UTILS_DATA.DBF' SIZE 120M AUTOEXTEND ON NEXT 20M MAXSIZE 2048M;
CREATE TABLESPACE TS_UTILS_IDX DATAFILE 'TS_UTILS_IDX.DBF' SIZE 20M AUTOEXTEND ON NEXT 20M MAXSIZE 2048M;
ALTER USER USER_KAMIL DEFAULT TABLESPACE TS_UTILS_DATA;
ALTER USER USER_KAMIL QUOTA UNLIMITED ON TS_UTILS_DATA;
ALTER USER USER_KAMIL QUOTA UNLIMITED ON TS_UTILS_IDX;

GRANT SELECT ON SYS.DBA_PENDING_TRANSACTIONS TO USER_KAMIL;
GRANT SELECT ON SYS.PENDING_TRANS$ TO USER_KAMIL;
GRANT SELECT ON SYS.DBA_2PC_PENDING TO USER_KAMIL;
GRANT EXECUTE ON SYS.DBMS_XA TO USER_KAMIL;
GRANT FORCE ANY TRANSACTION TO USER_KAMIL;

config/xe11/init.sql – Tworzenie użytkownika/schematu

1
 

config/xe11/script.sh

Mierzenie rozmiaru tabel

Poszczególne tabele
1
2
3
4
5
6
SELECT
   (BYTES)/1024/1024 as size_in_mega,
   segment_name
FROM
   user_segments
ORDER BY size_in_mega DESC;
Całość
1
2
3
4
SELECT
   SUM(BYTES)/1024/1024 as size_in_mega
FROM
   user_segments;

Plan zapytań

Eksport bazy

1
exp USER/password@//127.0.0.186:1521/XE FULL=y FILE=dump.dmp GRANTS=y ROWS=y

Import bazy

1
imp USER/password@//127.0.0.1:1521/XE FILE=dump.dmp