public inbox for [email protected]help / color / mirror / Atom feed
Accommodating alternative column values 7+ messages / 3 participants [nested] [flat]
* Accommodating alternative column values @ 2024-07-02 21:47 Rich Shepard <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rich Shepard @ 2024-07-02 21:47 UTC (permalink / raw) To: pgsql-general In data made available from a state regulatory agency I find a few instances where a facility contact has two email addresses. While multiple locations are accommodated because they're in a table separate from the facility name and details, all people associated with a facility and location are in a 'people' table with only one column for an email addresse. While I could enter an additional email address in the 'comment' column if I'm entering data for a single facility, I'm reformatting the downloaded data so I can insert all new table data from one .sql file. Is there a way to accommodate multiple email addresses other than entering both with a forward slash separating them in the varchar(64) email address column? Suggestions appreciated, Rich ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Accommodating alternative column values @ 2024-07-02 21:50 Christophe Pettus <[email protected]> parent: Rich Shepard <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Christophe Pettus @ 2024-07-02 21:50 UTC (permalink / raw) To: Rich Shepard <[email protected]>; +Cc: pgsql-general > On Jul 2, 2024, at 14:47, Rich Shepard <[email protected]> wrote: > Is there a way > to accommodate multiple email addresses other than entering both with a > forward slash separating them in the varchar(64) email address column? If you are absolutely 100% sure there will never be any metadata associated with each email address (like a "valid" flag), you can use TEXT[] array to store them. Otherwise, it's best to move them into a table with a foreign key back to the owning record. ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Accommodating alternative column values @ 2024-07-02 21:57 Rich Shepard <[email protected]> parent: Christophe Pettus <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rich Shepard @ 2024-07-02 21:57 UTC (permalink / raw) To: pgsql-general On Tue, 2 Jul 2024, Christophe Pettus wrote: > If you are absolutely 100% sure there will never be any metadata > associated with each email address (like a "valid" flag), you can use > TEXT[] array to store them. Otherwise, it's best to move them into a table > with a foreign key back to the owning record. Christophe, Using text rather than varchar() is a good suggestion. Thank you, Rich ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Accommodating alternative column values @ 2024-07-02 21:59 Christophe Pettus <[email protected]> parent: Rich Shepard <[email protected]> 0 siblings, 2 replies; 7+ messages in thread From: Christophe Pettus @ 2024-07-02 21:59 UTC (permalink / raw) To: Rich Shepard <[email protected]>; +Cc: pgsql-general > On Jul 2, 2024, at 14:57, Rich Shepard <[email protected]> wrote: > Using text rather than varchar() is a good suggestion. To be clear, I wasn't suggesting stuffing them all into a text column with a delimiter, but storing them in a text *array* field, each email address one component of the array. ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Accommodating alternative column values @ 2024-07-02 22:11 Rich Shepard <[email protected]> parent: Christophe Pettus <[email protected]> 1 sibling, 0 replies; 7+ messages in thread From: Rich Shepard @ 2024-07-02 22:11 UTC (permalink / raw) To: pgsql-general On Tue, 2 Jul 2024, Christophe Pettus wrote: > To be clear, I wasn't suggesting stuffing them all into a text column with > a delimiter, but storing them in a text *array* field, each email address > one component of the array. Okay. I've not before done that and will learn how. This data set is the only one I've encountered that has a very few multiple email addresses for a person. Thanks, Rich ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Accommodating alternative column values @ 2024-07-03 13:58 Rich Shepard <[email protected]> parent: Christophe Pettus <[email protected]> 1 sibling, 1 reply; 7+ messages in thread From: Rich Shepard @ 2024-07-03 13:58 UTC (permalink / raw) To: pgsql-general On Tue, 2 Jul 2024, Christophe Pettus wrote: > To be clear, I wasn't suggesting stuffing them all into a text column with > a delimiter, but storing them in a text *array* field, each email address > one component of the array. Christophe, I'm not using the proper syntax and the postgres alter table doc has no example in the alter column choices. What I've tried: bustrac=# alter table people alter column email set data type varchar(64) []; ERROR: column "email" cannot be cast automatically to type character varying[] HINT: You might need to specify "USING email::character varying(64)[]". How do I incorporate the "USING email::..." string? TIA, Rich ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Accommodating alternative column values @ 2024-07-03 14:03 David G. Johnston <[email protected]> parent: Rich Shepard <[email protected]> 0 siblings, 0 replies; 7+ messages in thread From: David G. Johnston @ 2024-07-03 14:03 UTC (permalink / raw) To: Rich Shepard <[email protected]>; +Cc: pgsql-general On Wednesday, July 3, 2024, Rich Shepard <[email protected]> wrote: > > I'm not using the proper syntax and the postgres alter table doc has no > example in the alter column choices. Simpler syntax forms tend to get skipped over when doing examples. > > How do I incorporate the "USING email::..." string? > ALTER [ COLUMN ] *column_name* [ SET DATA ] TYPE *data_type* [ COLLATE *collation* ] [ USING *expression* ] David J. ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2024-07-03 14:03 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-07-02 21:47 Accommodating alternative column values Rich Shepard <[email protected]> 2024-07-02 21:50 ` Christophe Pettus <[email protected]> 2024-07-02 21:57 ` Rich Shepard <[email protected]> 2024-07-02 21:59 ` Christophe Pettus <[email protected]> 2024-07-02 22:11 ` Rich Shepard <[email protected]> 2024-07-03 13:58 ` Rich Shepard <[email protected]> 2024-07-03 14:03 ` David G. Johnston <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox