Is there any way to delete or hide Automated Materialized Views (AutoMV) tables from redshift users - amazon-redshift

I copied the tables from 1 Redshift Database to another Redshift Database through amazon redshift snapshots.
After successfully copying the tables from 1 DB to another DB there are some auto generated redshift tables "pg_automv.*" created.
I tried drop table pg_automv.auto_mv_******** command but it shows Error running query: permission denied for schema pg_automv result
Is there any way to delete or hide these tables from a specific users

Related

Azure SQL DB - Export data from a DB and insert into another DB?

I use Azure SQL DB (Single DB, Basic, DTU, Provisioned).
There are two different DBs, say, DB-1 and DB-2.
For DB-1, I have Admin access.
For DB-2, I have read-only access. (No access to create new table.)
The two DBs have no links. I access them using SSMS.
The requirement:
In DB-2, there is a table [EMP] with 1000 rows.
Only 250 of them to be exported and inserted into a new table in DB-1 (with all columns).
How can I achieve in SSMS?
Thanks in advance!
There is no way to do this in only SSMS. If this is an ad-hoc project, I would query the records, copy and paste them into Excel, configure them in Excel for an insert statement, then paste them into an insert statement against DB-1.
If this is something that will need to be sustainable, I'd recommend looking into Azure Data Factory.

Redshift queries do not finish after dropping and recreating tables

I have a few tables in a redshift cluster. When I drop say table A and recreate the table with the records in it using CREATE and the COPY command, any query on table A never finishes execution (even a simple select * from A;). I need to reboot the cluster and execute the query again for it to finish, be it any sort of query. What's the solution here ?

Redshift Materialized View Not Refreshing (No Error)

I have a materialized view in Redshift that refreshes fine when I run refresh materialized view command, however the AWS Glue job is failing to refresh.
I'm not seeing any kind of error in the logs and reviewing the redshift query history shows it completing successfully. Additionally, the update time is the same so it does appear to be running correctly. However querying the view after glue updates does not show updated records, but does if I run the refresh.
I have ran the following permissions to grant the glue account access.
alter table reporting.my_view owner to glue;
alter schema reporting owner to glue;
grant all on schema reporting to glue;
grant all on all tables in schema reporting to glue;
alter default privileges in schema reporting grant all on tables to glue;
Try to use "commit;" before your main post actions query, for example:
"postactions": "commit; your_query"
REFRESH works for commited records only.

Minimum permission required to access Redshift External table

As per the AWS documentation,
To run a Redshift Spectrum query, you need the following permissions:
Usage permission on the schema
Permission to create temporary tables in the current database
I have an External database, schema and a table created in that schema.
I created a new Redshift user to which I granted 'usage' privileges on the external schema:
grant usage on external_schema to new_user;
But I did not provided 'temp' privileges on external_database to my new_user.
Also, there are no default privileges, as I checked PG_DEFAULT_ACL using master user and there are no rows in it.
Can someone let me know why I am able to query the external table?
In Amazon Redshift, Database and Schema are different concepts. User objects (Redshift and external) are created in Schema and TEMP objects are created in "temp" schemas and are available at database level.
In some cases, where join between Spectrum tables and Redshift tables is applied, Redshift needs to create temporary tables and that's why it is mentioned in documentation to avoid any failure/error for users.
Here is what documentation says:
Grants the privilege to create temporary tables in the specified database. To run Amazon Redshift Spectrum queries, the database user must have permission to create temporary tables in the database.
Note
By default, users are granted permission to create temporary tables by their automatic membership in the PUBLIC group. To remove the privilege for any users to create temporary tables, revoke the TEMP permission from the PUBLIC group. Then explicitly grant the permission to create temporary tables to specific users or groups of users.

How to delete database tables in postgres

I have created some databases with postgres, and put some data in them.
The problem is when I delete/drop database, and then create new database, the new database always contains tables and data from the first database that was created with postgres.
How can I delete database so that, when the new database is created it dosent contain data from old database?
Thanks
It sounds like you created tables in the template1 database (or you specify the TEMPLATE xyz option with your CREATE DATABASE statement).
To get rid of the tables in the template1 database, connect to it and drop all tables there. After that new database will not contain those tables any more.
Delete the rows in table using truncate commnad
truncate <tablename>
then delete database using drop command
drop database <databasename>