SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE person ( id uuid DEFAULT uuid_generate_v4 (), timeslots jsonb ); CREATE TABLE timeslots ( id uuid DEFAULT uuid_generate_v4(), dayOfWeek integer, f time without time zone, t time without time zone ); INSERT INTO person(timeslots) VALUES(' [{"To": "13:00:00", "From": "12:00:00", "DayOfWeek": 7}, {"To": "16:00:00", "From": "10:00:00", "DayOfWeek": 5}]'); INSERT INTO person(timeslots) VALUES('[{"To": "15:00:00", "From": "12:00:00", "DayOfWeek": 7}, {"To": "22:00:00", "From": "12:00:00", "DayOfWeek": 3}]'); INSERT INTO timeslots(dayOfWeek, f, t) SELECT "DayOfWeek", "From", "To" FROM person JOIN LATERAL jsonb_to_recordset(timeslots) as ("DayOfWeek" integer, "From" time without time zone, "To" time without time zone) on true; SELECT * FROM timeslots;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear