Netezza Sql query

无人久伴 提交于 2019-12-10 14:44:53

问题


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.


回答1:


You can use this query.

SELECT * FROM _v_relation_keydata;



回答2:


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]




回答3:


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



回答4:


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';



回答5:


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.



来源:https://stackoverflow.com/questions/3722478/netezza-sql-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!