Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column labels

Status
Not open for further replies.

eaglejohn

Programmer
Mar 10, 2004
12
US
when creating a view. Is there a way to name your columns in lower case?
 
You should be able to name your columns in lower case by typing them in lower case.

Tim
 
i've tried that and the columns display in upper case. see below.


CREATE OR REPLACE VIEW mv_time_on_test_junk (
Sample,
sampled_date )
AS
SELECT SAMPLE.SAMPLE_NUMBER as Sample, SAMPLE.SAMPLED_DATE as sampled_date
FROM SAMPLE
 
Hmmm, I just tried a test using code similar to yours and it worked just fine. Maybe one of the other gurus can shed some light.

Tim
 
I actually found a guru myself. he suggested putting quotes around the name. ex: "Sample"

it worked!!

But beware. there seems to be a problem doing a select on that field.

Thansk, John
 
Yes I noticed that sample is a reserved word. You should try and avoid these when using column aliases. If you have to absolutely use them, put square brackets around them:

[Sample] or [Date] as examples

Tim
 
1) The syntax in your example is not valid - are you sure you are using SQL Server?

2) SAMPLE is not a reserved word - you don't need to use identifiers around it.

3) The case of the column names in the resultset is dependent on how you specify them when querying the table/view:

Code:
CREATE VIEW myview
AS

SELECT c1 AS Column1, c2 AS Column2
FROM mytable
GO

--returns Column1, Column2
SELECT * FROM myview

--returns column1, column2
SELECT column1, column2 FROM myview

--returns coLuMN1, COLUMN2
SELECT coLuMN1, COLUMN2 FROM myview

--James
 
SAMPLE is a keyword but it's not a reserved word. You only have to use identifiers around reserved words - although it is not good practice to use reserved words for object names.

--James
 
Code:
CREATE OR REPLACE VIEW mv_time_on_test_junk (
   Sample,
   sampled_date )...
Oracle?

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
I am using SQL navigator pointing to Oracle.
Originally i didn't want to use the select [field1] to display the field in lower case because i was using (select *). I have re-thought it and will get the columns in lower case when querying the view.

thanks for everyones help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top