Monthly Archives: February 2016

Check which database object depends on (has reference to) your table

12345678910111213141516SELECT R.TABLE_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE u INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS FK     ON U.CONSTRAINT_CATALOG = FK.UNIQUE_CONSTRAINT_CATALOG     AND U.CONSTRAINT_SCHEMA = FK.UNIQUE_CONSTRAINT_SCHEMA     AND U.CONSTRAINT_NAME = FK.UNIQUE_CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE R     ON R.CONSTRAINT_CATALOG = FK.CONSTRAINT_CATALOG     AND … Continue reading

Posted in Database, PostgreSQL | Leave a comment

Postgres function to devide-and-conquer (iterate) your big query

Create a postgres function to devide-and-conquer (iterate) your big query 1234567891011121314151617181920212223242526272829303132333435363738394041TRUNCATE TABLE YOUR_NEW_BIG_TABLE; DROP FUNCTION IF EXISTS pg_iterator(); CREATE OR REPLACE FUNCTION pg_iterator()   RETURNS void AS $BODY$ DECLARE     vOffsetRecord INT;     vTotal INT;     vLimit … Continue reading

Posted in Database, PostgreSQL | Leave a comment

Crontab header

123456# minute (0-59), # |      hour (0-23), # |      |       day of the month (1-31), # |      |       |       month of the year (1-12), # … Continue reading

Posted in Bash, Linux | Leave a comment