Create Table employees (
emp_id char(5) not null,
hourly_pay integer not null,
emp_name varchar(30) not null,
emp_address varchar(50) not null,
gender char(1) not null,
email varchar(30) null,
contact_info integer not null,
outlet_id char(5) null,
supervisor_id char(5) null,
job varchar(15) not null,
PRIMARY KEY (emp_id)
FOREIGN KEY (supervisor_id)
REFERENCES employees(emp_id)
)
如上所示的数据。 SQL Server 2008不断引发错误“关键字'FOREIGN'附近的语法错误。”
答案 0 :(得分:0)
你错过了一个逗号。
Create Table employees (
emp_id char(5) not null,
hourly_pay integer not null,
emp_name varchar(30) not null,
emp_address varchar(50) not null,
gender char(1) not null,
email varchar(30) null,
contact_info integer not null,
outlet_id char(5) null,
supervisor_id char(5) null,
job varchar(15) not null,
PRIMARY KEY (emp_id),
------------------------^
FOREIGN KEY (supervisor_id) REFERENCES employees(emp_id)
)