|
|
|
|
|
|
| Author |
Message |
kaushal.rajesh@gmail.com *nix forums beginner
Joined: 13 Jan 2006
Posts: 3
|
Posted: Mon Jul 17, 2006 6:27 am Post subject:
object created in a database using reserved word, 'table'
|
|
|
Hi,
We can create objects name in a sybase database using reserved
keywords, if we enclose the keyword with square bracket. Ex:
We can not create a table with the name, 'table' but we can create a
table with the name [table].
I have created a table using reserved word in Sybase as:
1>create table [table] ( id int, name char(10))
2>go
Now, when I select from sysobjects, it shows the table name without the
square bracket
1> select name from sysobjects
2> go
name
---------------
table
When I select from this table, using object name 'table', I get syntax
error.
1> select * from table
2> go
Incorrect syntax near the keyword 'table'.
But, if I select from the table using object name, [table] it runs
properly.
1> select * from [table]
2> go
id name
----------- ----------
100 apple
101 mango
=================
I would like to know:
Where and how the sybase stores this information internally?
Does it set any status bit when we use any reserved keywords in the
object names?
How do I check the full object name ( with square bracket ) if I have
created such objects?
Thanking you in advance
Regards
Rajesh Kaushal |
|
| Back to top |
|
 |
Carl Kayser *nix forums beginner
Joined: 25 May 2005
Posts: 42
|
Posted: Mon Jul 17, 2006 10:52 am Post subject:
Re: object created in a database using reserved word, 'table'
|
|
|
<kaushal.rajesh@gmail.com> wrote in message
news:1153117663.733296.236630@m79g2000cwm.googlegroups.com...
| Quote: | Hi,
We can create objects name in a sybase database using reserved
keywords, if we enclose the keyword with square bracket. Ex:
We can not create a table with the name, 'table' but we can create a
table with the name [table].
I have created a table using reserved word in Sybase as:
1>create table [table] ( id int, name char(10))
2>go
Now, when I select from sysobjects, it shows the table name without the
square bracket
1> select name from sysobjects
2> go
name
---------------
table
When I select from this table, using object name 'table', I get syntax
error.
1> select * from table
2> go
Incorrect syntax near the keyword 'table'.
But, if I select from the table using object name, [table] it runs
properly.
1> select * from [table]
2> go
id name
----------- ----------
100 apple
101 mango
=================
I would like to know:
Where and how the sybase stores this information internally?
Does it set any status bit when we use any reserved keywords in the
object names?
How do I check the full object name ( with square bracket ) if I have
created such objects?
Thanking you in advance
Regards
Rajesh Kaushal
|
Apaprently the square bracket is an implicit delimiter (for MS compatiblity)
whereas double quotes are explicit delimiteers, e.g.,
set quoted_identifier on
create table [fu bar]
(a int)
create table "'fu bar'"
(a int)
select name
from sysobjects
where id > 99
name
------------------------------
fu bar
'fu bar'
(2 rows affected)
drop table "fu bar"
drop table ['fu bar']
select name
from sysobjects
where id > 99
name
------------------------------
(0 rows affected)
(Note the usage reversal between create and drop above.) They are
interchangeable as far as I can tell - in which case you don't want either
the brackets or quotes stored as part of the name. So Sybase doesn't. If
you really want them then I suppose that you could create tables with names
[[fubar]] (or equivalently "[fubar]") and so forth in the DDL.
What I do find to be inconsistent is that the quotes ARE stored as part of
the name for usertypes and indexes (but not index constraints!). I haven't
checked for square brackets in these cases but strongly suspect that they
are also stored. |
|
| Back to top |
|
 |
kaushal.rajesh@gmail.com *nix forums beginner
Joined: 13 Jan 2006
Posts: 3
|
Posted: Tue Jul 18, 2006 6:42 am Post subject:
Re: object created in a database using reserved word, 'table'
|
|
|
Thanks a lot! Carl.
Regds
Rajesh Kaushal
Carl Kayser wrote:
| Quote: | kaushal.rajesh@gmail.com> wrote in message
news:1153117663.733296.236630@m79g2000cwm.googlegroups.com...
Hi,
We can create objects name in a sybase database using reserved
keywords, if we enclose the keyword with square bracket. Ex:
We can not create a table with the name, 'table' but we can create a
table with the name [table].
I have created a table using reserved word in Sybase as:
1>create table [table] ( id int, name char(10))
2>go
Now, when I select from sysobjects, it shows the table name without the
square bracket
1> select name from sysobjects
2> go
name
---------------
table
When I select from this table, using object name 'table', I get syntax
error.
1> select * from table
2> go
Incorrect syntax near the keyword 'table'.
But, if I select from the table using object name, [table] it runs
properly.
1> select * from [table]
2> go
id name
----------- ----------
100 apple
101 mango
=================
I would like to know:
Where and how the sybase stores this information internally?
Does it set any status bit when we use any reserved keywords in the
object names?
How do I check the full object name ( with square bracket ) if I have
created such objects?
Thanking you in advance
Regards
Rajesh Kaushal
Apaprently the square bracket is an implicit delimiter (for MS compatiblity)
whereas double quotes are explicit delimiteers, e.g.,
set quoted_identifier on
create table [fu bar]
(a int)
create table "'fu bar'"
(a int)
select name
from sysobjects
where id > 99
name
------------------------------
fu bar
'fu bar'
(2 rows affected)
drop table "fu bar"
drop table ['fu bar']
select name
from sysobjects
where id > 99
name
------------------------------
(0 rows affected)
(Note the usage reversal between create and drop above.) They are
interchangeable as far as I can tell - in which case you don't want either
the brackets or quotes stored as part of the name. So Sybase doesn't. If
you really want them then I suppose that you could create tables with names
[[fubar]] (or equivalently "[fubar]") and so forth in the DDL.
What I do find to be inconsistent is that the quotes ARE stored as part of
the name for usertypes and indexes (but not index constraints!). I haven't
checked for square brackets in these cases but strongly suspect that they
are also stored. |
|
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Mon Dec 01, 2008 9:52 pm | All times are GMT
|
|
Mortgage Calculator | Cell Phones | Cheapest mobile phones | Credit Cards | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|