使用 phpMyAdmin 时的 SQL #1064 [英] SQL #1064 while using phpMyAdmin

查看:27
本文介绍了使用 phpMyAdmin 时的 SQL #1064的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我写了一些 SQL 语句,当我去测试它们时,我遇到了以下错误.为什么要拒​​绝这个?

创建表学生(stud_id INT 无符号 NOT NULL,螺柱名称 VARCHAR 非空,std_phone INT(10) 无符号非空,std_date_of_birth 日期非空,std_city VARCHAR 非空,螺柱地址 VARCHAR 非空,std_postcode INT(4) 无符号非空,主键(stud_id、stud_phone));

<块引用>

#1064 - 您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,了解在NOT NULL"附近使用的正确语法,std_phone INT(10) 无符号非空,std_date_of_birth DATE NOT ' 在第 3 行

解决方案

您必须指定VARCHAR 数据类型的长度,例如VARCHAR(100).这是您查询的唯一内容.

您修改后的查询如下所示.

创建表学生(stud_id INT 无符号 NOT NULL,螺柱名称 VARCHAR(100) 非空,std_phone INT(10) 无符号非空,std_date_of_birth 日期非空,std_city VARCHAR(100) 非空,螺柱地址 VARCHAR(100) 非空,std_postcode INT(4) 无符号非空,主键(stud_id、stud_phone));

更正后,如果错误仍然显示在您的 phpMyadmin 中,那么您必须从查询文件底部的 phpmyadmin 位置的 Delimiter 文本框中删除 Delimiter.

So I wrote up some SQL statements and as I went to test them I was greeted with the following error. Why is it rejecting this?

CREATE TABLE Student 
(stud_id INT unsigned NOT NULL, 
stud_name VARCHAR NOT NULL, 
stud_phone INT(10) unsigned NOT NULL, 
stud_date_of_birth DATE NOT NULL,
stud_city VARCHAR NOT NULL,
stud_address VARCHAR NOT NULL,
stud_postcode INT(4) unsigned NOT NULL,
PRIMARY KEY (stud_id, stud_phone)
);

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL, stud_phone INT(10) unsigned NOT NULL, stud_date_of_birth DATE NOT ' at line 3

解决方案

You have to specify the length to the VARCHAR datatype like VARCHAR(100). This is the only thing with your query.

Your modified query looks like as below.

CREATE TABLE Student 
(stud_id INT unsigned NOT NULL, 
stud_name VARCHAR(100) NOT NULL, 
stud_phone INT(10) unsigned NOT NULL, 
stud_date_of_birth DATE NOT NULL,
stud_city VARCHAR(100) NOT NULL,
stud_address VARCHAR(100) NOT NULL,
stud_postcode INT(4) unsigned NOT NULL,
PRIMARY KEY (stud_id, stud_phone)
);

After correction this if the error still showing in you phpMyadmin then you have to remove Delimiter from the Delimiter textbox in your phpmyadmin place at the bottom of you query filed.

这篇关于使用 phpMyAdmin 时的 SQL #1064的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆