begin; attach database 'baseball-raw.db' as 'raw'; create temp table appearances as select * from "raw".appearances; alter table appearances drop column "lgID"; update appearances set teamid = 'WS9' where teamid = 'WAS' and yearid between 1891 and 1899; update appearances set teamid = 'PHP' where teamid = 'PH4' and yearid between 1890 and 1891; -- got this missing data from bbref insert into appearances values (1896,'BRO','dailyco01',1,null,1,null,0,1,0,0,0,0,0,0,0,0,0,null,null), (1875,'WS6','thompfr01',11,null,11,null,0,11,0,0,0,0,0,0,1,1,0,null,null); CREATE TABLE IF NOT EXISTS "appearances" ( "year" NUMERIC, "team" TEXT, "player" TEXT, "G_all" NUMERIC, "GS" NUMERIC, "G_batting" NUMERIC, "G_defense" NUMERIC, "G_p" NUMERIC, "G_c" NUMERIC, "G_1b" NUMERIC, "G_2b" NUMERIC, "G_3b" NUMERIC, "G_ss" NUMERIC, "G_lf" NUMERIC, "G_cf" NUMERIC, "G_rf" NUMERIC, "G_of" NUMERIC, "G_dh" NUMERIC, "G_ph" NUMERIC, "G_pr" NUMERIC, PRIMARY KEY("year","team","player"), foreign key("player") references "people"("ID"), foreign key("year","team") references "teamseasons"("year","team") ); insert into main.appearances select distinct * from temp.appearances; commit;