2016-05-22 115 views
0
CREATE DATABASE IF NOT EXISTS USER_TRACKS; 
USE USER_TRACKS; 


CREATE TABLE USER_TABLE(

userId INT AUTO_INCREMENT PRIMARY KEY, 
firstName VARCHAR(10), 
lastName VARCHAR(10), 
contactNo VARCHAR(20), 
emailId VARCHAR(30), 
pass VARCHAR(30) 
); 

CREATE TABLE USER_MUSIC_CATALOGUE(

userId INT REFERENCES USER_TABLE(userId), 
generType VARCHAR(20), 
albumName VARCHAR(20), 
artistName VARCHAR(20), 
releaseDate DATE 
); 

我得到錯誤#1064您每次嘗試導入數據庫時​​都會在SQL語法中出錯。但我不知道語法是怎麼錯的。請幫忙!?在將sql文件導入到phpmyadmin時導致mysql錯誤1064

+0

這個查詢都OK。您使用的版本是「IF NOT EXISTS」:從 - SELECT VERSION(); –

+0

嗨,服務器類型:MariaDB 服務器版本:10.0.17-MariaDB - mariadb.org二進制發行版 協議版本:10 並且我正在使用phpmyadmin導入sql文件 –

回答

0

樣品

MariaDB [bb]> CREATE DATABASE IF NOT EXISTS USER_TRACKS; 
Query OK, 1 row affected (0.00 sec) 

MariaDB [bb]> USE USER_TRACKS; 
Database changed 
MariaDB [USER_TRACKS]> 
MariaDB [USER_TRACKS]> 
MariaDB [USER_TRACKS]> CREATE TABLE USER_TABLE(
    -> 
    -> userId INT AUTO_INCREMENT PRIMARY KEY, 
    -> firstName VARCHAR(10), 
    -> lastName VARCHAR(10), 
    -> contactNo VARCHAR(20), 
    -> emailId VARCHAR(30), 
    -> pass VARCHAR(30) 
    ->); 
Query OK, 0 rows affected (0.08 sec) 

MariaDB [USER_TRACKS]> 
MariaDB [USER_TRACKS]> CREATE TABLE USER_MUSIC_CATALOGUE(
    -> 
    -> userId INT REFERENCES USER_TABLE(userId), 
    -> generType VARCHAR(20), 
    -> albumName VARCHAR(20), 
    -> artistName VARCHAR(20), 
    -> releaseDate DATE 
    ->); 
Query OK, 0 rows affected (0.08 sec) 

MariaDB [USER_TRACKS]>