Netezza Sql query
Asked Answered
K

5

5

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.

Kink answered 15/9, 2010 at 22:59 Comment(2)
I'm having a hell of a time finding any documentation for Netezza, but I'd probably start by looking at the system views. select * from _v_table; for exampleJohnathanjohnathon
Thanks Abe ! I will look at the system views.Kink
U
5

You can use this query.

SELECT * FROM _v_relation_keydata;
Urgent answered 24/9, 2010 at 15:6 Comment(0)
W
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]

Weslee answered 17/11, 2011 at 17:39 Comment(0)
R
2
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
Rolfe answered 13/2, 2015 at 13:35 Comment(2)
Code-only answers aren't much useful.Sapiential
True in general, but it certainly was for me this time! :)Lubricator
E
0

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';
Erlond answered 6/12, 2012 at 7:16 Comment(0)
T
0

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.

Thunderhead answered 17/12, 2012 at 6:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.