lahmanlite/sql/keys/salaries.sql

16 lines
381 B
PL/PgSQL

BEGIN;
CREATE TABLE IF NOT EXISTS "pk_salaries" (
"yearID" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"playerID" TEXT,
"salary" NUMERIC,
PRIMARY KEY("yearID","playerID","teamID"),
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_salaries" SELECT DISTINCT * FROM "salaries";
DROP TABLE "salaries";
ALTER TABLE "pk_salaries" RENAME TO "salaries";
COMMIT;