创建mysql表出现的问题,在线等..

zhouzongxi 2008-05-21 10:39:17

前面已经create database hibernate;
use hibernate;
现在是建表
create table login
(
'id' int(11) not null auto_increment,
'name' varchar(100) default not null,
'password' varchar(100) default not null,
primary key ('id')
)
type=mysiam;

出现的问题是:

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 ''id' int(11) not null auto_increment,
'name' varchar(100) default not null,
' at line 3

不知道错哪了,请给我个答案,谢谢,刚开始自学mysql
...全文
101 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouzongxi 2008-05-22
  • 打赏
  • 举报
回复
是我自己写的时候把default '' 写成了default '' not null 了。XICK的我比较满意...
zhouzongxi 2008-05-22
  • 打赏
  • 举报
回复
11楼的大哥写的是对的..SICTxK很热心。谢谢了。
懒得去死 2008-05-22
  • 打赏
  • 举报
回复
无语



create table login
(
`id` int(11) not null auto_increment,
`name` varchar(100) default '' not null,
`password` varchar(100) default '' not null,
primary key (`id`)
)
type=myisam;
SICTXK 2008-05-22
  • 打赏
  • 举报
回复
If strict SQL mode is not enabled, MySQL sets the column to the implicit default value for the column data type.
If strict mode is enabled, an error occurs for transactional tables and the statement is rolled back. For non-transactional tables, an error occurs, but if this happens for the second or subsequent row of a multiple-row statement, the preceding rows will have been inserted.
如果没有启用严格SQL模式,则MYSQL将赋给没有指定VALUE的DEFAULT列一个相应数据类型的默认值 即NULL。但是你的语句中DEFAULT 并且 NOT NULL,所以MYSQL将无法给此列赋予DEFAULT值。
SICTXK 2008-05-21
  • 打赏
  • 举报
回复
LZ的语句有三处错误:
1. DEFAULT 要有默认值。
2. 从copy你的代码来看,你所使用的单引号不是 半角英文。
3. 最后制定数据库引擎的时候写错了 type=mysiam; 因该是 MyISAM.
wwwwb 2008-05-21
  • 打赏
  • 举报
回复
create table login
(
'id' int not null auto_increment,
'name' varchar(100) default '123' not null,
'password' varchar(100) default '456' not null,
primary key ('id')
)
type=mysiam;
SICTXK 2008-05-21
  • 打赏
  • 举报
回复
DEFAULT 是要有值的
沪php攻城师 2008-05-21
  • 打赏
  • 举报
回复
CREATE TABLE `login` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 100 ) NOT NULL ,
`password` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `id` )
)

没查出来哪里错了,在phpmyadmin里运行楼主的语句确实错了,然后自己写了上面的就对了,你就用上面的吧
wwwwb 2008-05-21
  • 打赏
  • 举报
回复
id int auto_increment
zhouzongxi 2008-05-21
  • 打赏
  • 举报
回复
可是我明明按书上打的,也没有写默认值。上次好像是成功了 ,可能半角全角没写好,但不一定要在default里面写值吧。??谢谢各位
wwwwb 2008-05-21
  • 打赏
  • 举报
回复
'id' int(11) not null auto_increment, ->
id int auto_incremen
jacklee_888 2008-05-21
  • 打赏
  • 举报
回复
樓上說得很正確
sunday_bj 2008-05-21
  • 打赏
  • 举报
回复
default没有指定默认值

56,678

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧