41 lines
772 B
PL/PgSQL
41 lines
772 B
PL/PgSQL
BEGIN;
|
|
CREATE TABLE IF NOT EXISTS "pk_pitching" (
|
|
"playerID" TEXT,
|
|
"yearID" NUMERIC,
|
|
"stint" NUMERIC,
|
|
"teamID" TEXT,
|
|
"lgID" TEXT,
|
|
"W" NUMERIC,
|
|
"L" NUMERIC,
|
|
"G" NUMERIC,
|
|
"GS" NUMERIC,
|
|
"CG" NUMERIC,
|
|
"SHO" NUMERIC,
|
|
"SV" NUMERIC,
|
|
"IPouts" NUMERIC,
|
|
"H" NUMERIC,
|
|
"ER" NUMERIC,
|
|
"HR" NUMERIC,
|
|
"BB" NUMERIC,
|
|
"SO" NUMERIC,
|
|
"BAOpp" NUMERIC,
|
|
"ERA" NUMERIC,
|
|
"IBB" NUMERIC,
|
|
"WP" NUMERIC,
|
|
"HBP" NUMERIC,
|
|
"BK" NUMERIC,
|
|
"BFP" NUMERIC,
|
|
"GF" NUMERIC,
|
|
"R" NUMERIC,
|
|
"SH" NUMERIC,
|
|
"SF" NUMERIC,
|
|
"GIDP" NUMERIC,
|
|
PRIMARY KEY("playerID","yearID","stint","teamID"),
|
|
foreign key("playerID") references "people"("playerID")
|
|
);
|
|
|
|
INSERT INTO "pk_pitching" SELECT DISTINCT * FROM "pitching";
|
|
DROP TABLE "pitching";
|
|
ALTER TABLE "pk_pitching" RENAME TO "pitching";
|
|
COMMIT;
|