Solved

Sybase 11 - Create a table with AUTOINCREMENT field

Posted on 2003-11-04
4
20,120 Views
Last Modified: 2007-12-19
Hi,

I want to create a table with an autoincrement field, with the following syntax:

CREATE TABLE auto1
( primary1 INTEGER NOT NULL DEFAULT AUTOINCREMENT,
data1 INTEGER NOT NULL,
PRIMARY KEY ( primary1 ) );

Sybase reports with an error:

Incorrect syntax near the keyword 'DEFAULT'.

I've tried every possible combination, such as removing NOT NULL, DEFAULT, etc.. However, the only way to create the table successfully is to remove the AUTOINCREMENT syntax.

Or is there any option in Sybase to turn off the autoincrement feature?

Anyone can help? Thank you.
0
Comment
Question by:keewooi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
ahoor earned 125 total points
ID: 9677068
I suppose you use Sybase ASE? autoincrement is not Sybase-syntax, use"identity" instead.

CREATE TABLE auto1
( primary1 numeric(10) identity,
data1 INTEGER NOT NULL,
PRIMARY KEY ( primary1 ) )

Also use the numeric datatype for identity columns, you get to decide how big it should be yourself. Since you wanted to use integer I think numeric(10) will do.

0
 

Author Comment

by:keewooi
ID: 9677097
Thank you so much, it has solved my problem!

Now, can you please tell me, whether or not it's fine to use numeric(10) to replace INT?
0
 
LVL 3

Expert Comment

by:ahoor
ID: 9677239
Sure it's fine... numeric(10) means you can have numbers up to 9.999.999.999. That's almost 7.000.000.000 more than an integer highest value.
0
 

Author Comment

by:keewooi
ID: 9677268
Okay. Thans for the sulution. I appreciate that.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By reading this blog, MSPs will gain insight into how to improve communications with their clients as well as establish a more profitable business.
Invest in your employees with these five simple steps to improve employee engagement and retention.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question