如何在 Amazon redshift 中重新播种身份以及如何使其自动递增
How to reseed identity in Amazon redshift and how to make it auto increment
我想知道我们如何 reset/reseed
Amazon redshift
中的 identity
列
我还想在 table 中创建一个 auto increment
专栏。
您可以在创建 table 时执行类似的操作。
create table test(id bigint identity(1,1))
无法在现有 table 中添加标识列,因此您需要重新创建一个新的 table,然后从现有 table 复制您的数据。重新创建时,您可以根据需要将标识重置为列。
我也遇到过类似的情况,需要在 Redshift 中保留 Identity 列,尤其是当 table 被截断时。不幸的是,我找不到任何重置身份列的选项。在需要休息时使用 drop 和 create table 的变通方法,但这并不是在所有情况下都有效。
我想知道我们如何 reset/reseed
Amazon redshift
identity
列
我还想在 table 中创建一个 auto increment
专栏。
您可以在创建 table 时执行类似的操作。
create table test(id bigint identity(1,1))
无法在现有 table 中添加标识列,因此您需要重新创建一个新的 table,然后从现有 table 复制您的数据。重新创建时,您可以根据需要将标识重置为列。
我也遇到过类似的情况,需要在 Redshift 中保留 Identity 列,尤其是当 table 被截断时。不幸的是,我找不到任何重置身份列的选项。在需要休息时使用 drop 和 create table 的变通方法,但这并不是在所有情况下都有效。