Answer: c) *
Explanation: ‘ * ‘ is used along with SELECT statement in SQL, if we wish to select all the columns available in a table.
Example - SELECT * FROM Employees;
If you want to fetch the values of specific columns or fields of a table, then you have to specify column names such as
SELECT column1_name, column2_name, columnN_name FROM Employees;
Answer: d) Will return the total number of the unique values only, from the column country.
Explanation: (DISTINCT Country) will return only the values that are unique in the column Country and the COUNT function will return the count or the total number of the unique values from the column Country.
SELECT COUNT( DISTINCT Country) from Employees;
Output - 4
Answer: b) Update all the records in a table.
Explanation:The WHERE clause in the UPDATE statement specifies which record should be updated and if we omit the WHERE clause, all records in the table will be updated.
For example
Update Employees set Country = ‘India’; will update country of all employees as ‘India’
Answer: c) Return all the employees with an EmpName that ends with a letter a.
Explanation:‘ % ‘ is a wildcard character in SQL which represents zero or more characters. ‘ %a ‘ will find any values that ends with the letter a and does not care how long is the value as long as it ends with the letter a.
Output
Answer: d) All of the above
Explanation: An aggregate function in SQL performs a calculation on multiple rows of a single column of a table and returns a single value. SQL provides many aggregate functions that include avg, count, sum, min, max, etc.
Answer: d) All of the above.
Explanation: DROP DATABASE will delete the database and everything inside it, including the tables, attributes, index etc.
Answer: a) CREATE TABLE new_table AS SELECT col1,col2 FROM existing_table WHERE .... ;
For Example
CREATE TABLE NewEmployees AS (SELECT * FROM Employees);
Answer: a) Delete the existing records from the specified table.
Explanation: The Delete statement will only delete the existing records from the table. If the WHERE clause is omitted, it will delete all the records from the table. The table and its structure will remain as it is.
Answer: c) UNIQUE, NULL
Explanation: The Primary key is used to uniquely identify each record in a table and every key must be unique and not null.
Answer: b) Alter
Explanation: Alter is a command that is used to add, delete, or modify columns in an existing table. It is also used to add and drop various constraints on an existing table.
The following SQL adds a "Dept" column to the "Employees" table:
ALTER TABLE Employees
ADD Dept varchar(255);
Answer: d) RETURN
Explanation: UNIQUE ensures that all values in a column are different.
CHECK ensures that the values in a column satisfies a specific condition.
CREATE INDEX is used to create and retrieve data from the database very quickly.
Answer: b) a single character.
Explanation: ‘ _ ‘ is a wildcard character in SQL SERVER that is used to represent a single character. In Microsoft Access the ‘ ?‘ represents a single character.
Answer: a) LIKE
Explanation: Wildcard characters are used with the LIKE operator to search for a specific pattern in a column.
Answer: a) Specify multiple values in a WHERE clause.
Explanation: The IN operator is a shorthand for multiple OR conditions.
Example
SELECT * FROM Employees
WHERE Country IN ('India', 'Australia');
Answer: b) Delete the data inside a table but not a table itself.
Explanation: TRUNCATE works the same as the DELETE statement without the WHERE clause, where it will delete all the records from the table but not the table itself.
Answer: c) DELETE FROM CUSTOMER WHERE
Explanation: The DELETE statement will delete the specified rows mentioned in the WHERE clause, whereas the DELETE statement without the WHERE clause will delete all the rows from the table.
Answer: b) Added to WHERE clause to work with aggregate functions.
Explanation: The HAVING clause is used because the WHERE keyword cannot be used with aggregate functions.
Answer: a) Phone_number IS NULL.
Explanation: A field with a NULL value is one that has been left blank during record insertion.
Answer: b) (......)
Explanation: A sub query must always be enclosed in a pair of parentheses.
A Subquery is a query that is embedded in WHERE clause of another SQL query
The following statement returns Names of all the employees whose salary is greater than 50,000
Select EmpName from Employees where EmpId in (Select EmpId from Salary where Salary > 50,000);
Answer: c) ORDER BY
Explanation: ORDER BY is used to sort records in a result set in an ascending or descending order.
The following SQL statement selects all Employees from the "Employees" table, sorted by the "Country" column:
SELECT * FROM Employees
ORDER BY Country;
Answer: a) ASC
Explanation: ORDER BY command sorts the result set in an ascending order by default.
Example
SELECT * FROM Employees
ORDER BY Country;
The above SQL statement will sort the records in an ascending order.
Answer: c) The third highest salary.
Explanation: First, the sub query will return the top three records in an ascending order and the outer query will return the first record which is actually the third highest salary.
Answer: a) SELECT CONCAT (emp_fname, ‘ ’, emp_lname) AS Fullname FROM Employees;
Answer: c) SELECT emp_name, salary FROM Employees WHERE salary>10000 AND salary<20000;
Answer: c) ALTER