mirror of
https://github.com/Example-uPagge/transactional.git
synced 2024-06-14 11:52:55 +03:00
23 lines
517 B
MySQL
23 lines
517 B
MySQL
|
CREATE SEQUENCE seq_person;
|
||
|
CREATE SEQUENCE seq_transaction;
|
||
|
|
||
|
CREATE TABLE person
|
||
|
(
|
||
|
id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('seq_person'),
|
||
|
balance BIGINT NOT NULL
|
||
|
);
|
||
|
|
||
|
CREATE TABLE transaction
|
||
|
(
|
||
|
id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('seq_transaction'),
|
||
|
person_from BIGINT NOT NULL REFERENCES person (id),
|
||
|
person_to BIGINT NOT NULL REFERENCES person (id),
|
||
|
amount BIGINT NOT NULL
|
||
|
|
||
|
);
|
||
|
|
||
|
INSERT INTO person
|
||
|
VALUES (1, 1000);
|
||
|
|
||
|
INSERT INTO person
|
||
|
VALUES (2, 1000);
|