lahmanlite/sql/seriespost.sql

28 lines
668 B
MySQL
Raw Normal View History

pragma foreign_keys = 0;
2024-01-26 19:27:58 +00:00
begin;
2024-05-05 03:11:20 +00:00
attach database 'lahman-raw.db' as 'raw';
2024-01-31 06:09:39 +00:00
create temp table seriespost as
select * from "raw".seriespost;
2024-01-26 19:27:58 +00:00
alter table "seriespost" drop column "lgIDwinner";
alter table "seriespost" drop column "lgIDloser";
2024-01-31 06:09:39 +00:00
CREATE TABLE IF NOT EXISTS main."seriespost" (
"year" NUMERIC,
"round" NUMERIC,
"winner" TEXT,
"loser" TEXT,
"wins" NUMERIC,
"losses" NUMERIC,
"ties" NUMERIC,
PRIMARY KEY("year","round"),
foreign key("year") references "seasons"("year"),
foreign key("winner") references "teams"("ID"),
foreign key("loser") references "teams"("ID")
);
insert into main.seriespost select distinct * from temp."seriespost";
2024-01-26 19:27:58 +00:00
commit;