Skip to main content

Vertica - Export table with IDENTITY

  • October 10, 2018
  • 1 reply
  • 0 views

RameshMarimuthu

In Vertica, We have can created a table with IDENTITY or AUTO INCREMENT constraints or sequence for a field.
While using export command and taking dump and restore the dump into anther vertica setup, we facing error .
All rows are rejected due to above constraints .
Need help to take dump with constraint (IDENTITY or AUTO INCREMENT) and restore data dump with same constraint for backup process.
Regards
M.Ramesh

1 reply

marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • October 10, 2018
Auto increment/ identity and accepting values from outside are diagonally opposed requirements.

Workaround: create at least the target table like so: the previously IDENTITY column as INTEGER NOT NULL. Then export/import. Then SELECT MAX(<identity>) FROM <your table>; . Use the returned value for the initial value of your following CREATE SEQUENCE foo MINVALUE <your number>; . Then, ALTER TABLE <your table> ALTER COLUMN <idcolumn> DEFAULT foo.nextval;