pragma foreign_keys = 0; begin; attach database 'baseball-raw.db' as 'raw'; create temp table battingpost as select * from "raw".battingpost; alter table battingpost drop column "lgID"; alter table battingpost drop column "teamID"; 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"; commit;