Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread How-To Reindex tables?
Wed, Feb 4 2009 6:11 AMPermanent Link

James Relyea
Is there any command to reindex tables, or is Optimize it?

When I run: "optimize tablename", I seem to be OK.

I am getting errors whenever I specify an index name like "optimize tablename 'index name'.

This is the error syntax:
"ElevateDB Error #700 An error was found in the statement at line 2 and column 30
(Expected index name but instead found 'my index name')"

The index name is not misspelled.

Thanks

Smile
jr
Wed, Feb 4 2009 7:35 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

James


From the manual

Syntax
OPTIMIZE TABLE <TableName>
[USING <IndexName>]

Roy Lambert [Team Elevate]
Wed, Feb 4 2009 9:28 AMPermanent Link

James Relyea
I think I found my problem: Indexes without spaces worked. Indexes with spaces enclosed in
single quotes throw the error below. So, how do I execute Optimize statements and use
indexes with spaces?

Smile
jr





James Relyea wrote:

Is there any command to reindex tables, or is Optimize it?

When I run: "optimize tablename", I seem to be OK.

I am getting errors whenever I specify an index name like "optimize tablename 'index name'.

This is the error syntax:
"ElevateDB Error #700 An error was found in the statement at line 2 and column 30
(Expected index name but instead found 'my index name')"

The index name is not misspelled.

Thanks

Smile
jr
Wed, Feb 4 2009 9:56 AMPermanent Link

"Eduardo [HPro]"
James

My suggestion is "never" use space in database objects (database, tables,
fields, indexes, etc).

Eduardo

Wed, Feb 4 2009 10:10 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

James,

1. As Roy indicated, the syntax you are using for OPTIMIZE is wrong -
you are missing the word "USING"

2. Database object names that contain spaces must be enclosed in double
quotes, not single quotes. For example:
OPTIMIZE "My Table Name" USING "My Index Name"
Single quotes are used only to delimit string literals.

3. If you want to rebuild the indexes then you must use REPAIR TABLE,
not OPTIMIZE TABLE.

--
Fernando Dias
[Team Elevate]
Wed, Feb 4 2009 10:13 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

James


The rule seems to be double space for system objects and single space for data so try wrapping in double spaces. However, I will agree with Eduado - don't use spaces for table, column, stored procedures, index names etc

Roy Lambert [Team Elevate]
Wed, Feb 4 2009 11:05 AMPermanent Link

James Relyea
Thanks everyone!

Double quotes work. For the very first time in over 13 years, I chose to use spaces in DB
object name.... and I got bit by it! I won't be using spaces again!


Smile
jr







Roy Lambert wrote:

James


The rule seems to be double space for system objects and single space for data so try
wrapping in double spaces. However, I will agree with Eduado - don't use spaces for table,
column, stored procedures, index names etc

Roy Lambert [Team Elevate]
Wed, Feb 4 2009 12:10 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

James


I also developed a habit of prefacing column names with an underscore - pretty much guarantees no collision with reserved words.

Roy Lambert
Tue, Feb 17 2009 11:30 AMPermanent Link

"James Relyea"
I was doing that but found it handier use the data type in the column name.
Helps me not use reserved words too. (eg EmpId     could be a variety of
data types so I usually prefix them like    intEmpId  varEmpId    or idEmpId
for GUIDs depending on the app. It's saved me debugging time down the road
when I've not looked at the app for a while. I do the same for .Net object
types too for the same reason.

Smile
jr


"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:E67D3A60-579B-488E-A518-89312642E663@news.elevatesoft.com...
> James
>
>
> I also developed a habit of prefacing column names with an underscore -
> pretty much guarantees no collision with reserved words.
>
> Roy Lambert
>

Image