Editing GRANT

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
 
* PostgreSQL Documentation: https://www.postgresql.org/docs/current/sql-grant.html
 
* PostgreSQL Documentation: https://www.postgresql.org/docs/current/sql-grant.html
  
== Examples ==
+
Example:
 
* <code>[[GRANT ALL PRIVILEGES]] ON DATABASE YOUR_DB_NAME TO YOUR_USERNAME;</code>
 
* <code>[[GRANT ALL PRIVILEGES]] ON DATABASE YOUR_DB_NAME TO YOUR_USERNAME;</code>
  
* <code>GRANT [[pg_read_all_data]] TO xxx;</code>
+
* <code>[[GRANT USAGE]]</code>
  
 +
* <code>GRANT USAGE ON [[ALL SEQUENCES IN SCHEMA]] your_schema TO mygrp; </code><ref>https://stackoverflow.com/a/10353730</ref>
  
* <code>[[SELECT]], INSERT, UPDATE, [[DELETE]], TRUNCATE, REFERENCES, TRIGGER, CREATE, CONNECT, TEMPORARY, EXECUTE, [[USAGE]]</code>
 
  
* [[GRANT SELECT]]: <code>[[GRANT SELECT ON mytable TO xxx]]</code>
+
  GRANT your_defined_role TO your_username;
 
+
GRANT ROLE
[[GRANT USAGE]]
 
  [[GRANT USAGE ON]] [[ALL SEQUENCES IN SCHEMA]] your_schema TO mygrp; </code><ref>https://stackoverflow.com/a/10353730</ref>
 
 
 
Command: <code> GRANT "[[your-defined_role]]" TO "your_username";</code>
 
:Output: <code>[[GRANT ROLE]]</code>
 
  
 
  SELECT * FROM your_table_name;
 
  SELECT * FROM your_table_name;
 
  [[ERROR: permission denied for table]] your_table_name
 
  [[ERROR: permission denied for table]] your_table_name
  
* List roles: <code>[[\du]]</code> or <code>[[SELECT * FROM pg_roles;]]</code>
+
[[GRANT SELECT ON mytable TO xxx]]
  
[[psql -h]] you_dp_ip [[-U postgres]] [[-p 5432]]  << EOF
+
* List roles: <code>[[\du]]</code>
[[CREATE DATABASE]] "yourdbname";
 
[[CREATE USER]] "yourusername" WITH PASSWORD yourpassword;
 
[[GRANT ALL PRIVILEGES ON DATABASE]] "yourdbname" to "yourusername";
 
[[GRANT ALL PRIVILEGES ON SCHEMA]] public to "yourusername";
 
[[GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA]] [[public]] TO "yourdbname";
 
EOF
 
  
 
+
System information functions:
[[GRANT CONNECT]]
 
 
 
== [[Amazon Redshift]] ==
 
[[Amazon Redshift]] system information functions:
 
 
* <code>[[HAS_TABLE_PRIVILEGE]]</code>
 
* <code>[[HAS_TABLE_PRIVILEGE]]</code>
 
* <code>[[HAS_SCHEMA_PRIVILEGE]]</code>
 
* <code>[[HAS_SCHEMA_PRIVILEGE]]</code>
Line 40: Line 25:
 
* <code>[[HAS_DATABASE_PRIVILEGE]]</code>
 
* <code>[[HAS_DATABASE_PRIVILEGE]]</code>
  
== AWS RDS ==
 
* <code>[[GRANT rds_iam]] TO your-user;</code>
 
* <code>GRANT [[rds_superuser]] TO "your username";</code>
 
  
== Activities ==
 
 
* [[View GRANTs on Redshift]]: (<code>[[HAS_TABLE_PRIVILEGE]]</code>)
 
* [[View GRANTs on Redshift]]: (<code>[[HAS_TABLE_PRIVILEGE]]</code>)
 
* [[Amazon Redshift: show permissions]]: (<code>[[has_schema_privilege]]</code>)
 
* [[Amazon Redshift: show permissions]]: (<code>[[has_schema_privilege]]</code>)
* [[Amazon Redshift: grant read only privileges to user]]
 
  
 
== Related terms ==
 
== Related terms ==
* [[ERROR: permission denied for]]
 
 
* [[Amazon Redshift: GRANT]]
 
* [[Amazon Redshift: GRANT]]
* <code>[[\dp]]</code> [[list tables]] and privileges
 
* <code>[[\dn+]]</code>
 
 
* <code>[[\ddp]]</code> <ref>https://dba.stackexchange.com/a/184339</ref>
 
* <code>[[\ddp]]</code> <ref>https://dba.stackexchange.com/a/184339</ref>
[[\dt *.*]]
 
 
* <code>[[CREATE ROLE]]</code>
 
* <code>[[CREATE ROLE]]</code>
* [[DELETE PostgreSQL]]
+
* {{TOC operation databases}}
* [[PostgreSQL Privileges]]
 
  
 
== See also ==
 
== See also ==
* {{ALTER}}
 
 
* {{GRANT}}
 
* {{GRANT}}
 +
* {{PostgreSQL}}
 +
  
 
[[Category:PostgreSQL]]
 
[[Category:PostgreSQL]]

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Templates used on this page:

Advertising: