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 kassiri( id SERIAL PRIMARY KEY, fio_kassira VARCHAR(50) NOT NULL, age INT NOT NULL, job varchar(50) NOT NULL ); CREATE TABLE cheki( id SERIAL PRIMARY KEY, kas_id int, number_chek SERIAL, date_create TIMESTAMP(0) DEFAULT NOW(), FOREIGN KEY (kas_id) REFERENCES kassiri(id) ON DELETE CASCADE ); INSERT INTO kassiri(fio_kassira, age, job) VALUES ('Романов', 44, 'Кассир'), ('Грачёв', 19, 'Кассир'), ('Иванов', 53, 'Главный кассир'); INSERT INTO cheki(kas_id) SELECT id FROM kassiri ORDER BY RANDOM() LIMIT 1; INSERT INTO cheki(kas_id) SELECT id FROM kassiri ORDER BY RANDOM() LIMIT 1; CREATE OR REPLACE VIEW my_view AS SELECT ch.number_chek, ch.id, ch.kas_id, k.fio_kassira, k.age, k.job, ch.date_create FROM cheki ch JOIN kassiri k ON ch.kas_id = k.id ORDER BY ch.number_chek; SELECT*FROM my_view DROP VIEW my_view CREATE OR REPLACE PROCEDURE Update_my_view(_fio_kassira VARCHAR(50), _job VARCHAR(50)) LANGUAGE plpgsql AS $$ DECLARE _kas_id INT; BEGIN SELECT id INTO _kas_id FROM kassiri WHERE fio_kassira = _fio_kassira and job = _job LIMIT 1; UPDATE my_view SET kas_id = _kas_id ; IF (_kas_id IS NULL) THEN RAISE EXCEPTION 'Кассира не существует'; END IF; END; $$; CREATE OR REPLACE FUNCTION insert_row_view() RETURNS trigger AS $$ BEGIN INSERT INTO cheki(kas_id) VALUES (NEW.kas_id); RETURN NEW; END; $$ LANGUAGE 'plpgsql'; CREATE OR REPLACE TRIGGER insert_view INSTEAD OF UPDATE ON my_view FOR EACH ROW EXECUTE PROCEDURE insert_row_view(); CALL Update_my_view('Романов', 'Кассир');
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
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