Monday, 5 September 2022

How do I get the list of primary key(s) of a table from Postgres via pgadmin?

SELECT c.column_name, c.data_type

FROM information_schema.table_constraints tc 

JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name) 

JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema

AND tc.table_name = c.table_name AND ccu.column_name = c.column_name

WHERE constraint_type = 'PRIMARY KEY' and tc.table_name = 'mytablename';

DBT - Models

Models are where your developers spend most of their time within a dbt environment. Models are primarily written as a select statement and ...