Netezza Sql query

2019-06-22 03:20发布

I have a list of tables in a Netezza database and I want to get the name of primary key for each of the tables.

Can anyone provide me the query.

标签: sql netezza
5条回答
兄弟一词,经得起流年.
2楼-- · 2019-06-22 03:28
SELECT database
        , schema
        , constraintname
        , relation as tablename
        , conseq as seq
        , attname as columnname, *
FROM _v_relation_keydata
where contype='p'
and schema='ADMIN'
order by relation, conseq
查看更多
手持菜刀,她持情操
3楼-- · 2019-06-22 03:28

We do not have primary key concept in Netezza. If you are concerned about Not NULL columns following query will help you.

select * from _v_relation_column where NAME='TABLE_NAME' and ATTNOTNULL='Y';
查看更多
4楼-- · 2019-06-22 03:38

There is nothing sort of Primary Key thing in Netezza. If you want to look at the NULL or NOT NULL constraints for your required table you can enter the below commands from your nzsql command line

\d [YOURTABLENAME]

查看更多
时光不老,我们不散
5楼-- · 2019-06-22 03:43

The key(primary/foreign) concepts is not there in Netezza. But we can create primary keys in Netezza and this is created to sync the model with the outside data reporting tools like Informatica/Microstrategy.

You can look into the system view _v_relation_keydata.

查看更多
Bombasti
6楼-- · 2019-06-22 03:50

You can use this query.

SELECT * FROM _v_relation_keydata;
查看更多
登录 后发表回答