pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed"quoting" column names
4+ messages / 3 participants
[nested] [flat]
* "quoting" column names
@ 1999-07-13 12:15 Patrik Kudo <kudo@partitur.se>
1999-07-13 14:08 ` Re: [SQL] "quoting" column names Tom Lane <tgl@sss.pgh.pa.us>
1999-07-13 14:30 ` Re: [SQL] "quoting" column names Herouth Maoz <herouth@oumail.openu.ac.il>
0 siblings, 2 replies; 4+ messages in thread
From: Patrik Kudo @ 1999-07-13 12:15 UTC (permalink / raw)
To: pgsql-sql
Hi
I've been using Postgres for... well, as long as I can remember ;)
And aparently I've been using a column name wich is "almost reserved"
(i.e. cannot be used as identifer). Since upgrading to 6.5 I nolonger
can access these fields the way I've always done them. This what I've
been doing:
create table login (userid text, when datetime);
select when from login where userid = 'xxxx';
In 6.5 I have to do:
select "when" from login where userid = 'xxxx';
My question now is, should I always quote column names, just in case,
or should I only quote column names that are "almost reserved"?
/Kudo
--
ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol
Känns det oklart? Fråga på!
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] "quoting" column names
1999-07-13 12:15 "quoting" column names Patrik Kudo <kudo@partitur.se>
@ 1999-07-13 14:08 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-07-13 14:19 ` Re: [SQL] "quoting" column names Patrik Kudo <kudo@partitur.se>
1 sibling, 1 reply; 4+ messages in thread
From: Tom Lane @ 1999-07-13 14:08 UTC (permalink / raw)
To: Patrik Kudo <kudo@partitur.se>; +Cc: pgsql-sql
Patrik Kudo <kudo@partitur.se> writes:
> create table login (userid text, when datetime);
> select when from login where userid = 'xxxx';
> In 6.5 I have to do:
> select "when" from login where userid = 'xxxx';
Right ... WHEN is a keyword in CASE expressions, which didn't use to
be implemented but are now.
> My question now is, should I always quote column names, just in case,
> or should I only quote column names that are "almost reserved"?
In theory you should only have to worry about keywords that are
reserved in SQL92 but that Postgres hasn't gotten around to implementing
yet. That's a fairly short list, I think, but I do not have the
details handy. (Anyone?)
Quoting every column name in sight would make your SQL pretty unreadable
(pg_dump now does it by default ... try reading pg_dump commands :-().
Also, if you have a reserved word as a column name, you won't be able
to access the table at all using tools that don't quote column names.
Better to rename your columns if you get burnt by this.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] "quoting" column names
1999-07-13 12:15 "quoting" column names Patrik Kudo <kudo@partitur.se>
1999-07-13 14:08 ` Re: [SQL] "quoting" column names Tom Lane <tgl@sss.pgh.pa.us>
@ 1999-07-13 14:19 ` Patrik Kudo <kudo@partitur.se>
0 siblings, 0 replies; 4+ messages in thread
From: Patrik Kudo @ 1999-07-13 14:19 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
Tom Lane wrote:
>
> Patrik Kudo <kudo@partitur.se> writes:
> > create table login (userid text, when datetime);
> > select when from login where userid = 'xxxx';
> > In 6.5 I have to do:
> > select "when" from login where userid = 'xxxx';
>
> Right ... WHEN is a keyword in CASE expressions, which didn't use to
> be implemented but are now.
Ah! that explains that part...
> > My question now is, should I always quote column names, just in case,
> > or should I only quote column names that are "almost reserved"?
>
> In theory you should only have to worry about keywords that are
> reserved in SQL92 but that Postgres hasn't gotten around to implementing
> yet. That's a fairly short list, I think, but I do not have the
> details handy. (Anyone?)
The list of reserved keywords can be found at:
http://www.postgresql.org/ -> Info Central -> Documentation -> User's
Guide
-> SQL Syntax -> Key Words.
That list doesn't say which need to be quoted though.
> Quoting every column name in sight would make your SQL pretty unreadable
> (pg_dump now does it by default ... try reading pg_dump commands :-().
> Also, if you have a reserved word as a column name, you won't be able
> to access the table at all using tools that don't quote column names.
> Better to rename your columns if you get burnt by this.
Will do, will do...
/Kudo
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] "quoting" column names
1999-07-13 12:15 "quoting" column names Patrik Kudo <kudo@partitur.se>
@ 1999-07-13 14:30 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1 sibling, 0 replies; 4+ messages in thread
From: Herouth Maoz @ 1999-07-13 14:30 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Patrik Kudo <kudo@partitur.se>; +Cc: pgsql-sql
At 17:08 +0300 on 13/07/1999, Tom Lane wrote:
> In theory you should only have to worry about keywords that are
> reserved in SQL92 but that Postgres hasn't gotten around to implementing
> yet. That's a fairly short list, I think, but I do not have the
> details handy. (Anyone?)
The list of reserved words from the SQL92 spec:
ABSOLUTE, ACTION, ADD, ALL, ALLOCATE, ALTER, AND, ANY, ARE, AS, ASC,
ASSERTION, AT, AUTHORIZATION, AVG
BEGIN, BETWEEN, BIT, BIT_LENGTH, BOTH, BY
CASCADE, CASCADED, CASE, CAST, CATALOG, CHAR, CHARACTER, CHAR_LENGTH,
CHARACTER_LENGTH, CHECK, CLOSE, COALESCE, COLLATE, COLLATION, COLUMN,
COMMIT, CONNECT, CONNECTION, CONSTRAINT, CONSTRAINTS, CONTINUE, CONVERT,
CORRESPONDING, COUNT, CREATE, CROSS, CURRENT, CURRENT_DATE, CURRENT_TIME,
CURRENT_TIMESTAMP, CURRENT_USER, CURSOR
DATE, DAY, DEALLOCATE, DEC, DECIMAL, DECLARE, DEFAULT, DEFERRABLE, DEFERRED,
DELETE, DESC, DESCRIBE, DESCRIPTOR, DIAGNOSTICS, DISCONNECT, DISTINCT,
DOMAIN, DOUBLE, DROP
ELSE, END, END-EXEC, ESCAPE, EXCEPT, EXCEPTION, EXEC, EXECUTE, EXISTS,
EXTERNAL, EXTRACT
FALSE, FETCH, FIRST, FLOAT, FOR, FOREIGN, FOUND, FROM, FULL
GET, GLOBAL, GO, GOTO, GRANT, GROUP
HAVING, HOUR
IDENTITY, IMMEDIATE, IN, INDICATOR, INITIALLY, INNER, INPUT, INSENSITIVE,
INSERT, INT, INTEGER, INTERSECT, INTERVAL, INTO, IS, ISOLATION
JOIN
KEY
LANGUAGE, LAST, LEADING, LEFT, LEVEL, LIKE, LOCAL, LOWER
MATCH, MAX, MIN, MINUTE, MODULE, MONTH
NAMES, NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULL, NULLIF, NUMERIC
OCTET_LENGTH, OF, ON, ONLY, OPEN, OPTION, OR, ORDER, OUTER, OUTPUT, OVERLAPS
PAD, PARTIAL, POSITION, PRECISION, PREPARE, PRESERVE, PRIMARY, PRIOR,
PRIVILEGES, PROCEDURE, PUBLIC
READ, REAL, REFERENCES, RELATIVE, RESTRICT, REVOKE, RIGHT, ROLLBACK, ROWS
SCHEMA, SCROLL, SECOND, SECTION, SELECT, SESSION, SESSION_USER, SET, SIZE,
SMALLINT, SOME, SPACE, SQL, SQLCODE, SQLERROR, SQLSTATE, SUBSTRING, SUM,
SYSTEM_USER
TABLE, TEMPORARY, THEN, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE,
TO, TRAILING, TRANSACTION, TRANSLATE, TRANSLATION, TRIM, TRUE
UNION, UNIQUE, UNKNOWN, UPDATE, UPPER, USAGE, USER, USING
VALUE, VALUES, VARCHAR, VARYING, VIEW
WHEN, WHENEVER, WHERE, WITH, WORK, WRITE
YEAR
ZONE
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-07-13 14:30 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-07-13 12:15 "quoting" column names Patrik Kudo <kudo@partitur.se>
1999-07-13 14:08 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-07-13 14:19 ` Patrik Kudo <kudo@partitur.se>
1999-07-13 14:30 ` Herouth Maoz <herouth@oumail.openu.ac.il>
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