2012-12-29 157 views
0

我是mysql新手,請幫我做這個表。創建表時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; 
+0

當您添加有關錯誤的問題時,請提供* full *錯誤。 – Dancrumb

+0

給varchar限制像varchar(20) – Dhinakar

回答

1

我想你有這樣的錯誤消息

您的SQL語法錯誤;檢查 對應於你的MySQL服務器版本正確的語法使用 附近手冊 'NOT NULL, add VARCHAR NOT NULL, phone_no VARCHAR(25)NOT NULL,' 在第4行:

你應指定長度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; 
+0

看[VARCHAR和CHAR](http://dev.mysql.com/doc/refman/5.0/en/char.html) –

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; 
+0

謝謝你的極客,它的執行! –