2017-08-14 4 views
0

Ich kann keine Tabelle erstellen.Fehler # 1064 - Sie haben einen Fehler in Ihrer SQL-Syntax

Dies ist der Code:

DROP TABLE IF EXISTS `monitoreos`; 

CREATE TABLE `monitoreos` (
    `id` INTEGER NOT NULL AUTO_INCREMENT DEFAULT NULL, 
    `fecha` VARCHAR NULL DEFAULT NULL, 
    `id_cliente` INTEGER NULL DEFAULT NULL, 
    `id_vehiculo` INTEGER NULL DEFAULT NULL, 
    `posicion` INTEGER NULL DEFAULT NULL, 
    `numero_serie` INTEGER NULL DEFAULT NULL, 
    `numero_alterno` INTEGER NULL DEFAULT NULL, 
    `profundidad_inicial` VARCHAR NULL DEFAULT NULL, 
    `horometro_actual` VARCHAR NULL DEFAULT NULL, 
    `profundidad_actual_exterior` VARCHAR NULL DEFAULT NULL, 
    `profundidad_actual_interior` VARCHAR NULL DEFAULT NULL, 
    PRIMARY KEY (`id`) 
); 

und das ist der Fehler:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL DEFAULT NULL, 
    `id_cliente` INTEGER NULL DEFAULT NULL, 
    `id_vehiculo` I' at line 3 
+3

Warum wird "id" auf "NOT NULL" und "DEFAULT NULL" gesetzt? –

+0

'fecha VARCHAR NULL DEFAULT NULL' ist ungültig –

Antwort

0

Nullable und DEFAULT NULL sind die Standardwerte, daher können Sie sie entfernen.

Noch wichtiger, Sie benötigen eine Länge für die VARCHAR Felder. Die folgenden Werke:

CREATE TABLE `monitoreos` (
    `id` INTEGER NOT NULL AUTO_INCREMENT , 
    `fecha` VARCHAR(255), 
    `id_cliente` INTEGER, 
    `id_vehiculo` INTEGER, 
    `posicion` INTEGER, 
    `numero_serie` INTEGER, 
    `numero_alterno` INTEGER, 
    `profundidad_inicial` VARCHAR(255), 
    `horometro_actual` VARCHAR(255), 
    `profundidad_actual_exterior` VARCHAR(255), 
    `profundidad_actual_interior` VARCHAR(255), 
    PRIMARY KEY (`id`) 
); 

Here ist ein SQL-Fiddle.

+0

dank seiner Arbeit jetzt! –

+1

'fecha' sollte wahrscheinlich als' DATUM' deklariert werden. –

3

Das glaube ich nicht, dass Sie zusammen Standard Null und Autoinkrement setzen. Befreien Sie sich von der Standard-Null.

Verwandte Themen