postgresqlHow do I grant access to a PostgreSQL database?
-
You can grant access to a PostgreSQL database by using the
GRANT
command. -
For example, to grant read and write access to a user named
bob
for a database namedmydb
, you would use the following command:
GRANT ALL PRIVILEGES ON DATABASE mydb TO bob;
-
This command grants
bob
all privileges on themydb
database, 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
bob
only the ability to connect to themydb
database. -
You can also grant access to specific tables or columns within a database. For example, to grant
bob
read access to a table namedmytable
withinmydb
, 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 integrate PostgreSQL with Yii2?
- How can I extract the year from a PostgreSQL timestamp?
- How can I use PostgreSQL XOR to compare two values?
- How can Zalando use PostgreSQL to improve its software development?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I set a PostgreSQL interval to zero?
- How can I monitor PostgreSQL performance using Zabbix?
- How can I use PostgreSQL with YAML?
See more codes...