By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,291 Members | 3,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,291 IT Pros & Developers. It's quick & easy.

column name can't include character '-'

P: n/a
Niy
why?
Jul 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a

"Niy" <ni***@hotmail.com> wrote in message
news:55**************************@posting.google.c om...
| why?

that's the rules

also, '-' has special meaning to the parser

however, just like Access and VB use [] delimiters, Oracle (and I believe
this is standard ANSI SQL) uses "" delimiters to allow 'illegal' column (and
other object) names -- but I wouldn't recommend this

just use _ instead of -, and life with oracle will be just fine
;-{) mcs
Jul 19 '05 #2

P: n/a
x
IF you had a tale with columns

a number
b number
a-b number

what would return

select a-b from x

?
Jul 19 '05 #3

P: n/a
your question is not clear, but it looks like you need to do research on
expressions -- take some time reading the Oracle SQL Reference manual, and
running some tests

you will find that oracle does not support derived columns in table
definitions, but it does in views

;-{ mcs

"x" <x@x.hr> wrote in message news:c1**********@ls219.htnet.hr...
| IF you had a tale with columns
|
| a number
| b number
| a-b number
|
| what would return
|
| select a-b from x
|
| ?
|
|
Jul 19 '05 #4

P: n/a
"x" <x@x.hr> wrote in message news:<c1**********@ls219.htnet.hr>...
IF you had a tale with columns

a number
b number
a-b number

what would return

select a-b from x

?


Obviously a minus b:

SQL> @test
SQL> create table marktest3 (
2 a number, b number, "a-b" number);

Table created.

SQL> desc marktest3
Name Null? Type
----------------------------------------- --------
----------------------------
A NUMBER
B NUMBER
a-b NUMBER
SQL>
SQL> insert into marktest3 values (6,4,9);

1 row created.

SQL> commit;

Commit complete.

SQL>
SQL> select a, b, a-b, "a-b" from marktest3;

A B A-B a-b
---------- ---------- ---------- ----------
6 4 2 9

SQL>
SQL> drop table marktest3;

Table dropped.

If you need a col "a-b" it would be better to name it a_minus_b,
diff_a_b, or some such than use double quotes to create potential
problems for users.

HTH -- Mark D Powell --
Jul 19 '05 #5

P: n/a
| SQL> select a, b, a-b, "a-b" from marktest3;
|
| A B A-B a-b
| ---------- ---------- ---------- ----------
| 6 4 2 9
|
| SQL>
| SQL> drop table marktest3;
|
| Table dropped.
|
| If you need a col "a-b" it would be better to name it a_minus_b,
| diff_a_b, or some such than use double quotes to create potential
| problems for users.
|
| HTH -- Mark D Powell --

unless there's a specific identified processing advantage to storing a
derived value, the "a-b" or a_minus_b column really should be implemented
via a view, not included in the table.
(function-based indexes would be an alternative if searches are often done
on the derived value, if an index would be effective in those searches)

-- mcs
Jul 19 '05 #6

P: n/a
"Mark C. Stock" <mcstockX@Xenquery .com> wrote in message news:<OL********************@comcast.com>...
| SQL> select a, b, a-b, "a-b" from marktest3;
|
| A B A-B a-b
| ---------- ---------- ---------- ----------
| 6 4 2 9
|
| SQL>
| SQL> drop table marktest3;
|
| Table dropped.
|
| If you need a col "a-b" it would be better to name it a_minus_b,
| diff_a_b, or some such than use double quotes to create potential
| problems for users.
|
| HTH -- Mark D Powell --

unless there's a specific identified processing advantage to storing a
derived value, the "a-b" or a_minus_b column really should be implemented
via a view, not included in the table.
(function-based indexes would be an alternative if searches are often done
on the derived value, if an index would be effective in those searches)

-- mcs


Mark, very true. I was just trying to make a point about meaningful
names and should have thought of that also.

Saving calculated values should only be done where either the
variables of the calculation are not retained with the result such as
in a history table OR the cost of calculating the result is too
expensive. Our electronics and prototype lab calculates values that
often take significant time per calculation so even it the variable
values are saved it is not feasible to recalculate the results for
display.

-- Mark D Powell --
Jul 19 '05 #7

P: n/a
Niy
Thanks for the reply.

In v$transaction, you can see
DSCN-B, DSCN-W columns, how
to select them?
Jul 19 '05 #8

P: n/a

"Niy" <ni***@hotmail.com> wrote in message
news:55**************************@posting.google.c om...
| Thanks for the reply.
|
| In v$transaction, you can see
| DSCN-B, DSCN-W columns, how
| to select them?
very observant -- you have to (always) use double-quotes to select these
columns, and type them in upper case, because oracle (why, oh, why?) used
non-conforming column names here

the only exception to 'always' is when you do a SELECT *

select addr, "DSCN-B", "DSCN-W"
from v$transaction

;-{ mcs
Jul 19 '05 #9

P: n/a

"Mark D Powell" <Ma*********@eds.com> wrote in message
news:26**************************@posting.google.c om...
| "Mark C. Stock" <mcstockX@Xenquery .com> wrote in message
news:<OL********************@comcast.com>...
| > | SQL> select a, b, a-b, "a-b" from marktest3;
| > |
| > | A B A-B a-b
| > | ---------- ---------- ---------- ----------
| > | 6 4 2 9
| > |
| > | SQL>
| > | SQL> drop table marktest3;
| > |
| > | Table dropped.
| > |
| > | If you need a col "a-b" it would be better to name it a_minus_b,
| > | diff_a_b, or some such than use double quotes to create potential
| > | problems for users.
| > |
| > | HTH -- Mark D Powell --
| >
| > unless there's a specific identified processing advantage to storing a
| > derived value, the "a-b" or a_minus_b column really should be
implemented
| > via a view, not included in the table.
| > (function-based indexes would be an alternative if searches are often
done
| > on the derived value, if an index would be effective in those searches)
| >
| > -- mcs
|
| Mark, very true. I was just trying to make a point about meaningful
| names and should have thought of that also.
|
| Saving calculated values should only be done where either the
| variables of the calculation are not retained with the result such as
| in a history table OR the cost of calculating the result is too
| expensive. Our electronics and prototype lab calculates values that
| often take significant time per calculation so even it the variable
| values are saved it is not feasible to recalculate the results for
| display.
|
| -- Mark D Powell --

point well made, and good real-world example

;-{ mcs
Jul 19 '05 #10

P: n/a
x
Thank you for your answers, but I didn't ask what would select a-b return, I
just answered to 'why column name can't include character '-''

My point is that in that cese select a-b would be confusing. select "a-b" is
something else.


Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.