PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > newbie: CREATE TABLE syntax error
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
newbie: CREATE TABLE syntax error

Réponse
 
LinkBack Outils de la discussion
Vieux 06/04/2008, 00h24   #1
R.A.M.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut newbie: CREATE TABLE syntax error

Hello,
I am creating my first database in MySQL. It will contain a
table 'customers':

CREATE TABLE `rozgloszenia`.`customers` (
`customer_id` INT UNSIGNED CHARACTER SET utf8 COLLATE utf8_general_ci NOT
NULL AUTO_INCREMENT,
`town` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci,
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci,
`phone` DECIMAL(9,0) UNSIGNED CHARACTER SET utf8 COLLATE utf8_general_ci,
`first_name` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci,
`surname` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci,
PRIMARY KEY (`customer_id`),
INDEX `customer`(`town`, `email`, `phone`),
INDEX `name`(`surname`, `first_name`)
)
ENGINE = MyISAM
CHARACTER SET utf8 COLLATE utf8_general_ci;

Here is the problem:

Error executing SQL commands to create table.
MySQL Error Nr. 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 'CHARACTER SET
utf8 COLLATE utf8_general_ci NOT NULL AUTO_INCREMENT,
`town` var' at line 2

Could you me plase?
/RAM/
  Réponse avec citation
Vieux 06/04/2008, 01h05   #2
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: newbie: CREATE TABLE syntax error

R.A.M. wrote:
> Hello,
> I am creating my first database in MySQL. It will contain a
> table 'customers':
>
> CREATE TABLE `rozgloszenia`.`customers` (
> `customer_id` INT UNSIGNED CHARACTER SET utf8 COLLATE utf8_general_ci NOT
> NULL AUTO_INCREMENT,
> `town` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci,
> `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci,
> `phone` DECIMAL(9,0) UNSIGNED CHARACTER SET utf8 COLLATE utf8_general_ci,
> `first_name` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci,
> `surname` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci,
> PRIMARY KEY (`customer_id`),
> INDEX `customer`(`town`, `email`, `phone`),
> INDEX `name`(`surname`, `first_name`)
> )
> ENGINE = MyISAM
> CHARACTER SET utf8 COLLATE utf8_general_ci;
>
> Here is the problem:
>
> Error executing SQL commands to create table.
> MySQL Error Nr. 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 'CHARACTER SET
> utf8 COLLATE utf8_general_ci NOT NULL AUTO_INCREMENT,
> `town` var' at line 2


Try with:

CREATE TABLE `rozgloszenia`.`customers` (
`customer_id` UNSIGNED INT NOT NULL AUTO_INCREMENT,
`town` varchar(40),
`email` varchar(50),
`phone` UNSIGNED DECIMAL(9,0),
`first_name` VARCHAR(25),
`surname` VARCHAR(40),
PRIMARY KEY (`customer_id`),
INDEX `customer`(`town`, `email`, `phone`),
INDEX `name`(`surname`, `first_name`)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = MyISAM;

If you have phone numbers starting with a zero, then they will be stored
without the leading zero's, so a varchar may be a better option.

--

//Aho
  Réponse avec citation
Vieux 06/04/2008, 04h09   #3
ThanksButNo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: newbie: CREATE TABLE syntax error

On Apr 5, 5:05 pm, "J.O. Aho" <u...@example.net> wrote:
> R.A.M. wrote:


> If you have phone numbers starting with a zero, then they will be stored
> without the leading zero's, so a varchar may be a better option.
>


IMHO, varchar is *always* a better option for any data that you can't
do arithmetic on.

Social security numbers, zip and postal codes, phone numbers, etc.

Since "Square Root of Phone Number Plus 5" doesn't make any sense, use
varchar.

  Réponse avec citation
Vieux 06/04/2008, 04h27   #4
ThanksButNo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: newbie: CREATE TABLE syntax error

On Apr 5, 9:18 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> ThanksButNo wrote:
> > On Apr 5, 5:05 pm, "J.O. Aho" <u...@example.net> wrote:
> >> R.A.M. wrote:

>
> >> If you have phone numbers starting with a zero, then they will be stored
> >> without the leading zero's, so a varchar may be a better option.

>
> > IMHO, varchar is *always* a better option for any data that you can't
> > do arithmetic on.

>
> > Social security numbers, zip and postal codes, phone numbers, etc.

>
> > Since "Square Root of Phone Number Plus 5" doesn't make any sense, use
> > varchar.

>
> Oh, no. Now you've figured out my secret speed dial codes. I'm going
> to have to change my algorithm...
>


LOL!!
  Réponse avec citation
Vieux 06/04/2008, 05h18   #5
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: newbie: CREATE TABLE syntax error

ThanksButNo wrote:
> On Apr 5, 5:05 pm, "J.O. Aho" <u...@example.net> wrote:
>> R.A.M. wrote:

>
>> If you have phone numbers starting with a zero, then they will be stored
>> without the leading zero's, so a varchar may be a better option.
>>

>
> IMHO, varchar is *always* a better option for any data that you can't
> do arithmetic on.
>
> Social security numbers, zip and postal codes, phone numbers, etc.
>
> Since "Square Root of Phone Number Plus 5" doesn't make any sense, use
> varchar.
>
>


Oh, no. Now you've figured out my secret speed dial codes. I'm going
to have to change my algorithm...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h33.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11381 seconds with 13 queries