I am currently converting an Oracle database to Postgis. Instead of blindingly copying the data model, I am also checking which columns are actually really used, and drop those that are never used.
In most tables it is pretty easy, I can do a quick visual check and then count that one column that seems to be zero all the time. But we have a few tables with 30-50 columns.
For such a table there is also an easy way:
SELECT t.column_name
FROM user_tab_columns t
WHERE t.nullable = 'Y'
AND t.table_name = 'YOUR_TABLE_NAME_HERE'
AND t.num_distinct = 0
Mind you, for this to work, your database must have gathered the statistics (if you haven't done this before, this will also help your performance).
BEGIN
DBMS_STATS.gather_database_stats();
END;
Comments
Add comment