我已经创建了一个登录系统。我对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
但是当我拿出那个错误或修正它时,更多的出现并说实话我不知道该怎么做。
答案 0 :(得分:0)
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)
);