Reputation: 13
I've been looking at a SQL query & output and am trying to figure out the impact the "$" would have in the query if any.
I cannot find anything about the use of the "$" symbol and want to make sure. I've searched the w3 schools, here, and Oracle documentation (as I'm using an Oracle database)
select * from v$example_users
The above is the code that I'm looking at. Will the "$" symbol in the middle of the table name? I.e. is the table called "v$example_users" or does the "$" somehow affect the table?
Upvotes: 1
Views: 9515
Reputation: 48810
Most Oracle identifiers (table names, column names, etc.) you see in the wild usually include only alphanumeric characters. This is largely because it's easy to type and it reduces confusion with math operators, parenthesis, and other delimiters. This is also true for all databases I know.
However, you can actually use other symbols for table names (or other "objects") if you want to. If you do, you will probably need to quote the name -- every time. That is, when you create
the table, when you insert
a row, when you delete
and update
it, and on every single select
query where you use it. It's perfectly legal, so if you need it, use it.
And, there's no performance penalty to pay. For Oracle there's no difference.
For example:
create table "Car+Price" (
id number(6),
"list&price" number(6),
"%discount" number(3),
"used?" number(1)
);
But then a query would be:
select id, "list&price", "%discount"
from "Car+Price"
where "used?" = 1;
See? Works! Does it look nice? er... not really. Besides, it looks quite error prone to me.
In my opinion, I would strongly recommend against using it (if possible) since it makes code harder to read, it's more difficult to debug, some ORMs don't really deal well with it, and a myriad of other reasons.
Just stay away from it, as long as you can.
Upvotes: -1
Reputation: 311508
There's no special functionality to the $
character.
The v$
views are public synonyms of Oracle's dynamic performance views. They are given these "unconventional" names to make them easy to recognize.
Upvotes: 2