预期 phpmyadmin 错误右括号。 (靠近 ”)”
phpmyadmin error closing bracket was expected. (near ")"
我试图在 phpmyadmin 中导入一个 sql 数据库,
我收到错误:
需要右括号。 (在位置 194 的“)”附近)
Sql 查询:
CREATE TABLE IF NOT EXISTS `wll_product` ( `product_id` int(5) NOT NULL AUTO_INCREMENT, `product_name` varchar(60) NOT NULL, `product_type` tinyint(1) UNSIGNED NOT NULL DEFAULT '0'COMMENT )
我是 mysql 的新手,请帮帮我,谢谢。
你有一些错误,tinyint 是数字,但你分配了一个字符串“0”
有评论未决和缺少密钥(自动增量强制)
CREATE TABLE IF NOT EXISTS `wll_product` (
`product_id` int(5) NOT NULL AUTO_INCREMENT,
`product_name` varchar(60) NOT NULL,
`product_type` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
key(product_id)
);
您需要在 COMMENT 关键字后添加注释(或将 COMMENT 省略)。如果你想在上面使用 auto_increment,你还需要制作 product_id 键。
CREATE TABLE `wll_product` (
`product_id` int(5) NOT NULL AUTO_INCREMENT,
`product_name` varchar(60) NOT NULL,
`product_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'a comment',
KEY (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
编辑:如scaisEdge所说,只有key就够了,不像我之前说的pk。
CREATE TABLE 'data' (
'id' int(11) NOT NULL auto_increment,
'title' varchar(255) NOT NULL,
'text' text NOT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO 'data' ('id', 'title', 'text') VALUES(1, 'Hello World!', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla
sapien eros, lacinia eu, consectetur vel, dignissim et, massa. Praesent suscipit nunc vitae neque. Duis a ipsum. Nunc a erat. Praesent
nec libero. Phasellus lobortis, velit sed pharetra imperdiet, justo ipsum facilisis arcu, in eleifend elit nulla sit amet tellus.
Pellentesque molestie dui lacinia nulla. Sed vitae arcu at nisl sodales ultricies. Etiam mi ligula, consequat eget, elementum sed,
vulputate in, augue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;');
我试图在 phpmyadmin 中导入一个 sql 数据库, 我收到错误: 需要右括号。 (在位置 194 的“)”附近)
Sql 查询:
CREATE TABLE IF NOT EXISTS `wll_product` ( `product_id` int(5) NOT NULL AUTO_INCREMENT, `product_name` varchar(60) NOT NULL, `product_type` tinyint(1) UNSIGNED NOT NULL DEFAULT '0'COMMENT )
我是 mysql 的新手,请帮帮我,谢谢。
你有一些错误,tinyint 是数字,但你分配了一个字符串“0” 有评论未决和缺少密钥(自动增量强制)
CREATE TABLE IF NOT EXISTS `wll_product` (
`product_id` int(5) NOT NULL AUTO_INCREMENT,
`product_name` varchar(60) NOT NULL,
`product_type` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
key(product_id)
);
您需要在 COMMENT 关键字后添加注释(或将 COMMENT 省略)。如果你想在上面使用 auto_increment,你还需要制作 product_id 键。
CREATE TABLE `wll_product` (
`product_id` int(5) NOT NULL AUTO_INCREMENT,
`product_name` varchar(60) NOT NULL,
`product_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'a comment',
KEY (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
编辑:如scaisEdge所说,只有key就够了,不像我之前说的pk。
CREATE TABLE 'data' (
'id' int(11) NOT NULL auto_increment,
'title' varchar(255) NOT NULL,
'text' text NOT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO 'data' ('id', 'title', 'text') VALUES(1, 'Hello World!', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla
sapien eros, lacinia eu, consectetur vel, dignissim et, massa. Praesent suscipit nunc vitae neque. Duis a ipsum. Nunc a erat. Praesent
nec libero. Phasellus lobortis, velit sed pharetra imperdiet, justo ipsum facilisis arcu, in eleifend elit nulla sit amet tellus.
Pellentesque molestie dui lacinia nulla. Sed vitae arcu at nisl sodales ultricies. Etiam mi ligula, consequat eget, elementum sed,
vulputate in, augue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;');