DO $$
DECLARE
r record;
BEGIN
FOR r IN
SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_schema = 'crm'
LOOP
EXECUTE format(
'CREATE OR REPLACE VIEW syn.%I AS SELECT * FROM %I.%I;',
r.table_name, r.table_schema, r.table_name
);
END LOOP;
END$$;