What is a view? Why should you use a view?
Answer:
A view is a logical snapshot based on a table or another view. It is used for −
Which SQL statement is used to add, modify or drop columns in a database table?
Answer:
The ALTER TABLE statement.
ViewSay True or False. Give explanation if False.
A DROP TABLE statement can be rolled back.
Answer:
False. A DROP TABLE statement cannot be rolled back.
ViewWhat is the difference between VARCHAR2 AND CHAR datatypes?
Answer:
VARCHAR2 represents variable length character data, whereas CHAR represents fixed length character data.
ViewWhat is the purpose of the MERGE statement in SQL?
Answer:
The MERGE statement allows conditional update or insertion of data into a database table. It performs an UPDATE if the rows exists, or an INSERT if the row does not exist.
ViewCan you remove rows from a table based on values from another table? Explain.
Answer:
Yes, subqueries can be used to remove rows from a table based on values from another table.
ViewWhat happens if you omit the WHERE clause in a delete statement?
Answer:
All the rows in the table are deleted.
ViewSay True or False. Give explanation if False.
The DELETE statement is used to delete a table from the database.
Answer:
False. The DELETE statement is used for removing existing rows from a table.
ViewCan you modify the rows in a table based on values from another table? Explain.
Answer:
Yes. Use of subqueries in UPDATE statements allow you to update rows in a table based on values from another table.
ViewWhat happens if you omit the WHERE clause in the UPDATE statement?
Answer:
All the rows in the table are modified.
ViewHow do you copy rows from one table to another?
Answer:
The INSERT statement can be used to add rows to a table by copying from another table. In this case, a subquery is used in the place of the VALUES clause.
ViewSay True or False. Give explanation if False.
INSERT statement does not allow copying rows from one table to another.
Answer:
False. INSERT statement allows to add rows to a table copying rows from an existing table.
ViewHow do you insert null values in a column while inserting data?
Answer:
Null values can be inserted into a table by one of the following ways −
Which statement is used to add a new row in a database table?
Answer:
The INSERT INTO statement.
ViewWhat is the pupose of DML statements in SQL?
Answer:
The DML statements are used to add new rows to a table, update or modify data in existing rows, or remove existing rows from a table.
ViewWhat are the various multiple row comparison operators in SQL?
Answer:
IN, ANY, ALL.
ViewWhat’s wrong in the following query?
SELECT student_code, name FROM students WHERE marks = (SELECT MAX(marks) FROM students GROUP BY subject_code);
Answer:
Here a single row operator = is used with a multiple row subquery.
ViewSay True or False. Give explanation if False.
A single row subquery returns only one row from the outer SELECT statement
Answer:
False. A single row subquery returns only one row from the inner SELECT statement.
ViewWhat do you understand by a subquery? When is it used?
Answer:
A subquery is a SELECT statement embedded in a clause of another SELECT statement. It is used when the inner query, or the subquery returns a value that is used by the outer query. It is very useful in selecting some rows in a table with a condition that depends on some data which is contained in the same table.
ViewSay True or False. Give explanation if False.
Group functions cannot be nested.
Answer:
False. Group functions can be nested to a depth of two.
View© 2017 QuizBucket.org