DROP TABLE audit;
CREATE TABLE audit (
EMP_no INT NOT NULL,
create_date datetime NOT NULL,
FOREIGN KEY ( EMP_no ) REFERENCES employees_test ( ID )
);
或
DROP TABLE audit;
CREATE TABLE audit(
EMP_no INT NOT NULL REFERENCES employees_test(ID),
create_date datetime NOT NULL
);
**注意:**SQLite中只能先删除表,再重新建表的过程中创建外键
Mysql下写为:
alter table audit add foreign key(emp_no) references employees_test(id)