We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


Is there any way to show some columns are defined as AUTO_INCREMENT in vsql command prompt? — Vertica Forum

Is there any way to show some columns are defined as AUTO_INCREMENT in vsql command prompt?

In vsql prompt, \d command shows type of AUTO_INCREMENT columns as "int".
Is there any way to show some columns are defined as AUTO_INCREMENT?

Best Answers

  • Answer ✓

    I have noticed \ds helps, but is there any better ways?

  • moshegmosheg Vertica Employee Administrator
    Answer ✓

    Consider one of the options below:

    1. SELECT EXPORT_OBJECTS('','your_schema_name.your_table_name','true');

    2. For tables using default sequences like "DEFAULT my_seq.NEXTVAL"
      do:
      SELECT table_schema,table_name,column_name,data_type,column_default
      from columns
      where table_schema = 'your_schema_name' and table_name = 'your_table_name';

    3. For tables using IDENTITY sequences do:
      SELECT table_schema,table_name,column_name,data_type,column_default
      from columns
      where is_identity;

Answers

  • I'm sorry for being late.
    Forum has approved my account just today.

    Option 2. fits my case perfectly.
    I wanted vsql \d command to show table description like this query shows.

    select
    table_schema "Schema"
    , table_name "Table"
    , column_name "Column"
    , case when is_identity then 'AUTO_INCREMENT' else data_type end "Type"
    , data_type_length "Size"
    , column_default "Default"
    , not(is_nullable) "Not Null"
    from
    columns
    where
    table_schema = 'MY_SCHEMA'
    and upper(table_name) = upper('my_table_name')
    ;

    I am using queries like that with my shell script.
    $ ddd mytable

Leave a Comment

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