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?
0
Best Answers
-
mosheg
Vertica Employee Administrator
Consider one of the options below:
SELECT EXPORT_OBJECTS('','your_schema_name.your_table_name','true');
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';For tables using IDENTITY sequences do:
SELECT table_schema,table_name,column_name,data_type,column_default
from columns
where is_identity;
0
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