gpt4 book ai didi

mysql - 创建 MYSQL 数据库表?需要帮助修改

转载 作者:行者123 更新时间:2023-11-30 23:11:57 25 4
gpt4 key购买 nike

我已经创建了一个登录系统。我对 MYSQL 有一些了解,我希望修改这些大垃圾代码。

这是代码:

DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS Country;
CREATE TABLE Country(
country_code char(2) not null,
country_name varchar(60) not null,
primary key(country_code)
)
CREATE TABLE users(
pk_user int unsigned not null auto_increment,
email varchar(120) not null,
flname varchar(100) not null,
password varchar(64) not null,
country_code char(2) not null,
usr_ip varchar(15),
usr_nmb_logins int(10) unsigned not null default 0,
usr_signup_date timestamp not null default CURRENT_TIMESTAMP,
usr_userid varchar(32),
usr_confirm_hash varchar(255) not null, # for the account confirmation
usr_is_confirmed tinyint(1) not null default 0, # after confirming its set to 1
usr_resetpassword_hash varchar(255) not null, # when the user resets password (forgot password)
usr_is_blocked tinyint(1) not null default 0, # blocked or not
usr_is_admin tinyint(1) not null default 0, # admin or not
foreign key(country_code) references Country(country_code),
unique index(email),
primary key(pk_user)
)

还有大量的 insert,如下所示:

insert into Country(country_code,country_name) values("n","?");

这是至少一百个格式相同的第一个。

这是 PHPMyAdmin 给我的错误:

#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 'CREATE TABLE users(
pk_user int unsigned not null auto_increment,
ema' at line 6

但是当我排除那个错误或修复它时,更多的出现并告诉你真相我不知道该怎么做。

最佳答案

CREATE TABLE Country(
country_code char(2) not null,
country_name varchar(60) not null,
primary key(country_code)
);
CREATE TABLE users(
pk_user int unsigned not null auto_increment,
email varchar(120) not null,
flname varchar(100) not null,
password varchar(64) not null,
country_code char(2) not null,
usr_ip varchar(15),
usr_nmb_logins int(10) unsigned not null default 0,
usr_signup_date timestamp not null default CURRENT_TIMESTAMP,
usr_userid varchar(32),
usr_confirm_hash varchar(255) not null, # for the account confirmation
usr_is_confirmed tinyint(1) not null default 0, # after confirming its set to 1
usr_resetpassword_hash varchar(255) not null, # when the user resets password (forgot password)
usr_is_blocked tinyint(1) not null default 0, # blocked or not
usr_is_admin tinyint(1) not null default 0, # admin or not
foreign key(country_code) references Country(country_code),
unique index(email),
primary key(pk_user)
);

关于mysql - 创建 MYSQL 数据库表?需要帮助修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19460901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com