尝试找出如何创建表Java DB的主键会自动递增时遇到了一些麻烦。下面是我的代码:
--DROP Table Customer;
CREATE TABLE Customer (
Name varchar(20),
Address varchar(60),
id INT not null primary key GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
);
INSERT INTO Customer (Name, Address, id) VALUES
('Eva Smith', '129 Station Rd, London, N3 2AS', 1),
('Rob Manton', '23 Bow Lane, London, N3', 2),
('Bob Currie', '54 Teignmouth Rd, London, NW2', 3),
('Jim Hunter', '765 High Road, London, N12', 4),
('Phil Johnson', '75 Squires Lane, London, N3', 5),
('Saim Soyler', '2 Rosemary Ave, London, N3', 6),
('Gul Hikmet', '31 Clifton Rd, London, N3 2SG', 7);
但是,这段代码给了我错误:
[Exception, Error code 30,000, SQLState 42X01] Syntax error: Encountered ")" at line 5, column 1.
Line 6, column 1
尽管有很多与此相关的主题,但我一直在寻找解决方案,但是找不到有效的解决方案。我还尝试过手动添加“ ID”列,如下图所示,但这也不起作用。
有人知道如何解决这个问题吗?我正在使用Netbeans 8.2版。