MySQL 建表

CREATE TABLE IF NOT EXISTS rr_category( cid TINYINT UNSIGNED AUTO_INCREMENT, c_name VARCHAR, parentid TINYINT UNSIGNED, PRIMARY KEY (cid) );


报错怎么解决

小静_123
浏览 3776回答 4
4回答

Hadooper

TINYINT和VARCHAR后面都要加上长度,否则数据库不知道要怎么分配空间大小

yes居然被占用

你自己的语句:mysql> CREATE TABLE IF NOT EXISTS rr_category( cid TINYINT UNSIGNED AUTO_INCREMENT, c_name VARCHAR, parentid TINYINT UNSIGNED, PRIMARY KEY (cid) );执行后报这个错误: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 ' parentid TINYINT UNSIGNED, PRIMARY KEY (cid) )' at line 1修改后的语句(采取“Hadooper”的提示):mysql> CREATE TABLE IF NOT EXISTS rr_category( cid TINYINT UNSIGNED AUTO_INCREMENT, c_name VARCHAR(20), parentid TINYINT UNSIGNED, PRIMARY KEY (cid) );执行后的提示:Query OK, 0 rows affected查看结果:mysql> show tables;+----------------+| Tables_in_test |+----------------+| rr_category    || users          |+----------------+6 rows in set

程灰_

 IF NOT  应该是  inot

天启之魂

你把报错的提示发出来啊  这样不好看呢! 看提示就知道了
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL