创建数据库时出现问题 [英] a problem in creating database

查看:91
本文介绍了创建数据库时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建数据库时,发生了某些错误:
以下是错误消息

您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册,以在''\''1 \''附近使用正确的语法,标题varchar(50)NOT NULL default \''\'',页面类型varchar(20)NOT N' '在第3行

这是我的mysql文件的一个例子

when i created a database,something wrong happen:
the follow is the error message

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''\''1\'', title varchar(50) NOT NULL default \''\'', pagetype varchar(20) NOT N'' at line 3

and here is a example of my mysql file

CREATE TABLE uchome_ad (
  adid smallint(6) unsigned NOT NULL auto_increment,
  available tinyint(1) NOT NULL default ''1'',
  title varchar(50) NOT NULL default '''',
  pagetype varchar(20) NOT NULL default '''',
  adcode text NOT NULL,
  system tinyint(1) NOT NULL default ''0'',
  PRIMARY KEY  (adid)
) ENGINE=MyISAM;




顺便说一句,我可以在dos下正确创建数据库,有人可以告诉我我做错了什么吗?

非常感谢!




By the way, I can create the database correctly under dos,can someone tell me what is wrong thing I have done?

Thank you very much!!

推荐答案



我有几点建议,这篇文章可能不是实际的解决方案(我没有使用MySql,但在SQL Server 2005中使用过),但是请考虑

(1)正在创建"tinyint"类型的"available"列,但分配的默认值是字符类型("1"),相反,在我看来应该像这样

Hi,

I have couple of suggestion and this post might not be the actual solution( I have not worked using MySql but in SQL Server 2005), but please consider

(1) column "available" is being created of type tinyint but default value assigned is being of character type(''1'') instead it looks to me that it should have been like this

available tinyint(1) NOT NULL default 1,
....
--do the same for "system" column
system tinyint(1) NOT NULL default 0,



请告诉我是否有帮助.



Please let me know if it helps.


问题是反斜杠.
在您应用的某个位置(我假设您正在开发一个),您有一个代码,每次看到单引号时都会添加一个反斜杠.

您应该删除该问题代码.
或在执行查询之前添加其他代码以消除反斜杠.
The problem is the backslash.
Somewhere in your app (I''m assuming you''re working on one), you have a code that adds a backslash every time it sees a single quote.

You should remove that problem code.
Or add another code to remove the backslash before executing your query.


这篇关于创建数据库时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆