Skip to main content
Question

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

  • July 10, 2025
  • 3 replies
  • 8 views

crm250ar

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?

3 replies

crm250ar
  • Author
  • New Participant
  • July 10, 2025

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


mosheg
Forum|alt.badge.img+2
  • Participating Frequently
  • July 10, 2025

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;


crm250ar
  • Author
  • New Participant
  • August 21, 2025

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