SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
CREATE TABLE clients ( id number(10) NOT NULL PRIMARY KEY, name varchar2(1000), place_of_birth varchar2(1000), date_of_birth date, adress varchar2(1000), passport varchar2(100) ); CREATE TABLE tarifs ( id number(10) NOT NULL PRIMARY KEY, name varchar2(100), cost number(10,2) ); CREATE TABLE product_type ( id number(10) NOT NULL PRIMARY KEY, name varchar2(100), begin_date date, end_date date, tarif_ref number(10) NOT NULL, CONSTRAINT fk_tarif_ref FOREIGN KEY (tarif_ref) REFERENCES tarifs(id) ); CREATE TABLE products ( id number(10) NOT NULL PRIMARY KEY, product_type_id number(10) NOT NULL, name varchar2(100), client_ref number(10) NOT NULL, open_date date, close_date date, CONSTRAINT fk_product_type_id FOREIGN KEY (product_type_id) REFERENCES product_type(id), CONSTRAINT fk_client_ref FOREIGN KEY (client_ref) REFERENCES clients(id) ); CREATE TABLE accounts ( id number(10) NOT NULL PRIMARY KEY, name varchar2(100), saldo number(10, 2), client_ref number(10) NOT NULL, open_date date, close_date date, product_ref number(10) NOT NULL, acc_num varchar2(25), CONSTRAINT fk_client_ref1 FOREIGN KEY (client_ref) REFERENCES clients(id), CONSTRAINT fk_product_ref FOREIGN KEY (product_ref) REFERENCES products(id) ); CREATE TABLE records ( id number(10) NOT NULL PRIMARY KEY, dt number(1), sum number(10, 2), acc_ref number(10) NOT NULL, oper_date date, CONSTRAINT fk_acc_ref FOREIGN KEY (acc_ref) REFERENCES accounts(id) ); insert into tarifs values (1,'Тариф за выдачу кредита', 10); insert into tarifs values (2,'Тариф за открытие счета', 10); insert into tarifs values (3,'Тариф за обслуживание карты', 10); insert into product_type values (1, 'КРЕДИТ', to_date('01.01.2018','DD.MM.YYYY'), null, 1); insert into product_type values (2, 'ДЕПОЗИТ', to_date('01.01.2018','DD.MM.YYYY'), null, 2); insert into product_type values (3, 'КАРТА', to_date('01.01.2018','DD.MM.YYYY'), null, 3); insert into clients values (1, 'Сидоров Иван Петрович', 'Россия, Московская облать, г. Пушкин', to_date('01.01.2001','DD.MM.YYYY'), 'Россия, Московская облать, г. Пушкин, ул. Грибоедова, д. 5', '2222 555555, выдан ОВД г. Пушкин, 10.01.2015'); insert into clients values (2, 'Иванов Петр Сидорович', 'Россия, Московская облать, г. Клин', to_date('01.01.2001','DD.MM.YYYY'), 'Россия, Московская облать, г. Клин, ул. Мясникова, д. 3', '4444 666666, выдан ОВД г. Клин, 10.01.2015'); insert into clients values (3, 'Петров Сиодр Иванович', 'Россия, Московская облать, г. Балашиха', to_date('01.01.2001','DD.MM.YYYY'), 'Россия, Московская облать, г. Балашиха, ул. Пушкина, д. 7', '4444 666666, выдан ОВД г. Клин, 10.01.2015'); insert into products values (1, 1, 'Кредитный договор с Сидоровым И.П.', 1, to_date('01.06.2015','DD.MM.YYYY'), null); insert into products values (2, 2, 'Депозитный договор с Ивановым П.С.', 2, to_date('01.08.2017','DD.MM.YYYY'), null); insert into products values (3, 3, 'Карточный договор с Петровым С.И.', 3, to_date('01.08.2017','DD.MM.YYYY'), null); insert into accounts values (1, 'Кредитный счет для Сидоровым И.П.', -2000, 1, to_date('01.06.2015','DD.MM.YYYY'), null, 1, '45502810401020000022'); insert into accounts values (2, 'Депозитный счет для Ивановым П.С.', 6000, 2, to_date('01.08.2017','DD.MM.YYYY'), null, 2, '42301810400000000001'); insert into accounts values (3, 'Карточный счет для Петровым С.И.', 8000, 3, to_date('01.08.2017','DD.MM.YYYY'), null, 3, '40817810700000000001'); insert into records values (1, 1, 5000, 1, to_date('01.06.2015','DD.MM.YYYY')); insert into records values (2, 0, 1000, 1, to_date('01.07.2015','DD.MM.YYYY')); insert into records values (3, 0, 2000, 1, to_date('01.08.2015','DD.MM.YYYY')); insert into records values (4, 0, 3000, 1, to_date('01.09.2015','DD.MM.YYYY')); insert into records values (5, 1, 5000, 1, to_date('01.10.2015','DD.MM.YYYY')); insert into records values (6, 0, 3000, 1, to_date('01.10.2015','DD.MM.YYYY')); insert into records values (7, 0, 10000, 2, to_date('01.08.2017','DD.MM.YYYY')); insert into records values (8, 1, 1000, 2, to_date('05.08.2017','DD.MM.YYYY')); insert into records values (9, 1, 2000, 2, to_date('21.09.2017','DD.MM.YYYY')); insert into records values (10, 1, 5000, 2, to_date('24.10.2017','DD.MM.YYYY')); insert into records values (11, 0, 6000, 2, to_date('26.11.2017','DD.MM.YYYY')); insert into records values (12, 0, 120000, 3, to_date('08.09.2017','DD.MM.YYYY')); insert into records values (13, 1, 1000, 3, to_date('05.10.2017','DD.MM.YYYY')); insert into records values (14, 1, 2000, 3, to_date('21.10.2017','DD.MM.YYYY')); insert into records values (15, 1, 5000, 3, to_date('24.10.2017','DD.MM.YYYY')); SELECT accounts.id, accounts.name, accounts.saldo, accounts.acc_num FROM accounts INNER JOIN products ON accounts.product_ref = products.id INNER JOIN clients ON products.client_ref = clients.id
SQL
Server:
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
MariaDB 11.5
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear