postgresqlHow do I grant access to a PostgreSQL database?
-
You can grant access to a PostgreSQL database by using the
GRANTcommand. -
For example, to grant read and write access to a user named
bobfor a database namedmydb, you would use the following command:
GRANT ALL PRIVILEGES ON DATABASE mydb TO bob;
-
This command grants
boball privileges on themydbdatabase, including the ability to create tables, insert data, and modify data. -
If you want to grant only read access to
bob, you can use the following command:
GRANT CONNECT ON DATABASE mydb TO bob;
-
This command grants
bobonly the ability to connect to themydbdatabase. -
You can also grant access to specific tables or columns within a database. For example, to grant
bobread access to a table namedmytablewithinmydb, you can use the following command:
GRANT SELECT ON mytable TO bob;
- For more information about granting access to PostgreSQL databases, see the PostgreSQL documentation.
More of Postgresql
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL's XMIN and XMAX features?
- How can I monitor PostgreSQL performance using Zabbix?
- How can I integrate PostgreSQL with Yii2?
- How can I use PostgreSQL with YAML?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How do I use PostgreSQL UNION to combine the results of two queries?
- How do I decide whether to use PostgreSQL VARCHAR or TEXT data types?
- How do I use PostgreSQL with Qt?
- How can I retrieve data from PostgreSQL for yesterday's date?
See more codes...