主键附近的SQL语法错误

时间:2016-04-28 21:12:29

标签: mysql

CREATE TABLE `bank`.`Customer_registrationTable` 
( `Account_no` INT NOT NULL , 
  `Name` VARCHAR(100) NOT NULL , 
  `Address` INT(100) NOT NULL , 
  `Account_type` VARCHAR(100) NOT NULL , 
  `Gender` VARCHAR(50) NOT NULL , 
  `DOB` VARCHAR(100) NOT NULL , 
  `Password` VARCHAR(100) NOT NULL , 
  `Date` VARCHAR(100) NOT NULL , 
  `Age` INT(10) NOT NULL , 
  `Previous_Balance` DOUBLE(20) NOT NULL,  
  PRIMARY KEY (`Account_no`(30))) ENGINE = InnoDB;
写完这篇文章后,我遇到了问题,

  

#1064 - 您的SQL语法出错;查看与您的MariaDB服务器版本对应的手册,以便在')NOT NULL,PRIMARY KEY(`Account_no`(30))附近使用正确的语法)在第1行的WHERE ENGINE = InnoDB'

2 个答案:

答案 0 :(得分:0)

CREATE TABLE `bank`.`Customer_registrationTable` 
( `Account_no` INT NOT NULL , 
  `Name` VARCHAR(100) NOT NULL , 
  `Address` INT(100) NOT NULL , 
  `Account_type` VARCHAR(100) NOT NULL , 
  `Gender` VARCHAR(50) NOT NULL , 
  `DOB` VARCHAR(100) NOT NULL , 
  `Password` VARCHAR(100) NOT NULL , 
  `Date` VARCHAR(100) NOT NULL , 
  `Age` INT(10) NOT NULL , 
  `Previous_Balance` DOUBLE NOT NULL,  
  PRIMARY KEY (`Account_no`)) ENGINE = InnoDB;

PRIMARY KEY(Account_no)不应该有(20) Previous_Balance DOUBLE NOT NULL不应该有(20),它应该像DOUBLE(20,2)

答案 1 :(得分:0)

CREATE TABLE IF NOT EXISTS `customer_registrationtable` (
 `Account_no` int(11) NOT NULL,
`Name` varchar(100) NOT NULL,
`Address` int(100) NOT NULL,
`Account_type` varchar(100) NOT NULL,
`Gender` varchar(50) NOT NULL,
`DOB` datetime NOT NULL,
`Password` varchar(100) NOT NULL,
`Date` datetime NOT NULL,
`Age` int(10) NOT NULL,
`Previous_Balance` double(20,2) NOT NULL,
PRIMARY KEY (`Account_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;