0

databases Online Quiz - 164

Description: databases Online Quiz - 164
Number of Questions: 20
Created by:
Tags: databases
Attempted 0/20 Correct 0 Score 0

Which SQL statement selects all rows from table called Contest, with column ContestDate having values greater or equal to May 25, 2006?

  1. SELECT * FROM Contest WHERE ContestDate >= '05/25/2006'

  2. SELECT * FROM Contest HAVING ContestDate >= '05/25/2006'

  3. SELECT * FROM Contest WHERE ContestDate < '05/25/2006'

  4. SELECT * FROM Contest IN ContestDate < '05/25/2006'


Correct Option: A
  1. INSERT INTO Projects (ProjectName, ProjectDescription) VALUES ('Content Development', 'Website content development project')

  2. INSERT Projects VALUES ('Content Development', 'Website content development project')

  3. INSERT Projects ('Content Development', 'Website content development project')

  4. SAVE INTO Projects (ProjectName, ProjectDescription) VALUES ('Content Development', 'Website content development project')


Correct Option: A
Explanation:

To insert data into a table called Projects, the user needs to use the INSERT statement.

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

A. INSERT INTO Projects (ProjectName, ProjectDescription) VALUES ('Content Development', 'Website content development project'): This option is correct. This statement inserts data into the Projects table by specifying the column names (ProjectName and ProjectDescription) and their respective values ('Content Development' and 'Website content development project').

B. INSERT Projects VALUES ('Content Development', 'Website content development project'): This option is incorrect because it does not specify the column names. The correct syntax is to use INSERT INTO, followed by the table name and then the column names and values.

C. INSERT Projects ('Content Development', 'Website content development project'): This option is incorrect because it is missing the INTO keyword. The correct syntax is to use INSERT INTO, followed by the table name and then the column names and values.

D. SAVE INTO Projects (ProjectName, ProjectDescription) VALUES ('Content Development', 'Website content development project'): This option is incorrect because there is no SAVE keyword in SQL. The correct syntax is to use INSERT INTO, followed by the table name and then the column names and values.

Therefore, the correct answer is: A. INSERT INTO Projects (ProjectName, ProjectDescription) VALUES ('Content Development', 'Website content development project')

Which of the following SQL statements will select all records with all their columns from a table called Sales.

  1. SELECT * FROM Sales

  2. DELETE FROM Sales

  3. SELECT * FROM SALES WHERE OrderID < 1

  4. SELECT FROM Sales


Correct Option: A

AI Explanation

To answer this question, you need to understand the syntax of the SELECT statement in SQL. Let's go through each option to understand why it is correct or incorrect:

Option A) SELECT * FROM Sales - This option is correct because it uses the SELECT statement to retrieve all records from the table named Sales. The asterisk (*) is a wildcard that represents all columns in the table, so this statement will select all records with all their columns.

Option B) DELETE FROM Sales - This option is incorrect because it uses the DELETE statement, which is used to delete records from a table. It does not retrieve or select any data from the table.

Option C) SELECT * FROM SALES WHERE OrderID < 1 - This option is incorrect because it includes a WHERE clause with a condition (OrderID < 1), which will filter the records based on that condition. It will not select all records from the table.

Option D) SELECT FROM Sales - This option is incorrect because it does not specify which columns to select. In a SELECT statement, you need to specify the columns you want to retrieve. The correct syntax is SELECT column1, column2, ... FROM Sales.

The correct answer is Option A) SELECT * FROM Sales. This option is correct because it uses the SELECT statement with the wildcard (*) to select all records with all their columns from the table named Sales.

Which of the following SQL statements deletes all rows in table called SalesData?

  1. DELETE FROM SalesData

  2. DELETE * FROM SalesData

  3. DELETE SalesData

  4. DELETE ALL SalesData


Correct Option: A
Explanation:

To solve this question, the user needs to know the basic syntax of the SQL DELETE statement. The correct answer is:

The Answer is: A

Explanation:

A. DELETE FROM SalesData: This option is correct because it follows the correct syntax for deleting all rows from a table. The DELETE statement is used to delete existing records in a table, and the FROM keyword specifies the table from which to delete the rows. So, this statement will delete all rows from the SalesData table.

B. DELETE * FROM SalesData: This option is incorrect because it does not follow the correct syntax for the DELETE statement. The asterisk (*) is not required in the DELETE statement and may cause an error.

C. DELETE SalesData: This option is also incorrect because it does not follow the correct syntax for the DELETE statement. The table name should be preceded by the keyword FROM, which is missing in this option.

D. DELETE ALL SalesData: This option is incorrect because it also does not follow the correct syntax for the DELETE statement. The keyword ALL is not necessary and will cause an error.

What is the ABS SQL function used for?

  1. To return the minimum value of a numeric expression.

  2. To return the absolute, positive value of a numeric expression.

  3. To return the maximum value of a numeric expression.

  4. To return the average value of a numeric expression.


Correct Option: B
  1. INSERT clause

  2. SELECT clause

  3. DELETE clause

  4. JOIN clause


Correct Option: B

If you join a table to itself, what kind of join are you using?

  1. Selective Join.

  2. You can't join a table to itself.

  3. Self Join

  4. Outer Join


Correct Option: C

Which SQL keyword is used to retrieve a maximum value?

  1. MAX

  2. TOP

  3. MOST

  4. UPPER


Correct Option: A
Explanation:

To retrieve a maximum value in SQL, the user needs to know the appropriate keyword that retrieves the highest value from a column. The correct option is:

The Answer is: A

Option A: MAX is the correct keyword used to retrieve the maximum value from a column. It is an aggregate function in SQL that takes the column name as input and returns the highest value in that column.

Option B: TOP is a keyword used to limit the number of rows returned from an SQL query. It does not retrieve the maximum value from a column.

Option C: MOST is not a valid SQL keyword.

Option D: UPPER is a keyword used to convert a string to uppercase in SQL. It does not retrieve the maximum value from a column.

  1. Determines if a value matches any of the values in a list or a sub-query.

  2. Defines the tables we are selecting or deleting data from.

  3. Is used with the DISTINCT SQL keyword only.

  4. Is used to select data from a view


Correct Option: A

A trigger is…

  1. a special type of table

  2. a special type of store procedure, executed when certain event occurs

  3. a special type of view

  4. an event


Correct Option: B

Which of the following is a SQL aggregate function

  1. LEFT

  2. LEN

  3. AVG

  4. JOIN


Correct Option: C

AI Explanation

To answer this question, we need to understand what SQL aggregate functions are.

SQL aggregate functions perform calculations on a set of values and return a single value as the result. They are used with the SELECT statement to perform operations such as calculating the average, sum, count, minimum, or maximum value of a column.

Let's go through each option to understand why it is correct or incorrect:

Option A) LEFT - This option is incorrect because LEFT is not an aggregate function. It is used to extract a specified number of characters from the left side of a string.

Option B) LEN - This option is incorrect because LEN is not an aggregate function. It is used to return the length of a string.

Option C) AVG - This option is correct because AVG is an aggregate function in SQL. It is used to calculate the average value of a column.

Option D) JOIN - This option is incorrect because JOIN is not an aggregate function. It is used to combine rows from two or more tables based on a related column between them.

The correct answer is C) AVG. This option is correct because AVG is a SQL aggregate function used to calculate the average value of a column.

"select" - Belogns to

  1. DML

  2. MDL

  3. DDL

  4. All the above


Correct Option: A

"select E_Name,E_Number from EMP order by 2" This Query is

  1. True

  2. False


Correct Option: A

Which key word is used to remove a table from the database

  1. Delete

  2. Truncate

  3. Remove

  4. Drop


Correct Option: D

To Insert new a column in a table Tbl_Test which of the following query is used

  1. Alter table Tbl_Test Insert column New_Column varchar 20

  2. Alter table Tbl_Test Alter column New_Column varchar 20

  3. Alter table Tbl_Test add New_Column varchar 20

  4. Either a or b could be used


Correct Option: C

Calling a stored Procedure inside a view is Possible

  1. True

  2. False


Correct Option: A

In the following which is not a DDL ?

  1. Truncate

  2. Create

  3. Alter

  4. All the above


Correct Option: A

When "Join" is used in a query which should not be used with that

  1. On

  2. Where

  3. Having

  4. Non of the Above


Correct Option: D
- Hide questions