By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,254 Members | 2,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

How can i effect Autoincrement in my table

P: 10
I created a table of five columns as follows
crop_id, crop_type, crop_name, cultivation_yrs, local_name.

I want to make the crop_id to be the primary key, and also to be autoincremental as well as serve as a reference to a foreign key in the main database table which is a different table altogerther.

I am able to create the primary key and the foreign key but i am not able to achieve the autoincrement

Please how can i achieve this.
Nov 27 '09 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
You can redefine (drop and create again) the table and define the type for column crop_id as 'serial'.
Or you can create now sequence (CREATE SEQUENCE ,,,) and define default for column crop_id as nextval('seqnece_name') (ALTER TABLE ..)
Nov 27 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.