MySQL Forums
Forum List  »  MySQL Administrator

#1064 - You have an error in your SQL syntax; on mysql5.5.24
Posted by: Jack Legrand
Date: February 21, 2013 10:28AM

Hi all ,



I don't think i have any errors but this error can't stop showing up
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''type'( id char(1), libelleType(30), CONTRAINT pk_type PRIMARY KEY (id)' at line 1


Here is my database code that i wrote in SQL :
-- Création d'une table "type"
CREATE TABLE type (
id char(1),
libelleType char(30),
CONSTRAINT pk_type PRIMARY KEY (id)
);
-- Ajout des données dans la table "type"
INSERT INTO type (id,libelleType)
VALUES ('V', 'Visiteur médical'),
('C', 'Comptable');
-- Changement de nom de table
ALTER TABLE visiteur RENAME TO utilisateur ;
-- Ajout du champ dans utilisateur
ALTER TABLE utilisateur ADD COLUMN idType char(1) NOT NULL ;
-- Déclaration de tous les utilisateurs actuels comme des "visiteurs"
UPDATE utilisateur SET idType = 'V';
-- Déclaration de la clé étrangère "idType" en référence à "id" de la table "type"
ALTER TABLE utilisateur
ADD CONSTRAINT fk_type FOREIGN KEY (idType) REFERENCES type (id);

Best Regards;

Options: ReplyQuote


Subject
Written By
Posted
#1064 - You have an error in your SQL syntax; on mysql5.5.24
February 21, 2013 10:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.