Skip to content

Instantly share code, notes, and snippets.

View adamantnz's full-sized avatar
:shipit:

Adam adamantnz

:shipit:
  • Fluidly
  • London
View GitHub Profile
@adamantnz
adamantnz / vwdependencies.sql
Last active February 26, 2024 02:45
Redshift - view table/schema dependencies
CREATE OR REPLACE VIEW dbo.vwdependencies
AS
SELECT DISTINCT c_p.oid AS tbloid
,n_p.nspname AS schemaname
,c_p.relname AS NAME
,n_c.nspname AS refbyschemaname
,c_c.relname AS refbyname
,c_c.oid AS viewoid
FROM pg_class c_p
JOIN pg_depend d_p ON c_p.relfilenode = d_p.refobjid
/* Can be used to move a large amount of data from one table to another in chunks to keep transaction log and temp db under control */
CREATE PROCEDURE [SchemaName].[moveData]
AS
BEGIN
DECLARE
@row INT = 0
,@step INT = 100000
,@max INT
SELECT @max = max(dv_keyid)