Thursday 26 June 2014

Identity Column in teradata

IDENTITY column can be set on Teradata table. It can be done while creating a table and you can not alter once you created.
You can not say that the numbers generated by IDENTITY will always be in sequence. This is because the identity column values are generated on an amp-local basis
Syntax:
  1. Column_name INTEGER GENERATED ALWAYS AS IDENTITY
  2. (START WITH value1
  3. INCREMENT BY value2
  4. MINVALUE value3
  5. MAXVALUE value4
  6. NO CYCLE)


Example:
  1. CREATE TABLE tbl_emp
  2. (id INTEGER GENERATED ALWAYS AS IDENTITY
  3. (START WITH 1
  4. INCREMENT BY 1
  5. MINVALUE 0
  6. MAXVALUE 1000000
  7. NO CYCLE),
  8. Name VARCHAR(20),
  9. Phone VARCHAR(10));

No comments:

Post a Comment