Skip to Content
PostgreSQL 10 Administration Cookbook - Fourth Edition
book

PostgreSQL 10 Administration Cookbook - Fourth Edition

by Simon Riggs, Gianni Ciolli
May 2018
Intermediate to advanced content levelIntermediate to advanced
576 pages
30h 25m
English
Packt Publishing
Content preview from PostgreSQL 10 Administration Cookbook - Fourth Edition

There's more…

We can compare the definitions of any two tables using the following function:

CREATE OR REPLACE FUNCTION diff_table_definition(t1_schemaname text,t1_tablename text,t2_schemaname text,t2_tablename text)RETURNS TABLE(t1_column_name text,t1_data_type text,t2_column_name text,t2_data_type text)LANGUAGE SQLas$$SELECT t1.column_name,t1.data_type,t2.column_name,t2.data_typeFROM (SELECT column_name, data_type  FROM information_schema.columns  WHERE table_schema = $1      AND table_name = $2 ) t1 FULL OUTER JOIN (SELECT column_name, data_type  FROM information_schema.columns  WHERE table_schema = $3      AND table_name = $4 ) t2 ON t1.column_name = t2.column_name AND t1.data_type = t2.data_typeWHERE t1.column_name IS NULL OR t2.column_name IS NULL ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PostgreSQL 13 Cookbook

PostgreSQL 13 Cookbook

Vallarapu Naga Avinash Kumar
PostgreSQL 9 Administration Cookbook - Second Edition

PostgreSQL 9 Administration Cookbook - Second Edition

Simon Riggs, GIANNI CIOLLI, Hannu Krosing, Gabriele Bartolini

Publisher Resources

ISBN: 9781788474924Supplemental Content