Posts

Showing posts from October, 2020

Recursively Delete files of the Same Name in S3

  From the CLI you can delete all files recursively of the same name (/mydata.csv) using This is for cases where a file of the same name appears in subfolders of a bucket and you want to delete all occurences of that file. If you have bucket versioning turned on then you will not actually lose the file forever. aws s3 rm s3://mybucket/toplevelfolder/ --recursive --exclude "*" --include "*/mydata.csv" If you are paranoid about screwing things up there’s an optional – dryrun parameter that generates a report of what will be deleted, without actually deleting.   aws s3 rm s3:// mybucket/toplevelfolder / --dryrun --recursive --exclude "*" --include "*/metadata.csv" (dryrun) delete: s3:// mybucket/toplevelfolder /part_2/mydata.csv (dryrun) delete: s3:// mybucket/toplevelfolder /part_3/mydata.csv  

RedShift - Renaming - ALTER TABLE

Rename a table The following command renames the USERS table to USERS_BKUP: alter table users rename to users_bkup; You can also use this type of command to rename a view. Change the owner of a table or view The following command changes the VENUE table owner to the user DWUSER: alter table venue owner to dwuser; Rename a column The following command renames the VENUESEATS column in the VENUE table to VENUESIZE: alter table venue rename column venueseats to venuesize;

Redshift - Show Tables in schema

select t.table_name from information_schema.tables t where t.table_schema = 'myschema' -- put your schema name here and t.table_type = 'BASE TABLE' order by t.table_name;