Re: Lookup tables

Rich Shepard <rshepard@appl-ecosys.com>

From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@postgresql.org
Date: 2025-02-04T19:08:42Z
Lists: pgsql-general
On Tue, 4 Feb 2025, Rob Sargent wrote:

> Unless your lookup tables are huge I would create a new table matching
> your current table but with an identity column and load from you original
> table.

I created a new table:

create table ind_types_lu (
   ind_nbr serial primary key,
   ind_name varchar(32) not null
);

Now the database has the new table and a new sequence:

  public | ind_types_lu             | table    | rshepard
  public | ind_types_lu_ind_nbr_seq | sequence | rshepard

I want to replace the old lookup table (with no FK) with this one. Can I
use:

alter table rename ind_types_lu to industrytypes;

and have the sequence name changed, too?

TIA,

Rich