forums › forums › SQLyog › SQLyog: Bugs / Feature Requests › Non-pk Auto_incriment
- This topic is empty.
-
AuthorPosts
-
-
January 17, 2007 at 5:23 am #23242
peterlaursen
Participant1) With CREATE TABLE SQLyog does everything itself.
2) With ALTER TABLE you will have to help yourself.
You will need to create an index first on the column that shall be auto-increment.
The reason is a (pretty technical) issue in MySQL with UNIQUE keys and ALTER TABLE .
and I'll have to vacuumize my memory if I shall remember all details …
An example:
1)
Start using CREATE TABLE GUI to create this:
Code:CREATE TABLE `keytest` ( `id` bigint(20) NOT NULL auto_increment, `id2` bigint(20) NOT NULL, `t` varchar(20) default NULL,
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=latin12)
Now create an index with MANAGE INDEXES like
Code:CREATE TABLE `keytest` ( `id` bigint(20) NOT NULL auto_increment, `id2` bigint(20) NOT NULL, `t` varchar(20) default NULL,
PRIMARY KEY (`id`),
KEY `id2` (`id2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin13)
ALTER TABLE GUI now lets you define:
Code:CREATE TABLE `keytest` ( `id` bigint(20) NOT NULL, `id2` bigint(20) NOT NULL auto_increment, `t` varchar(20) default NULL,
PRIMARY KEY (`id`),
KEY `id2` (`id2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1With CREATE TABLE however you can go directly to step 3!
Do you use CREATE TABLE or ALTER TABLE?
-
January 17, 2007 at 6:05 am #23243
peterlaursen
ParticipantThere was a FAQ actually: http://webyog.com/faq/28_139_en.html
This one explains why we chose NOT to let ALTER TABLE create the index
-
January 17, 2007 at 4:34 pm #23244
gigawatz
MemberThank you both for your answers. You both have been quite informative.
My apologies for not finding the FAQ and resolving this issue myself.
-
-
AuthorPosts
- You must be logged in to reply to this topic.