lahmanlite/sql/battingpost.sql

38 lines
835 B
MySQL
Raw Normal View History

2024-01-28 06:09:06 +00:00
begin;
2024-01-31 06:09:39 +00:00
attach database 'baseball-raw.db' as 'raw';
create temp table battingpost as
select * from "raw".battingpost;
2024-01-28 06:09:06 +00:00
alter table battingpost drop column "lgID";
alter table battingpost drop column "teamID";
2024-01-31 06:09:39 +00:00
CREATE TABLE IF NOT EXISTS main."battingpost" (
"year" NUMERIC,
"round" NUMERIC,
"player" TEXT,
"G" NUMERIC,
"AB" NUMERIC,
"R" NUMERIC,
"H" NUMERIC,
"2B" NUMERIC,
"3B" NUMERIC,
"HR" NUMERIC,
"RBI" NUMERIC,
"SB" NUMERIC,
"CS" NUMERIC,
"BB" NUMERIC,
"SO" NUMERIC,
"IBB" NUMERIC,
"HBP" NUMERIC,
"SH" NUMERIC,
"SF" NUMERIC,
"GIDP" NUMERIC,
PRIMARY KEY("year","player","round"),
foreign key("player","year") references "appearancespost"("player","year"),
foreign key("year","round") references "seriespost"("year","round")
);
insert into main.battingpost select distinct * from temp."battingpost";
2024-01-28 06:09:06 +00:00
commit;