|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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).] |
|
#3
|
|||
|
|||
|
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? |
|
#4
|
|||
|
|||
|
Try O'Reilly's book. It good and I believe it may be the only one.
Code Guy |
|
#5
|
|||
|
|||
|
Must agree
The O'Reilly book but also the manual and the forum you are on now - nothing beats hands on knowledge shared. |
|
#6
|
||||
|
||||
|
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 ************************************************************* |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Auto Increment Beginning at 1000 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|