38 lines
878 B
PL/PgSQL
38 lines
878 B
PL/PgSQL
begin;
|
|
create table if not exists allstargames (
|
|
"yearID" numeric,
|
|
"gameNum" numeric,
|
|
"gameID" text,
|
|
primary key("yearID","gameNum")
|
|
);
|
|
|
|
insert into allstargames
|
|
select distinct yearid, gamenum, gameid
|
|
from allstarfull;
|
|
|
|
alter table allstarfull drop column "gameID";
|
|
|
|
alter table allstarfull rename to "allstarstartingpos";
|
|
|
|
create table if not exists "allstars" (
|
|
"playerID" text,
|
|
"yearID" text,
|
|
"gameNum" text,
|
|
"teamID" text,
|
|
"GP" numeric,
|
|
primary key("playerID","yearID","gameNum"),
|
|
foreign key("playerID") references "people"("playerID")
|
|
);
|
|
|
|
insert into allstars
|
|
select distinct playerid, yearid, gamenum, teamid, gp
|
|
from allstarstartingpos;
|
|
|
|
alter table allstarstartingpos drop column "teamid";
|
|
alter table allstarstartingpos drop column "lgID";
|
|
alter table allstarstartingpos drop column "gp";
|
|
|
|
delete from allstarstartingpos
|
|
where startingpos is null;
|
|
commit;
|