CREATE TABLE 'categories'(
'id' SMALLINT NOT NULL AUTO_INCREMENT,
'category' VARCHAR(30) NOT NULL,
PRIMARY KEY ('id'),
UNIQUE KEY 'category' ('category')
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE 'orders' (
'id' INT UNSIGNED NOT NULL AUTO_INCREMENT,
'user_id' INT UNSIGNED NOT NULL,
'transaction_id' VARCHAR(19) NOT NULL,
'payment_status' VARCHAR(15) NOT NULL,
'payment_amount' DECIMAL(6,2) UNSIGNED NOT NULL,
'payment_date_time' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ('id'),
KEY 'user_id' ('user_id')
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE 'pages' (
'id' MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
'category_id' SMALLINT UNSIGNED NOT NULL,
'title' VARCHAR(100) NOT NULL,
'description' TINYTEXT NOT NULL,
'content' LONGTEXT NOT NULL,
'date_created' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ('id'),
KEY 'category_id' ('category_id'),
KEY 'creation_date' ('date_created')
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE 'pdfs' (
'id' SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
'tmp_name' CHAR(40) NOT NULL,
'title' VARCHAR(100) NOT NULL,
'description' TINYTEXT NOT NULL,
'file_name' VARCHAR(40) NOT NULL,
'size' MEDIUMINT UNSIGNED NOT NULL,
'date_created' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ('id'),
UNIQUE KEY 'tmp_name' ('tmp_name'),
KEY 'date_created' ('date_created')
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE 'users' (
'id' INT UNSIGNED NOT NULL AUTO_INCREMENT,
'type' ENUM ('member','admin') NOT NULL,
'username' VARCHAR(30) NOT NULL,
'email' VARCHAR(80) NOT NULL,
'pass' VARBINARY(32) NOT NULL,
'first_name' VARCHAR(20) NOT NULL,
'last_name' VARCHAR (40) NOT NULL,
'date_expires' DATE NOT NULL,
'date_created' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
'date_modified' TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY ('id'),
UNIQUE KEY 'username' ('username'),
UNIQUE KEY 'email' ('email')
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
............................................... ..............................
我在这里找不到SQL错误。
MySQL说:#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在''类别'附近使用正确的语法('id'SMALLINT NOT NULL AUTO_INCREMENT,'category'VARCHAR(30)NOT'在第1行
请帮忙。我在共享服务器上使用MySQL 4.4.x.
答案 0 :(得分:7)
你用'
围绕你的表名和列名,它应该是`(反引号)
CREATE TABLE `categories`
(`id` SMALLINT NOT NULL AUTO_INCREMENT,
`category` VARCHAR(30) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `category` (`category`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
答案 1 :(得分:0)
摆脱你的单引号或@Joachim Isaksson说,使用反引号`。
CREATE TABLE categories (id SMALLINT NOT NULL AUTO_INCREMENT, category VARCHAR(30) NOT NULL, PRIMARY KEY (id), UNIQUE KEY(category) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
还有下一次,简化您的问题。您对第一个CREATE TABLE
语句有疑问。没有必要打印其他所有内容。另外一些格式也很好: - )。