MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 19th, 2000, 09:33 AM
kjedwards kjedwards is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 76 kjedwards User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m
Reputation Power: 8
Hi

Can anyone please help?

I have a table with an auto increment field holding unique ID's, everything is fine, BUT I want to start the auto increment from 1000 if I try to put in a default value I just get an error.

Does anyone know how to start the auto increment from a value other than 0

Many Thanks

Kevin

Reply With Quote
  #2  
Old October 19th, 2000, 10:19 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
Just enter a 'dummy' record, and then update the record to change the id number to 999. Then the next record inserted will be 1000. After that you can delete the dummy record.

Make sure your id column type is not TINYINT, because it won't let you input a number as high as 1000. (I've seen this happen a few too many times)

[This message has been edited by rycamor (edited October 19, 2000).]

Reply With Quote
  #3  
Old October 20th, 2000, 01:40 AM
kjedwards kjedwards is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 76 kjedwards User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m
Reputation Power: 8
Hi

Many thanks it was the TINYINT that was doing it!

I have another one (Sorry) I have some fields with a default value defined, fields defined as TINYINT or CHAR always put in the default value automatically, However fields defined as VARCHAR DO NOT, am I missing something? Can you have a default value auto-entered for VARCHAR fields?

Many thanks

Kevin

PS Can anyone recommend a really good book on mySQL?

Reply With Quote
  #4  
Old October 20th, 2000, 08:37 AM
CodeGuy CodeGuy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 1 CodeGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try O'Reilly's book. It good and I believe it may be the only one.

Code Guy

Reply With Quote
  #5  
Old October 20th, 2000, 10:12 AM
des des is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 73 des User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Must agree
The O'Reilly book but also the manual and the forum you are on now - nothing beats hands on knowledge shared.

Reply With Quote
  #6  
Old October 20th, 2000, 08:35 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,381 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 7 h 38 m 58 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
Yes, you can have a default for VARCHAR fields. You set it when you create your table, or if it's already created you can use the ALTER command...

CREATE TABLE test (id INT, var VARCHAR(100) DEFAULT 'This is my Default');

or...

ALTER TABLE test CHANGE COLUMN var var VARCHAR(100) DEFAULT 'This is my default';

You'll have to have ALTER permissions. Read the manual on the alter command...it can be a big help as you learn database design...it's easier than recreating the whole table..

---John Holmes...

------------------
*************************************************************
* The manual can probably answer 90% of your questions...
*
* PHP Manual. www.php.net/manual
* MySQL Manual: www.mysql.com/documentation/mysql/bychapter
*************************************************************

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Auto Increment Beginning at 1000


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway