前面已经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
id int auto_incremen
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 100 ) NOT NULL ,
`password` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `id` )
) 没查出来哪里错了,在phpmyadmin里运行楼主的语句确实错了,然后自己写了上面的就对了,你就用上面的吧
(
'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;
1. DEFAULT 要有默认值。
2. 从copy你的代码来看,你所使用的单引号不是 半角英文。
3. 最后制定数据库引擎的时候写错了 type=mysiam; 因该是 MyISAM.
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值。
(
`id` int(11) not null auto_increment,
`name` varchar(100) default '' not null,
`password` varchar(100) default '' not null,
primary key (`id`)
)
type=myisam;