Skip to content

Instantly share code, notes, and snippets.

@avbelyaev
Last active January 30, 2020 20:33
Show Gist options
  • Save avbelyaev/832ac9d9a94450769385f04ce5261933 to your computer and use it in GitHub Desktop.
Save avbelyaev/832ac9d9a94450769385f04ce5261933 to your computer and use it in GitHub Desktop.
databases: PostgreSQL 10, PgAdmin4, SqlServer 2019, Oracle 11XE, Sybase 16
version: '3.1'
services:
xpostgres:
image: postgres:10.10
environment:
POSTGRES_DB: ics
POSTGRES_USER: ics
POSTGRES_PASSWORD: ics
ports:
- 5432:5432
volumes:
- ./postgres-data:/var/lib/postgresql/data
networks:
- postgres-net
xpgadmin:
# connect to xpostgres:5432
# creds to db from above
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: ics
ports:
- 4000:80
networks:
- postgres-net
depends_on:
- xpostgres
xsqlserver:
# creds: sa/Pa55w0rd
image: mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu
environment:
ACCEPT_EULA: Y
SA_PASSWORD: Pa55w0rd
ports:
- 1433:1433
# volume not supported on Mac
xoracle:
# creds: system/oracle
# SID seems to be case sensitive: "xe"
# port: 1521
image: quay.io/maksymbilenko/oracle-xe-11g
environment:
ORACLE_PWD: Pa55w0rd
shm_size: '1gb'
ports:
- 1521:1521
- 8080:8080
volumes:
- ./oracle-data:/u01/app/oracle
# xsybase:
## это дерьмо весит 2+ гб!
# # creds: sa/myPassword
# image: datagrip/sybase
# environment:
# SYBASE_DB: ics
# SYBASE_USER: ics
# SYBASE_PASSWORD: ics
# ports:
# - 5000:5000
networks:
postgres-net:
driver: bridge
create table Tests
(
id int primary key,
foo varchar(20)
)
insert into Tests values
(1, 'hello'),
(2, 'world')
delete from Tests
select * from Tests
CREATE DATABASE TestDB
SELECT Name from sys.Databases
GO
USE TestDB
CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
INSERT INTO Inventory VALUES (1, 'banana', 150);
INSERT INTO Inventory VALUES (2, 'orange', 154);
GO
select * from Inventory
select banner from v$version where rownum = 1;
ALTER SESSION SET CURRENT_SCHEMA = "SYSTEM";
CREATE TABLE customers
( customer_id number(10) NOT NULL,
customer_name varchar2(50) NOT NULL,
city varchar2(50)
);
insert into customers
(customer_id, customer_name, city) VALUES
(1, 'anthony', 'moscow');
select * from customers;
create table emp
(
user_mobile number(10) not null,
update_date date,
start_date date,
end_date date
);
insert into emp values (9631234567, '01.03.2016', '01.03.2016', null);
insert into emp values (9159876543, '01.10.2018', '01.10.2018', null);
insert into emp values (9159876543, '01.11.2018', null, '01.11.2018');
insert into emp values (9159876543, '01.12.2018', '01.12.2018', null);
insert into emp values (9159876543, '01.01.2019', null, '01.01.2019');
select * from emp;
create or replace procedure MergeEmployeeDates
(
employeeMobilePhone in number
)
is
cursor cursorOverSingleEmployee is
select start_date, end_date
from emp
where user_mobile = employeeMobilePhone
order by update_date asc;
begin
dbms_output.put_line(employeeMobilePhone);
for employeeEventRow in cursorOverSingleEmployee
loop
dbms_output.put_line('Variable value= ' || employeeEventRow.start_date );
end loop;
end;
Set serveroutput on;
begin
MergeEmployeeDates(9159876543);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment