niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Sybase
object created in a database using reserved word, 'table'
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
kaushal.rajesh@gmail.com
*nix forums beginner


Joined: 13 Jan 2006
Posts: 3

PostPosted: Mon Jul 17, 2006 6:27 am    Post subject: object created in a database using reserved word, 'table' Reply with 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
Back to top
Carl Kayser
*nix forums beginner


Joined: 25 May 2005
Posts: 42

PostPosted: Mon Jul 17, 2006 10:52 am    Post subject: Re: object created in a database using reserved word, 'table' Reply with quote

<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

PostPosted: Tue Jul 18, 2006 6:42 am    Post subject: Re: object created in a database using reserved word, 'table' Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Mon Dec 01, 2008 9:52 pm | All times are GMT
navigation Forum index » Databases » Sybase
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Move Oracle 10g database to another location Selt Server 0 Fri Jul 21, 2006 2:14 pm
No new posts How to ALTER a table using the ALTOBJ procedure Serge Rielau IBM DB2 1 Fri Jul 21, 2006 1:06 pm
No new posts database Share Memory Limit (2 GB ) in a Instance is tota... sadanjan@gmail.com IBM DB2 0 Fri Jul 21, 2006 12:57 pm
No new posts how can i use fstream object to clear file's content? horneye C++ 2 Fri Jul 21, 2006 7:52 am
No new posts CORBA object used in Vector niks C++ 0 Fri Jul 21, 2006 7:45 am

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
[ Time: 0.2539s ][ Queries: 16 (0.1667s) ][ GZIP on - Debug on ]