RE: Spaces in alias
Posted in 1998
>---------- From: David Williams[SMTP:djw@smooth1.demon.co.uk] >Sent: Wednesday, February 25, 1998 11:34 PM >In article <6d1pk1$kpn$1@nnrp1.dejanews.com>, bes@hnc.com writes >>Is there any way to put spaces in an alias in a select statement? >> >>In Informix you can do this: >> >>SELCT ITEM_ID AS "Item ID" FROM TABLE1.... >> >>Is there an Informix equivalent? Isn't this a self-answering question? As in "Informix does this; what is Informix's equivalent to this?"? > Why do you need to? >Almost all computer languages do not support spaces in identifiers. SQL is an exception; it supports delimited identifiers. Informix supports delimited identifiers when the DELIMIDENT environment variable is set. It should not be used casually; if you are not absolutely consistent in using single quotes to enclose strings and only using double quotes to enclose delimited identifiers, you will rewrite your SQL with identifiers in place of strings, which will generally yield lots of syntax errors. If you want to send your co-workers into apopleptic fits, create a table like this: CREATE TABLE "Oh Bother!" ( "Do Not Remove" SERIAL NOT NULL PRIMARY KEY CONSTRAINT "PK Oh Bother!", "This Column!" CHAR(10) NOT NULL, "@(#)SCCS" VARCHAR(255), "$Ident$" DECIMAL(10) NOT NULL ); Set DELIMIDENT=Yes in the environment before trying this. Afterwards, you have to know exactly what you're doing (and have DELIMIDENT set) to be able to do anything with this table. > Try > select ITEM_ID "Item ID" FROM TABLE1... That should work, as will the 'SELECT Item_ID AS "Item ID" ...' notation. Yours, Jonathan Leffler (jleffler@visa.com) #include <bother.ms-exchange.h>