Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

How to alter table to have uuid?

We are trying to migrate this table from the dev server to production server, the table have a uuid as a column

Tagged:

Answers

  • If your table is:

    CREATE TABLE migrate_me (
      id        UUID NOT NULL DEFAULT UUID_GENERATE()
    , fname VARCHAR(32)
    , lname  VARCHAR(32)
    );
    

    Then, if you use CSV files for the migration, export all columns to CSV, create the same table on the other side and perform a normal COPY migrate_me FROM '/data/migrate_me.csv' DELIMITER ',' /* or whatever applies */[...];.

    If you had no UUID at the source (I did not figure that out exactly from your question), like so:

    CREATE TABLE migrate_me (
      fname VARCHAR(32)
    , lname  VARCHAR(32)
    );
    

    , then also export all columns you have, create the table like so on the other side:

    CREATE TABLE migrate_me (
      id        UUID NOT NULL DEFAULT UUID_GENERATE()
    , fname VARCHAR(32)
    , lname  VARCHAR(32)
    );
    

    , and copy the CSV file like so:

    COPY migrate_me (
      fname
    , lname
    )
    FROM '/data/migrate_me.csv' DELIMITER ','
    [...]
    ;
    
  • thanks for the response sir @marcothesane

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.