Redshift-使用node-orm-2的自动增量ID的不支持类型“ serial”

Nic*_*ons 4 node.js amazon-redshift node-orm2

关于如何获得自动增量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' }
Run Code Online (Sandbox Code Playgroud)

vit*_*y-t 6

没有这样的东西支持。

您只能为整数自动增加

IDENTITY(seed, step) 指定该列是一IDENTITY列的子句。一IDENTITY列包含独特的自动生成的值。这些值以指定为种子的值开头,并以指定为步长的数字递增。IDENTITY列的数据类型必须为INTBIGINT

对于GUID,您必须生成一个并自己插入。

例:

CREATE TABLE your_table(
   id INT IDENTITY(1, 1)
);
Run Code Online (Sandbox Code Playgroud)

  • 有人可以添加一个SQL创建表示例吗? (3认同)