我写了一个DDL创建架构和用户。 sql是在Mac上以终端模式提供给mysql的。 mysql是5.6,XOS是yosemitee。
表格,索引创建得很好。但是,
create user hr identified by 'hr';
语法错误失败。虽然在mysql模式下可以使用相同的语法。
我还尝试了`
,"
而不是'
。但是,它们都不起作用。
有什么想法吗? (见下面的日志)
drop database if exists classdb
create database classdb character set utf8
set foreign_key_checks=0
drop table if exists departments
create table departments (
deptId enum('1','2','3','4','5','6') not null,
deptName enum('OFFICER','HR','MARKETING','ENGINEERIN','IT', 'SALES') not null,
deptHeadId int(11) not null,
deptHeadUserId varchar(25) not null,
deptAA varchar(45) not null,
parentDeptId enum('1','2','3','4','5','6') not null,
primary key (deptId)
)engine=InnoDB default charset=utf8
drop table if exists payments
create table payments (
supplierId int(11) not null,
date DATE not null,
amount int(11) not null
) engine=InnoDB default charset=utf8
drop table if exists suppliers
create table suppliers (
supplierId int(11) not null,
name varchar(45) not null,
country varchar(45) not null,
reliabilityScore int(11) not null,
primary key (supplierId)
)engine=InnoDB default charset=utf8
drop table if exists employees
create table employees (
empID int(11) not null,
name varchar(45) not null,
taxId varchar(45) not null,
country varchar(45) not null,
hireDate date not null,
birthDate date not null,
salary int(11) not null,
bonus int (11) not null,
deptId enum('1','2','3','4','5','6') not null,
primary key (empID)
)engine=InnoDB default charset=utf8
drop table if exists info
create table info (
infoId int(11) not null,
name varchar(45) not null,
language varchar(45) not null,
status enum('obsolete','historical','colloquial','current','proposed') not null,
standard varchar(45) not null,
placeId int(11) not null,
supplierId int(11) not null,
dateSupplied date not null,
primary key (infoId)
)engine=InnoDB default charset=utf8
drop table if exists places
create table places (
placeId int(11) not null,
type varchar(25) default null,
population int(11) not null,
latitude decimal(10,2) default null,
elevation int(11) not null,
country varchar(45) not null,
longitude decimal(10,2) default null,
addressInfo varchar(45) default null,
primary key (placeId)
) engine=InnoDB default charset=utf8
create index info_name_index on info(name) using BTREE
create index place_latitude_index on places(latitude) using BTREE
create index place_longitude_index on places(longitude) using BTREE
alter table employees add check (salary > 0)
alter table employees add check (bonus <= salary)
alter table employees
add foreign key fk_departments(deptId)
references departments(deptId)
on delete restrict
on update cascade
alter table info
add foreign key fk_suppliers(supplierId)
references suppliers(supplierId)
on delete restrict
on update cascade
alter table info
add foreign key fk_places(placeId)
references places(placeId)
on delete restrict
on update cascade
alter table payments
add foreign key fk_suppliers1(supplierId)
references suppliers(supplierId)
on delete restrict
on update cascade
create user officerMk identified by `officerMk`
ERROR 1064 (42000) at line 125: 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 '`officerMk`' at line 1
Louises-MBP:30215.(013)SQL louiselee$
答案 0 :(得分:0)
错误是由后引号引起的。它应该是一个单引号。