Re: Alter table column constraint [RESOLVED]

2018-12-17 Thread Rich Shepard
On Mon, 17 Dec 2018, Ron wrote: Melvin is saying to: 1. create a table named valid_industry, 2. populate it with the valid industries, 3. create an FK constraint on your main table's industry column to valid_industry.industry, and then 4. drop the constraint invalid_industry. Got it.

Re: Alter table column constraint

2018-12-17 Thread Adrian Klaver
On 12/17/18 12:20 PM, Rich Shepard wrote: On Mon, 17 Dec 2018, Melvin Davidson wrote: Yes, you must drop then add the revised constraint. However, from your statement above, it sounds to me as if you would be better off using A FOREIGN kEY CONSTRAINT. It makes things a lot simpler. Melvin,

Re: Alter table column constraint

2018-12-17 Thread Melvin Davidson
See https://www.postgresql.org/docs/current/tutorial-fk.html On Mon, Dec 17, 2018 at 3:32 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Mon, Dec 17, 2018 at 1:20 PM Rich Shepard > wrote: > > > > On Mon, 17 Dec 2018, Melvin Davidson wrote: > > > > > Yes, you must drop then add

Re: Alter table column constraint

2018-12-17 Thread Melvin Davidson
So CREATE a table eg: CREATE TABLE fks_for_tables ( fks_id serial fks_values varchar(20), CONSTRAINT fks_pkey PRIMARY KEY (fks_id), CONSTRAINT fks-unique UNIQUE fks_values ) Then INSERT INTO fks_for_tables (fks_values) VALUES ( 'Agriculture'), ('Business'), ('other))', 'Chemicals') ... ...

Re: Alter table column constraint

2018-12-17 Thread David G. Johnston
On Mon, Dec 17, 2018 at 1:20 PM Rich Shepard wrote: > > On Mon, 17 Dec 2018, Melvin Davidson wrote: > > > Yes, you must drop then add the revised constraint. However, from your > > statement above, it sounds to me as if you would be better off using A > > FOREIGN kEY CONSTRAINT. It makes things a

Re: Alter table column constraint

2018-12-17 Thread Ron
On 12/17/2018 02:20 PM, Rich Shepard wrote: On Mon, 17 Dec 2018, Melvin Davidson wrote: Yes, you must drop then add the revised constraint. However, from your statement above, it sounds to me as if you would be better off using A FOREIGN kEY CONSTRAINT. It makes things a lot simpler. Melvin,

Re: Alter table column constraint

2018-12-17 Thread Rich Shepard
On Mon, 17 Dec 2018, Melvin Davidson wrote: Yes, you must drop then add the revised constraint. However, from your statement above, it sounds to me as if you would be better off using A FOREIGN kEY CONSTRAINT. It makes things a lot simpler. Melvin, I don't follow. Here's the DDL for that

Re: Alter table column constraint

2018-12-17 Thread Melvin Davidson
>I want to alter a term in a column's constraint to allow only specified > strings as attributes Yes, you must drop then add the revised constraint. However, from your statement above, it sounds to me as if you would be better off using A FOREIGN kEY CONSTRAINT. It makes things a lot simpler. On

Re: Alter table column constraint

2018-12-17 Thread Joshua D. Drake
On 12/17/18 12:01 PM, Rich Shepard wrote: On Mon, 17 Dec 2018, Rich Shepard wrote: I want to alter a term in a column's constraint to allow only specified strings as attributes and have not found how to do this in the docs (using version 10 docs now). There is an alter table command that

Re: Alter table column constraint

2018-12-17 Thread Rich Shepard
On Mon, 17 Dec 2018, Rich Shepard wrote: I want to alter a term in a column's constraint to allow only specified strings as attributes and have not found how to do this in the docs (using version 10 docs now). There is an alter table command that allows renaming a constraint but I've not seen

Alter table column constraint

2018-12-17 Thread Rich Shepard
I want to alter a term in a column's constraint to allow only specified strings as attributes and have not found how to do this in the docs (using version 10 docs now). There is an alter table command that allows renaming a constraint but I've not seen how to modify the constraint itself.