473,408 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to have a auto increment field with default value of 1000

Hi All,

I am using server version: 4.1.11-nt on windows 2000.

I want to create a table with ID as auto increment and initialise it
with a starting value of 1000.

I am trying to do following

DROP TABLE IF EXISTS `demo`;
CREATE TABLE `demo` (
id bigint not null auto_increment=1000,
`Author_Name` tinytext,
`Authors_Email` varchar(255) default '',
`Author_Password` varchar(8) default '',
`Author_Zipcode` int(6) default NULL,
`Author_DOB` date default NULL,
PRIMARY KEY (id)
) DEFAULT CHARSET=latin1;

The error i am getting is shown below

ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that
corresponds to your MySQL server version for the right syntax to use
near '=1000
,
`Author_Name` tinytext,
`Authors_Email` varchar(255) default '',
`A' at line 2
From MySQL manual i learned that innoDB engine cannt have a default

value.

Please suggest me how to create a table so that it gets initialised by
1000 value (First record starts from 1000).

Thanks for your advices.

Regards,
Kajol

Jul 23 '05 #1
2 4664
On 21/04/2005, Kajol wrote:
Please suggest me how to create a table so that it gets initialised by
1000 value (First record starts from 1000).


For MyISAM tables you can use:

CREATE TABLE foo (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE = MyISAM AUTO_INCREMENT = 1000;

For InnoDB you need a workaround:

CREATE TABLE foo (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE = InnoDB;
INSERT INTO foo VALUES(999);
DELETE FROM foo WHERE id=999;

--
felix

--
felix
Jul 23 '05 #2
Hello Sir,
Thank u so much.U solve my problem.

Regards,
Kajol

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David P. Donahue | last post by:
I'm using the following code to add a row to a table (for holding images) in my database (obtained from http://www.codeproject.com/aspnet/image_asp.asp?df=100&forumid=38225&select=1038401): ...
2
by: Brian Bendtsen | last post by:
Hi Is there at way to reset a table and set the auto increment value to 1000? /Brian Bendtsen
9
by: Eitan M | last post by:
Hello, How can I find the last indentity of auto-increment field ? (If I inserted a record, then the auto-increment field is build automatically, and I want to find its value). Thanks :)
13
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
1
by: rjames.clarke | last post by:
I am inserting a record in to a mysql database. I'd like to know the record number of that record. I use a index field which is auto-incremented. Is there any way to get a field value returned...
2
by: praveena mani | last post by:
how to specify a default value for auto increment?? for innodb engine..
8
by: boss1 | last post by:
hi all i m using oracle9i and php4 to developa webbased application. i wrote the code for auto increment in primary key field.but now i want to add a string value with that increment field when a...
3
by: Viji nellaiappan | last post by:
Greetings to all, this is my query for creating table.. CREATE TABLE `books` ( `serial_num` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT , `bk_name` VARCHAR( 200 ) NOT NULL , `qty` INT( 10 )...
3
by: paulyXvpf | last post by:
Hello, all... Just finished a handy tutorial that has helped me understand how to auto increment and post to a web page... but its only a Web User Control passing values from VB.NET method...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.