CREST Practitioner Security Analyst (CPSA) Practice

Disable ads (and more) with a membership for a one time $2.99 payment

Master the CREST Practitioner Security Analyst Exam. Prepare with quizzes and comprehensive study guides that include tips and explanations. Excel in your certification journey!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


In PostgreSQL, which command is used to retrieve the hostname and IP address?

  1. SELECT inet_server()addr()

  2. SELECT current_database()

  3. SELECT username FROM pg_user

  4. SELECT version()

The correct answer is: SELECT inet_server()addr()

The correct command to retrieve the hostname and IP address in PostgreSQL is indeed the one that involves the function `inet_server()`. This function is specifically designed to return the IP address and port number being used by the server for the current connection. When you use `inet_server()`, it provides the address in a format that can include both IPv4 and IPv6 addresses, allowing users to understand more about the server’s networking context. This is particularly useful in database management and monitoring, where understanding the network settings and the environment where the PostgreSQL server is running is crucial for performance and security. The other options do not provide the hostname and IP address. For instance, `current_database()` retrieves the name of the database to which the connection is established, while querying `pg_user` fetches information on database users, including usernames. Lastly, the `version()` command returns details about the current version of PostgreSQL that is being run, providing insights into the server's capabilities but not its network information. Each of these functions serves a different purpose, highlighting how specialized commands allow for efficient database management tasks.