我的 sql 查询有什么问题? [英] Whats wrong in my sql query?

查看:37
本文介绍了我的 sql 查询有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我正在尝试创建一个新表,但我不知道创建表时我做错了什么.

Here I'm trying to create a new table, but I don't know what I did wrong when creating the table.

SQL 查询:

CREATE DATABASE IF NOT EXISTS wan_ecommerce;
USE wan_ecommerce
CREATE TABLE IF NOT EXISTS users (
 user_id int(11) NOT NULL AUTO_INCREMENT COMMENT,
 user_name varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT,
 user_password_hash varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT,
 user_email varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT,
 user_active tinyint(1) NOT NULL DEFAULT '0' COMMENT,
 user_activation_hash varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT,
 user_password_reset_hash char(40) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT,
 user_password_reset_timestamp bigint(20) DEFAULT NULL COMMENT,
 user_rememberme_token varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT,
 user_failed_logins tinyint(1) NOT NULL DEFAULT '0' COMMENT,
 user_last_failed_login int(10) DEFAULT NULL COMMENT,
 user_registration_datetime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
 user_registration_ip varchar(39) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0.0.0.0',
 PRIMARY KEY (`user_id`),
 UNIQUE KEY user_name (`user_name`),
 UNIQUE KEY user_email (`user_email`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='user data';

当我运行这个时,我得到一个错误.我在 use wan_ecommerce; 之后添加了 ;;,但我仍然得到:

When I run this I get an error. I've added ; after use wan_ecommerce;, but I'm still getting:

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以了解要使用的正确语法靠近'

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 '

user_name varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT,

user_name varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT,

user_passwo' 在第 2 行

user_passwo' at line 2

我在这里做错了什么?

我该如何解决这个问题?

How can I solve this?

推荐答案

使用分号终止每条语句.

Use semicolon to terminate each statement.

CREATE DATABASE IF NOT EXISTS wan_ecommerce;
USE wan_ecommerce; -- <----- semi colon was missing
CREATE TABLE IF NOT EXISTS users (
-- ....

这篇关于我的 sql 查询有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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