This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
resources [2011/11/15 15:43] k2patel [Getting Connection Information] |
resources [2020/08/10 02:35] (current) |
||
---|---|---|---|
Line 62: | Line 62: | ||
== Read Only User == | == Read Only User == | ||
- | This only allow user to access database but can not write to it. | + | This only allow user to access database but can not write to it.\\ |
+ | <note important>Before you grant make sure you selected database else it could not work</note> | ||
<code sql> | <code sql> | ||
Line 69: | Line 70: | ||
GRANT SELECT ON ALL TABLES IN SCHEMA public TO carol; | GRANT SELECT ON ALL TABLES IN SCHEMA public TO carol; | ||
</code> | </code> | ||
+ | |||
+ | <note tip>If there is ERROR : pg_dump: The command was: LOCK SEQUENCE public.client_group IN ACCESS SHARE MODE See next Section </note> | ||
+ | |||
+ | <code sql> | ||
+ | \dp public.client_group; # check permission | ||
+ | GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO backup; | ||
+ | </code> | ||
+ | |||
+ | <note tip>Even you can use above commands to create backup user for specific database.</note> | ||
==== Getting Connection Information ==== | ==== Getting Connection Information ==== | ||
Line 78: | Line 88: | ||
Following is the available procedures / variable. | Following is the available procedures / variable. | ||
- | Name | + | <code text> |
- | Return Type | + | Name Description |
- | Description | + | current_catalog name of current database (called "catalog" in the SQL standard) |
- | current_catalog | + | current_database() name of current database |
- | name | + | current_schema[()] name of current schema |
- | name of current database (called "catalog" in the SQL standard) | + | current_schemas(boolean) names of schemas in search path, optionally including implicit schemas |
- | current_database() | + | current_user user name of current execution context |
- | name | + | current_query() text of the currently executing query, as submitted by the client (might contain more than one statement) |
- | name of current database | + | pg_backend_pid() Process ID of the server process attached to the current session |
- | current_schema[()] | + | pg_listening_channels() channel names that the session is currently listening on |
- | name | + | inet_client_addr() address of the remote connection |
- | name of current schema | + | inet_client_port() port of the remote connection |
- | current_schemas(boolean) | + | inet_server_addr() address of the local connection |
- | name[] | + | inet_server_port() port of the local connection |
- | names of schemas in search path, optionally including implicit schemas | + | pg_my_temp_schema() OID of session's temporary schema, or 0 if none |
- | current_user | + | pg_is_other_temp_schema(oid) boolean is schema another session's temporary schema? |
- | name | + | pg_postmaster_start_time() server start time |
- | user name of current execution context | + | pg_conf_load_time() configuration load time |
- | current_query() | + | session_user session user name |
- | text | + | user equivalent to current_user |
- | text of the currently executing query, as submitted by the client (might contain more than one statement) | + | version() PostgreSQL version information |
- | pg_backend_pid() | + | </code> |
- | int | + | |
- | Process ID of the server process attached to the current session | + | |
- | pg_listening_channels() | + | |
- | setof text | + | |
- | channel names that the session is currently listening on | + | |
- | inet_client_addr() | + | |
- | inet | + | |
- | address of the remote connection | + | |
- | inet_client_port() | + | |
- | int | + | |
- | port of the remote connection | + | |
- | inet_server_addr() | + | |
- | inet | + | |
- | address of the local connection | + | |
- | inet_server_port() | + | |
- | int | + | |
- | port of the local connection | + | |
- | pg_my_temp_schema() | + | |
- | oid | + | |
- | OID of session's temporary schema, or 0 if none | + | |
- | pg_is_other_temp_schema(oid) | + | |
- | boolean | + | |
- | is schema another session's temporary schema? | + | |
- | pg_postmaster_start_time() | + | |
- | timestamp with time zone | + | |
- | server start time | + | |
- | pg_conf_load_time() | + | |
- | timestamp with time zone | + | |
- | configuration load time | + | |
- | session_user | + | |
- | name | + | |
- | session user name | + | |
- | user | + | |
- | name | + | |
- | equivalent to current_user | + | |
- | version() | + | |
- | text | + | |
- | PostgreSQL version information | + |