0

我是 mysql 新手,请帮助我执行此表。

CREATE TABLE `jjsaar`.`dd_chq` (
  `reg_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `receipt_no` INTEGER UNSIGNED NOT NULL,
  `name` VARCHAR NOT NULL,
  `add` VARCHAR NOT NULL,
  `phone_no` VARCHAR NOT NULL,
  `purpose` VARCHAR NOT NULL,
  `pay_method` VARCHAR NOT NULL,
  `amount` INTEGER UNSIGNED NOT NULL,
  `dd_chq_no` VARCHAR NOT NULL,
  `bank_details` VARCHAR NOT NULL,
  `timestamp` TIMESTAMP NOT NULL,
  PRIMARY KEY (`reg_id`)
)
ENGINE = InnoDB;
4

2 回答 2

1

我猜你有这个错误信息

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 4 行的 'NOT NULL, addVARCHAR NOT NULL, phone_noVARCHAR(25) NOT NULL, ' 附近使用正确的语法:

您应该指定VARCHAR值的长度,例如

`name` VARCHAR(25) NOT NULL,

你的工作CREATE TABLE声明

CREATE TABLE `jjsaar`.`dd_chq` 
(
  `reg_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `receipt_no` INTEGER UNSIGNED NOT NULL,
  `name` VARCHAR(25) NOT NULL,
  `add` VARCHAR(25) NOT NULL,
  `phone_no` VARCHAR(25) NOT NULL,
  `purpose` VARCHAR(25) NOT NULL,
  `pay_method` VARCHAR(25) NOT NULL,
  `amount` INTEGER UNSIGNED NOT NULL,
  `dd_chq_no` VARCHAR(25) NOT NULL,
  `bank_details` VARCHAR(25) NOT NULL,
  `timestamp` TIMESTAMP NOT NULL,
  PRIMARY KEY (`reg_id`)
)
ENGINE = InnoDB;
于 2012-12-29T03:44:48.870 回答
0

您必须指定varchar长度。例如:

CREATE TABLE `jjsaar`.`dd_chq` (
  `reg_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `receipt_no` INTEGER UNSIGNED NOT NULL,
  `name` VARCHAR(50) NOT NULL,
  `add` VARCHAR(50) NOT NULL,
  `phone_no` VARCHAR(50) NOT NULL,
  `purpose` VARCHAR(50) NOT NULL,
  `pay_method` VARCHAR(50) NOT NULL,
  `amount` INTEGER UNSIGNED NOT NULL,
  `dd_chq_no` VARCHAR(50) NOT NULL,
  `bank_details` VARCHAR(50) NOT NULL,
  `timestamp` TIMESTAMP NOT NULL,
  PRIMARY KEY (`reg_id`)
)
ENGINE = InnoDB;
于 2012-12-29T03:47:39.397 回答