Changing PRIMARY KEY

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Changing PRIMARY KEY

Post by icesolid »

My Indexes section in phpMyAdmin for my table looks like this:

Code: Select all

Keyname     Type         Cardinality    Action     Field
PRIMARY    PRIMARY            7                     id
                                                    control_number
How do I remove the control_number from that?

I want the control_number field to be my FOREIGN KEY, I do not know how I ended up doing this. :roll:
Last edited by icesolid on Sat Sep 08, 2007 9:48 am, edited 1 time in total.
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Post by josa »

If you click the edit icon under Action, chose -- Ignore -- in the drop down for control_number and then click save, it should go away.

/josa
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

To add a foreign key all I need is this code correct?

Code: Select all

ALTER TABLE ba_forms ADD FOREIGN KEY (control_number) REFERENCES cases(control_number)
Because whenever I run that code above I just get control_number as INDEX in ba_forms.

I am running MyISAM, is FOREIGN KEYS only supported in InnoDB?
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Post by josa »

As far as I know - yes.

/josa
Post Reply