Using a table's data type...

Started by murphy popealmost 24 years ago2 messagesgeneral
Jump to latest
#1murphy pope
pope_murphy@hotmail.com

When I create a new table, I have also created a new data type (whose name
is the same as the name of the table). For example:

CREATE TABLE customer(
customer_id integer,
customer_name varchar );

creates a new data type named 'customer'. I can now create another table
that includes a column whose type is 'customer':

CREATE TABLE customer_archive(
customer_info customer,
mod_date timestamp );

Now, a couple of really basic questions.
1) Is there a way to insert a row into this table?

2) Since customer_archive.customer_info is defined to be a composite
column, how would I address each member?

3) Is this just a really dumb idea on my part? Maybe the fact that I can
use a table's type to define a column is just accidental and I really
shouldn't do that.

Any opinions, answers, or documentation references are appreciated. Thanks.

-- Murphy

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: murphy pope (#1)
Re: Using a table's data type...

"murphy pope" <pope_murphy@hotmail.com> writes:

Maybe the fact that I can use a table's type to define a column is
just accidental and I really shouldn't do that.

It did actually do something quasi-useful, I believe, back in the
PostQUEL days. But it hasn't worked for a long time, and I don't think
there's any interest in reviving it. Some day we should deliver the
coup de grace and get rid of 'attisset' completely.

regards, tom lane