Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

mySQL help

rickysririckysri Member Posts: 21
What seems to be wrong with the following message....

Earlier I had create a table named Person with PersonID as a primary key (unqiue identifier) and most of the other table created had the personID as foreign key like Employee,Volunteer and skill So i have created the personID as a foreign key in each of these table that references the Person table(personID).....

The mistake was that the datatype declared for personID was varchar(30) instead it ought to be renamed integer So I tried using the alter table syntax such as

Alter table Person modify personID integer not null ;
There seems to be an error error 1064 saying you have an error in your syntax...

i also tried several ways - dropping the primary key such as
Alter table Person drop primary key Person_personID_pk;

I got an Error 1025 Error on rename of hospital/#sql 122 to rename "hosital.... etc

I dont know where I am going wrong. I am a newbie to mySQL....

Can anybody help me asap?... I am using mySQL version 5.0

Sriram

Comments

  • quotientquotient Member Posts: 62
    : What seems to be wrong with the following message....
    :
    : Earlier I had create a table named Person with PersonID as a primary key (unqiue identifier) and most of the other table created had the personID as foreign key like Employee,Volunteer and skill So i have created the personID as a foreign key in each of these table that references the Person table(personID).....
    :
    : The mistake was that the datatype declared for personID was varchar(30) instead it ought to be renamed integer So I tried using the alter table syntax such as
    :
    : Alter table Person modify personID integer not null ;
    : There seems to be an error error 1064 saying you have an error in your syntax...
    :
    : i also tried several ways - dropping the primary key such as
    : Alter table Person drop primary key Person_personID_pk;
    :
    : I got an Error 1025 Error on rename of hospital/#sql 122 to rename "hosital.... etc
    :
    : I dont know where I am going wrong. I am a newbie to mySQL....
    :
    : Can anybody help me asap?... I am using mySQL version 5.0
    :
    : Sriram
    :

    You are using the wrong syntax for Alter Table. There is only ONE primary per table, so you don't need, and you can't specify it. Here's what you should do (The CAPITALS are your mistakes):
    --------------------------------------------------------------------
    alter table Person modify COLUMN personID integer not null;
    --------------------------------------------------------------------

    Also, this personID should be automatic and be your primary key as well, so you should put:
    --------------------------------------------------------------------
    alter table Person modify COLUMN personID integer not null AUTO_INCREMENT PRIMARY KEY;
    --------------------------------------------------------------------

    This should do the trick.

    Francis
Sign In or Register to comment.