我正在尝试通过SQL DDL定义MS Access表。我对传统SQL有很多经验,但访问特定语言让我陷入了困境。
CREATE TABLE DemoTable (
Demo_id IDENTITY PRIMARY KEY,
Demo_nm VARCHAR(200) NOT NULL
);
=> Query executed successfully. 0 rows were affected.
我已尝试AUTOINCREMENT
,COUNTER
和IDENTITY(1,1)
等。
INSERT INTO DemoTable VALUES('Some Name');
=> Number of query values and destination fields are not the same.
这是因为它需要一个Demo_id值。
INSERT INTO DemoTable VALUES(5, 'Some Name');
=> Query executed successfully. 1 rows were affected.
正确创建其他所有内容..为Demo_id
创建索引,Demo_nm
不可为空。
我的参考:
答案 0 :(得分:1)
这对我有用:
CREATE TABLE DemoTable (
Demo_id Counter PRIMARY KEY,
Demo_nm VARCHAR(200) NOT NULL)
然后
INSERT INTO DemoTable (
Demo_nm ) Values ("abc")