mysql - 创建全新表时出错
问题描述
我试图用代码创建一个全新的表:
MySQL [distributor]> create table order
-> (
-> order_num integer not null,
-> order_date datetime not null,
-> cust_id chat(10) not null
-> );
它会产生错误:
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 'order
(
order_num integer not null,
order_date datetime not null,
cust_id chat(' at line 1
由于 SQL 不区分大小写,我已多次检查以确保我的代码没有问题。
我的代码有什么错误?
解决方案
您的查询有两个问题:首先,order
是 MySQL 保留字。其次,你有chat
which should be char
。试试这个(将表重命名为orders
):
CREATE TABLE orders
(
order_num integer not null,
order_date datetime not null,
cust_id char(10)
);
推荐阅读
- html - 如何使用带有链接 id 和 div id 的悬停
- redux - 如何配置效果协调器以使用 redux-offline 将错误传递给回滚?
- datepicker - SwiftUI DatePicker 动画的问题
- java - JVM中invokevirtual的实现
- amazon-web-services - Dynamo 数据库流活动
- javascript - 为什么用户脚本管理器仍然支持使用 unsafeWindow?
- excel - if 有多个ands和mid函数
- xamarin - Xamarin.Essentials 如何处理 iOS“文档”文件夹?
- css - 角度全局样式中的边距未强制执行
- python - 如何从列表中删除具有三个重复字母的单词?