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.


Which command can be used to get the current database in MS-SQL?

  1. SELECT DB_NAME()

  2. SELECT instance_name FROM v$instance

  3. SELECT database()

  4. SELECT current_database()

The correct answer is: SELECT DB_NAME()

The command that retrieves the current database in MS-SQL is correctly identified as the one that uses the syntax `SELECT DB_NAME()`. This built-in function, `DB_NAME()`, returns the name of the current database context in SQL Server. It effectively allows a user to determine which database they are currently connected to, which can be particularly useful in multi-database environments. Other options listed pertain to different database systems or use incorrect syntax for MS-SQL. For instance, the command using `instance_name FROM v$instance` relates to Oracle Database, indicating that it is looking for instance information rather than database names. The `SELECT database()` function is specific to MySQL, which serves the same purpose as the correct command here but for a different database system. Lastly, `SELECT current_database()` is a syntax used in PostgreSQL to return the current database in that environment, not MS-SQL. This difference highlights the importance of knowing the appropriate commands for the specific database management system being used.