Tag: databases

Questions Related to databases

What can a mandatory one to one relationship indicate?

  1. More entities are needed

  2. The model should be denormolized

  3. The tables are not properly indexed

  4. The model cannot be implemented physically

  5. More attributes are needed


Correct Option: E
  1. COMMIT

  2. MERGE

  3. UPDATE

  4. DELETE

  5. CREATE

  6. DROP


Correct Option: B,C,D

Which four are correct guidelines for naming database tables? (Choose four.)

  1. Must begin with either a number or a letter

  2. Must be 1-30 characters long

  3. Should not be an Oracle Server reserved word

  4. Must contain only A-Z, a-z, 0-9, _, *, and #

  5. Must contain only A-Z, a-z, 0-9, _, $, and #

  6. Must begin with a letter


Correct Option: B,C,E,F
  1. SELECT ename, salary*12 'Annual Salary' FROM employees;

  2. SELECT ename, salary*12 "Annual Salary" FROM employees;

  3. SELECT ename, salary*12 AS Annual Salary FROM employees;

  4. SELECT ename, salary*12 AS INITCAP("ANNUAL SALARY") FROM employees


Correct Option: B
  1. SELECT last_name FROM EMP WHERE last_name LIKE '_A%';

  2. SELECT last_name FROM EMP WHERE last name ='*A%'

  3. SELECT last_name FROM EMP WHERE last name ='_A%';

  4. SELECT last_name FROM EMP WHERE last name LIKE '*A%'


Correct Option: A
Explanation:

To solve this question, the user needs to know about the SQL SELECT statement and the LIKE operator. The LIKE operator is used to match a character pattern in a string. The underscore (_) represents a single character, while the percent sign (%) represents any number of characters.

Now, let's go through each option and explain why it is right or wrong:

A. SELECT last_name FROM EMP WHERE last_name LIKE '_A%'; This option is correct. It selects the last names of employees from the EMP table where the last name has any character as the first character and "A" as the second character, followed by any number of characters.

B. SELECT last_name FROM EMP WHERE last name ='A%' This option is incorrect because the equal sign (=) is used for exact matches, and the asterisk () is not a valid wildcard character in SQL.

C. SELECT last_name FROM EMP WHERE last name ='A%'; This option is incorrect because the equal sign (=) is used for exact matches, and the underscore () represents only a single character, not any number of characters.

D. SELECT last_name FROM EMP WHERE last name LIKE 'A%' This option is incorrect because the percent sign (%) is used to match any number of characters, not the asterisk ().

Therefore, the correct answer is:

The Answer is: A. SELECT last_name FROM EMP WHERE last_name LIKE '_A%';

Which two are character manipulation functions? (Choose two.)

  1. TRIM

  2. REPLACE

  3. TRUNC

  4. TO_DATE

  5. MOD

  6. CASE


Correct Option: A,B
  1. WHERE

  2. HAVING

  3. RESTRICT

  4. GROUP BY

  5. ORDER BY


Correct Option: B
  1. INSERT

  2. UPDATE

  3. SELECT

  4. DESCRIBE

  5. DELETE

  6. RENAME


Correct Option: D
  1. create groups of data

  2. sort data in a specific order

  3. convert data to a different format

  4. Retrieve data based on an unknown condition


Correct Option: D
Explanation:

To solve this question, the user needs to know the definition and purpose of a subquery.

A subquery is a query that is nested inside another query and returns data that will be used by the main query. It can be used to retrieve data based on an unknown condition and to filter data from a table.

Now, let's go through each option and explain why it is right or wrong:

A. create groups of data: This option is incorrect because creating groups of data is typically done using the GROUP BY clause, not a subquery.

B. sort data in a specific order: This option is incorrect because sorting data is typically done using the ORDER BY clause, not a subquery.

C. convert data to a different format: This option is incorrect because data conversion is typically done using functions like CAST or CONVERT, not a subquery.

D. Retrieve data based on an unknown condition: This option is correct. A subquery can be used to retrieve data based on an unknown condition, such as selecting all employees with salaries greater than the average salary.

Therefore, the answer is: D.