初学mysql, ERROR 1064 (42000)

violin_violet 2008-06-18 05:40:27
我初学MYSQL, 在华军软件下的5.0.51a版本。装上后只有第一次成功创建一个tabel,之后的每一次都提示ERROR 1064 (42000)。重装后也从没创建成功。到底ERROR 1064 (42000)是什么?我哪里打错了?

mysql> create table dept
-> (
-> deptno int primary key,
-> dname varchar(14),
-> loc varchar(13),
-> );
ERROR 1064 (42000): 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 ')' at
line 6

mysql> create table dept
-> BEGIN
-> END;
ERROR 1064 (42000): 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 'BEGIN

END' at line 2
...全文
9148 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jyzxwjj 2012-07-25
  • 打赏
  • 举报
回复
没看明白
adama 2008-06-20
  • 打赏
  • 举报
回复
恩,多写了最后一个逗号。
wwwwb 2008-06-20
  • 打赏
  • 举报
回复
loc varchar(13), 去掉逗号
hikuru 2008-06-20
  • 打赏
  • 举报
回复
这UBB咋用的?[code={0}]{1}[/code]??
hikuru 2008-06-20
  • 打赏
  • 举报
回复
最后一列结束不再需要","

[code={0}]
mysql> create table dept
-> (
-> deptno int primary key,
-> dname varchar(14),
-> loc varchar(13),
-> );
ERROR 1064 (42000): 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 ')' a
line 6
mysql> create table dept
-> (
-> deptno int primary key,
-> dname varchar(14),
-> loc varchar(13)
-> );
Query OK, 0 rows affected (0.53 sec)
[/code]
jzyshanxi 2008-06-18
  • 打赏
  • 举报
回复
得先建数据库。
例如:
create database test1;
成功后,再使用该数据库才能进以下操作
语句为:
use test1;
再建表:如:
create table (name char(10),age int);
就可以了,
记着每次使用前都要
use test1; 哦!!
懒得去死 2008-06-18
  • 打赏
  • 举报
回复
仔细看看手册!!!!!


create table dept(deptno int primary key,dname varchar(14), loc varchar(13));

56,679

社区成员

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

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