transactional/sql/create-tables.sql

23 lines
517 B
MySQL
Raw Normal View History

2022-11-27 10:17:22 +03:00
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);