CREATE TABLE `news` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` text,
  `st` varchar(100) DEFAULT NULL,
  `author` varchar(100) DEFAULT NULL,
  `news_type_id` int(11) DEFAULT NULL,
  `browser_count` int(11) DEFAULT `0`,
  `photo` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `news_type_id` (`news_type_id`),
  CONSTRAINT `news_ibfk_1` FOREIGN KEY (`news_type_id`) REFERENCES `news_type` (`id`)
) ;

解决方案 »

  1.   

      `browser_count` int(11) DEFAULT `0`???
    你都定义为int类型还给个字符串为默认值?  把单引号去了。
      

  2.   

    emmm,还是不行
      

  3.   

    emmm,还是不行
    报错信息发出来看看
      

  4.   

    CONSTRAINT `news_ibfk_1` FOREIGN KEY (`news_type_id`) REFERENCES `news_type` (`id`)
    既然有约束了,news_type_id的默认值就不能为空
      

  5.   

    emmm,还是不行
    报错信息发出来看看
    [Err] 1064 - 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 'CREATE TABLE `news` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `title` tex' at line 1
      

  6.   

     `browser_count` int(11) DEFAULT `0`,
      

  7.   

     `browser_count` int(11) DEFAULT `0`
    这一行的 `0` 改成 0 
      

  8.   

    create table news_type(
    id int AUTO_INCREMENT not null,
    val1 varchar(20) default '',
    primary key(id)
    );CREATE TABLE `news` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `title` text,
      `st` varchar(100) DEFAULT NULL,
      `author` varchar(100) DEFAULT NULL,
      `news_type_id` int(11) not null,
      `browser_count` int(11) DEFAULT 0,
      `photo` varchar(200) DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `news_type_id` (`news_type_id`),
      CONSTRAINT `news_ibfk_1` FOREIGN KEY (`news_type_id`) REFERENCES `news_type` (`id`)
    ) ;