对如何获得自动增量id工作有深入的见解吗?根据我的理解,默认情况下会添加id列;但是,由于我使用的是Redshift,默认的“串行”类型将无法工作,因为它不受支持。
{ [error: Column "probe.id" has unsupported type "serial".]
name: 'error',
length: 165,
severity: 'ERROR',
code: '0A000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: '/home/awsrsqa/padb/src/pg/src/backend/parser/parser_analyze.c',
line: '3600',
routine: 'transformColumnDefinition',
model: 'probe' }发布于 2015-07-09 23:10:16
没有这样的东西支持。
你只能得到一个整数的自动增量
IDENTITY(seed, step)子句,指定该列为IDENTITY列。IDENTITY列包含唯一的自动生成的值.这些值以指定为种子的值开始,增量由指定为step的数字开始。IDENTITY列的数据类型必须是INT或BIGINT。
对于GUID,必须生成GUID并自己插入。
示例:
CREATE TABLE your_table(
id INT IDENTITY(1, 1)
);https://stackoverflow.com/questions/31299148
复制相似问题