You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- set runtime config at system, database, or user level, or even user level for a specific database (eg. for an ETL user to set different memory settings for use in a given DB)
-- ALTER SYSTEM SET timezone = 'UTC';
-- ALTER DATABASE test SET timezone = 'UTC';
-- ALTER USER hari SET timezone = 'UTC';
-- ALTER USER hari IN DATABASE test SET timezone = 'UTC';
-- session level:
-- SET myParam TO 'myValue';
-- UPDATE pg_settings SET setting = 'myValue' WHERE name = 'myParam';
-- \x
-- SELECT * from pg_settings;
-- SHOW ALL;
-- SHOW one_param;
\echo
--\pset title 'Config Files'
SELECT
current_setting('config_file') AS"config_file",
current_setting('hba_file') AS"hba_file",
current_setting('ident_file') AS"ident_file";
\echo
--\pset title 'PostgreSQL Data Directory & Unix Sockets'
current_setting('max_files_per_process') AS"max_files_per_process", -- should be less than ulimit nofiles to avoid “Too many open files” failures
current_setting('track_activities') AS"track_activities", -- for pg_stat / pg_statio family of system views that are used in many other adjacent scripts
current_setting('track_counts') AS"track_counts", -- needed for the autovacuum daemon
-- in SQL the following have special syntax and should be called without parens: current_catalog, current_role, current_schema, current_user, session_user
SELECT
current_user, -- aka user, current_role - this is the effective user for permission checking
session_user, -- connection user before superuser SET SESSION AUTHORIZATION
current_schema,
current_catalog, -- SQL standard, same as current_database()
pg_backend_pid(),
current_query();
\echo
--\pset title 'Schema search list'
SELECT current_schemas(true) AS"current_schemas(true) - auto-searched schemas"; -- true to include implicit schemas eg. pg_catalog
-- CURRENT_TIME and CURRENT_TIMESTAMP deliver values with time zone; LOCALTIME and LOCALTIMESTAMP deliver values without time zone.
-- CURRENT_TIME, CURRENT_TIMESTAMP, LOCALTIME, and LOCALTIMESTAMP can optionally take a precision parameter, which causes the result to be rounded to that many fractional digits in the seconds field
\echo
--\pset title 'Date & Time'
SELECT
-- current timestamps even inside transactions/functions
now(),
timeofday(), -- human string timestamp with timezone
-- at start of current transaction for consistency, includes +offset timezone
current_timestamp(2) AS"current_timestamp(2)", -- secs precision of 2 decimal places, includes +offset timezone
current_date,
current_time(1) AS"current_time(1)", -- includes +offset timezone
localtime,
localtimestamp(1) AS"localtimestamp(1)",
-- provide current timestamps even inside transactions/functions
-- now()
-- timeofday(), -- human string timestamp with timezone
clock_timestamp(), -- current date + time (changes throughout function)
statement_timestamp(),
transaction_timestamp() -- same as CURRENT_TIMESTAMP