Solved

primary key confusion

Posted on 2013-06-27
3
273 Views
Last Modified: 2013-06-28
Hi,

In phpmyadmin I cant alter tables to get the primary key.  I want to set a primary key with autonumber and I know I check on a-I on creating a field .

If you see the img I have a field with PK that I cant undo the PK and I cant add a autonumber field as a PK as I get an error (need a PK)
mysql.docx
0
Comment
Question by:jagguy
3 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39281685
Consider recreating the table.  You might write a little script to copy the data to the new table.
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39281748
You shouldn't have to recreate the table.

What do you see when you edit (Change) the record - your version of PHPMyAdmin differs from the versions I am using

Have you tried running a query to do this
ALTER TABLE tbmod1 
   CHANGE `section` `section` INT(11) NOT NULL, 
   CHANGE `q1` `q1` INT(11) NOT NULL AUTO_INCREMENT,
   DROP PRIMARY KEY, 
   ADD PRIMARY KEY(`q1`)

Open in new window

Remember though before you can make a column a auto increment the column has to have unique values otherwise it will fail.
Also check if there are any relationships setup on the table which might be interferring.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39283611
Please use image files like JPGs for screen shots.  They will open in the browsers where 'docx' files require us to start up another program.  I usually won't do that and I haven't looked at your file.
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now