SELECT * FROM nodes JOIN names USING (tax_id) WHERE "name class" = 'scientific name' ; ALTER TABLE :table ALTER COLUMN tax_id TYPE integer USING tax_id::integer; ALTER TABLE :table ALTER COLUMN "parent tax_id" TYPE integer USING "parent tax_id"::integer; ALTER TABLE :table ADD PRIMARY KEY (tax_id);