MySQL Syntax Fehler

H34R7

Benutzer
Beiträge
6
Hallo zusammen,
ich bastle ein wenig an einem Code herum.. und erhalte immer einen Syntax-Fehler. Ich kann mir jedoch nicht erklären, wo mein Fehler liegt. :( Vielleicht kann mir da jemand helfen. Danke :)

Code:
CREATE TABLE IF NOT EXISTS gas_station_business( gas_station_id VARCHAR(50) NOT NULL DEFAULT '' COLLATE 'utf8mb4_general_ci', user_id VARCHAR(50) NOT NULL, stock INT(10) UNSIGNED NOT NULL DEFAULT '0', price INT(10) UNSIGNED NOT NULL DEFAULT '0', stock_upgrade TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', truck_upgrade TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', relationship_upgrade TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', money INT(10) UNSIGNED NOT NULL DEFAULT '0', total_money_earned INT(10) UNSIGNED NOT NULL DEFAULT '0', total_money_spent INT(10) UNSIGNED NOT NULL DEFAULT '0', gas_bought INT(10) UNSIGNED NOT NULL DEFAULT '0', gas_sold INT(10) UNSIGNED NOT NULL DEFAULT '0', distance_traveled DOUBLE UNSIGNED NOT NULL DEFAULT '0', total_visits INT(10) UNSIGNED NOT NULL DEFAULT '0', customers INT(10) UNSIGNED NOT NULL DEFAULT '0', timer INT(10) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (gas_station_id) USING BTREE) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ;
CREATE TABLE IF NOT EXISTS gas_station_balance ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, gas_station_id VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci', income BIT(1) NOT NULL, title VARCHAR(255) NOT NULL COLLATE 'utf8mb4_general_ci', amount INT(10) UNSIGNED NOT NULL, date INT(10) UNSIGNED NOT NULL, PRIMARY KEY (id) USING BTREE ) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ;
CREATE TABLE IF NOT EXISTS gas_station_jobs ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, gas_station_id VARCHAR(50) NOT NULL DEFAULT '' COLLATE 'utf8mb4_general_ci', name VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci', reward INT(10) UNSIGNED NOT NULL DEFAULT '0', amount INT(11) NOT NULL DEFAULT '0', progress BIT(1) NOT NULL DEFAULT '0', PRIMARY KEY (id) USING BTREE ) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ;
 
Werbung:

H34R7

Benutzer
Beiträge
6
noch einmal hier: das sind 3 Statements, wo tritt der Fehler auf, wie lautet der Fehler?

Also der Syntax Fehler tritt bei der 2. Create Table auf und lautet: "You have an error in your SQL syntax; it seems the error is around: 'CREATE TABLE IF NOT EXISTS gas_station_balance ( id INT(10) UNSIGNED NOT NULL ' at line 19"
Ich habe die Vermutung, dass es mit der Erstellung der nächsten Tabelle zutun hat. Aber eine Abfrage beende ich doch mit einem ";"?
 

akretschmer

Datenbank-Guru
Beiträge
9.612
Code:
Query OK, 0 rows affected (0,03 sec)

mysql> CREATE TABLE IF NOT EXISTS gas_station_balance ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, gas_station_id VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci', income BIT(1) NOT NULL, title VARCHAR(255) NOT NULL COLLATE 'utf8mb4_general_ci', amount INT(10) UNSIGNED NOT NULL, date INT(10) UNSIGNED NOT NULL, PRIMARY KEY (id) USING BTREE ) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ;
Query OK, 0 rows affected (0,06 sec)


Das muß aber nix bedeuten, MySQL ist halt so. Vielleicht liegt's ja am Wetter, hier scheint die Sonne.
 

H34R7

Benutzer
Beiträge
6
Dazu vielleicht noch... der Aufruf geschieht aus LUA heraus und wurde so implementiert:


Code:
 MySQL.Sync.execute(
            [[CREATE TABLE IF NOT EXISTS `gas_station_business`( `gas_station_id` VARCHAR(50) NOT NULL DEFAULT '' COLLATE 'utf8mb4_general_ci', `user_id` VARCHAR(50) NOT NULL, `stock` INT(10) UNSIGNED NOT NULL DEFAULT '0', `price` INT(10) UNSIGNED NOT NULL DEFAULT '0', `stock_upgrade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', `truck_upgrade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', `relationship_upgrade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', `money` INT(10) UNSIGNED NOT NULL DEFAULT '0', `total_money_earned` INT(10) UNSIGNED NOT NULL DEFAULT '0', `total_money_spent` INT(10) UNSIGNED NOT NULL DEFAULT '0', `gas_bought` INT(10) UNSIGNED NOT NULL DEFAULT '0', `gas_sold` INT(10) UNSIGNED NOT NULL DEFAULT '0', `distance_traveled` DOUBLE UNSIGNED NOT NULL DEFAULT '0', `total_visits` INT(10) UNSIGNED NOT NULL DEFAULT '0', `customers` INT(10) UNSIGNED NOT NULL DEFAULT '0', `timer` INT(10) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`gas_station_id`) USING BTREE) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ; CREATE TABLE IF NOT EXISTS `gas_station_balance` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `gas_station_id` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci', `income` BIT(1) NOT NULL, `title` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_general_ci', `amount` INT(10) UNSIGNED NOT NULL, `date` INT(10) UNSIGNED NOT NULL, PRIMARY KEY (`id`) USING BTREE ) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ; CREATE TABLE IF NOT EXISTS `gas_station_jobs` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `gas_station_id` VARCHAR(50) NOT NULL DEFAULT '' COLLATE 'utf8mb4_general_ci', `name` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci', `reward` INT(10) UNSIGNED NOT NULL DEFAULT '0', `amount` INT(11) NOT NULL DEFAULT '0', `progress` BIT(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) USING BTREE ) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB ;]]
        )
 
Werbung:

dabadepdu

Datenbank-Guru
Beiträge
986
Es ist gerade bei mySQL mit den miesen Fehlermeldungen nicht empfehlenswert, solche Blöcke bei der Fehleranalyse zu betrachten.
Bei Statement 3: Fehler Invalid default value for 'progress'
 
Oben