lahmanlite/sql/keys/managers.sql

20 lines
469 B
PL/PgSQL

BEGIN;
CREATE TABLE IF NOT EXISTS "pk_managers" (
"playerID" TEXT,
"yearID" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"inseason" NUMERIC,
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
"rank" NUMERIC,
"plyrMgr" TEXT,
PRIMARY KEY("playerID","yearID","teamID","inseason"),
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_managers" SELECT DISTINCT * FROM "managers";
DROP TABLE "managers";
ALTER TABLE "pk_managers" RENAME TO "managers";
COMMIT;