pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcan a column be aliased?
7+ messages / 3 participants
[nested] [flat]
* can a column be aliased?
@ 1998-08-03 16:04 James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 17:17 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
0 siblings, 1 reply; 7+ messages in thread
From: James Olin Oden @ 1998-08-03 16:04 UTC (permalink / raw)
To: pgsql-sql
I know this is probably a strange question, but can you give a column
name an alias? The reason I ask is because I have recently realized I
could use the oid to generate a unique key value for my tables, but I
don't like that idea, because it does not give a very readable (and I
assume portable) way of accessing the key value for the table. So I was
thinking if I could "alias" the name of the oid field in a particular to
something more palatable, then I would at least get around the
readability problem. Is this doable with SQL (or with PostgreSQL for
that matter)?
...james
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] can a column be aliased?
1998-08-03 16:04 can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
@ 1998-08-03 17:17 ` D'Arcy J.M. Cain <darcy@druid.net>
1998-08-03 17:35 ` Re: [SQL] can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 18:56 ` Re: [SQL] can a column be aliased? Roderick A. Anderson <raanders@altoplanos.net>
0 siblings, 2 replies; 7+ messages in thread
From: darcy@druid.net @ 1998-08-03 17:17 UTC (permalink / raw)
To: joden@lee.k12.nc.us; +Cc: pgsql-sql
Thus spake James Olin Oden
> I know this is probably a strange question, but can you give a column
> name an alias? The reason I ask is because I have recently realized I
SELECT table1.oid AS custnum, table2.oid AS salesman FROM ...
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] can a column be aliased?
1998-08-03 16:04 can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 17:17 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
@ 1998-08-03 17:35 ` James Olin Oden <joden@lee.k12.nc.us>
1998-08-04 11:12 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
1 sibling, 1 reply; 7+ messages in thread
From: James Olin Oden @ 1998-08-03 17:35 UTC (permalink / raw)
To: D'Arcy J.M. Cain <darcy@druid.net>; +Cc: pgsql-sql
D'Arcy J.M. Cain wrote:
> Thus spake James Olin Oden
> > I know this is probably a strange question, but can you give a column
> > name an alias? The reason I ask is because I have recently realized I
>
> SELECT table1.oid AS custnum, table2.oid AS salesman FROM ...
>
OK, I get that, but what if you want to say:
SELECT table1.custnum, table1.name, table2.invoicenum from table1, table2
WHERE table1.custnum = table2.custnum;
and without using the AS clause table1.custnum is pointing to table1.oid?
The idea is in perhaps the creation of the table to do something like the AS
clause, so that I don't have to "know" later that custnum (the key field) is
actually the oid column. The end result with this is to hide the
implementation details of the database from those querying it. I might be
really reaching, but it would be nice if something like this is a
available...james
> --
> D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
> http://www.druid.net/darcy/ | and a sheep voting on
> +1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] can a column be aliased?
1998-08-03 16:04 can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 17:17 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
1998-08-03 17:35 ` Re: [SQL] can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
@ 1998-08-04 11:12 ` D'Arcy J.M. Cain <darcy@druid.net>
1998-08-04 12:26 ` Re: [SQL] can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
0 siblings, 1 reply; 7+ messages in thread
From: darcy@druid.net @ 1998-08-04 11:12 UTC (permalink / raw)
To: joden@lee.k12.nc.us; +Cc: pgsql-sql
Thus spake James Olin Oden
> > Thus spake James Olin Oden
> > > I know this is probably a strange question, but can you give a column
> > > name an alias? The reason I ask is because I have recently realized I
> >
> > SELECT table1.oid AS custnum, table2.oid AS salesman FROM ...
> >
>
> OK, I get that, but what if you want to say:
>
> SELECT table1.custnum, table1.name, table2.invoicenum from table1, table2
>
> WHERE table1.custnum = table2.custnum;
>
> and without using the AS clause table1.custnum is pointing to table1.oid?
> The idea is in perhaps the creation of the table to do something like the AS
> clause, so that I don't have to "know" later that custnum (the key field) is
> actually the oid column. The end result with this is to hide the
> implementation details of the database from those querying it. I might be
> really reaching, but it would be nice if something like this is a
> available...james
I don't think so. Better use a sequence instead. You shouldn't be
using OID as a key anyway. You lose the value if you dump and reload.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] can a column be aliased?
1998-08-03 16:04 can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 17:17 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
1998-08-03 17:35 ` Re: [SQL] can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-04 11:12 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
@ 1998-08-04 12:26 ` James Olin Oden <joden@lee.k12.nc.us>
0 siblings, 0 replies; 7+ messages in thread
From: James Olin Oden @ 1998-08-04 12:26 UTC (permalink / raw)
To: D'Arcy J.M. Cain <darcy@druid.net>; +Cc: pgsql-sql
> I don't think so. Better use a sequence instead. You shouldn't be
> using OID as a key anyway. You lose the value if you dump and reload.
>
Ah...there's the rub. Well, I haven't been doing that anyway; I was merely trying
to explore the possiblity of doing so after I heard some users ask about it. At
first thought I had the reservation of it not being portable, but with your
thought (they change after a dump and reload) I can see that's a _real_ bad idea.
Thanks...james
> --
> D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
> http://www.druid.net/darcy/ | and a sheep voting on
> +1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] can a column be aliased?
1998-08-03 16:04 can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 17:17 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
@ 1998-08-03 18:56 ` Roderick A. Anderson <raanders@altoplanos.net>
1998-08-04 11:38 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
1 sibling, 1 reply; 7+ messages in thread
From: Roderick A. Anderson @ 1998-08-03 18:56 UTC (permalink / raw)
To: D'Arcy J.M. Cain <darcy@druid.net>; +Cc: pgsql-sql
On Mon, 3 Aug 1998, D'Arcy J.M. Cain wrote:
> Thus spake James Olin Oden
> > I know this is probably a strange question, but can you give a column
> > name an alias? The reason I ask is because I have recently realized I
>
> SELECT table1.oid AS custnum, table2.oid AS salesman FROM ...
>
Hot as flame bait, but is the AS a SQL92 standard? Coming from an Oracle
background I used
select table1.oid custnum,
table2.oid salesman
from ...
TIA,
Rod
--
Roderick A. Anderson
raanders@altoplanos.net Altoplanos Information Systems, Inc.
Voice: 208.765.6149 212 S. 11th Street, Suite 5
FAX: 208.664.5299 Coeur d'Alene, ID 83814
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] can a column be aliased?
1998-08-03 16:04 can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 17:17 ` Re: [SQL] can a column be aliased? D'Arcy J.M. Cain <darcy@druid.net>
1998-08-03 18:56 ` Re: [SQL] can a column be aliased? Roderick A. Anderson <raanders@altoplanos.net>
@ 1998-08-04 11:38 ` D'Arcy J.M. Cain <darcy@druid.net>
0 siblings, 0 replies; 7+ messages in thread
From: darcy@druid.net @ 1998-08-04 11:38 UTC (permalink / raw)
To: raanders@altoplanos.net; +Cc: pgsql-sql
Thus spake Roderick A. Anderson
> > Thus spake James Olin Oden
> > > I know this is probably a strange question, but can you give a column
> > > name an alias? The reason I ask is because I have recently realized I
> >
> > SELECT table1.oid AS custnum, table2.oid AS salesman FROM ...
> >
>
> Hot as flame bait, but is the AS a SQL92 standard? Coming from an Oracle
Yes it is.
> background I used
>
> select table1.oid custnum,
> table2.oid salesman
> from ...
This is accepted by the standard as well but doesn't seem to be accepted
by PostgreSQL. Does Oracle accept AS?
<select list> ::=
<asterisk>
| <select sublist> [ { <comma> <select sublist> }... ]
<select sublist> ::=
<derived column>
| <qualifier> <period> <asterisk>
<derived column> ::= <value expression> [ <as clause> ]
<as clause> ::= [ AS ] <column name>
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~1998-08-04 12:26 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-08-03 16:04 can a column be aliased? James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 17:17 ` D'Arcy J.M. Cain <darcy@druid.net>
1998-08-03 17:35 ` James Olin Oden <joden@lee.k12.nc.us>
1998-08-04 11:12 ` D'Arcy J.M. Cain <darcy@druid.net>
1998-08-04 12:26 ` James Olin Oden <joden@lee.k12.nc.us>
1998-08-03 18:56 ` Roderick A. Anderson <raanders@altoplanos.net>
1998-08-04 11:38 ` D'Arcy J.M. Cain <darcy@druid.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox