0

databases Online Quiz - 216

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

The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true

  1. True

  2. False


Correct Option: B

With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?

  1. SELECT * FROM Persons SORT BY 'FirstName' DESC

  2. SELECT * FROM Persons SORT 'FirstName' DESC

  3. SELECT * FROM Persons ORDER BY FirstName DESC

  4. SELECT * FROM Persons ORDER FirstName DESC


Correct Option: C

Which SQL statement is used to extract data from a database?

  1. OPEN

  2. EXTRACT

  3. SELECT

  4. GET


Correct Option: C

Which SQL statement is used to update data in a database?

  1. UPDATE

  2. MODIFY

  3. SAVE

  4. SAVE AS


Correct Option: A

AI Explanation

To answer this question, you need to understand the basic SQL syntax and operations.

The correct answer is A) UPDATE.

Explanation for each option:

A) UPDATE - This option is correct. The UPDATE statement is used to modify or update existing data in a database table.

B) MODIFY - This option is incorrect. The MODIFY statement is not a valid SQL statement for updating data. It is typically used in conjunction with the ALTER TABLE statement to modify the structure or definition of a table.

C) SAVE - This option is incorrect. The SAVE statement is not a valid SQL statement for updating data. SQL does not have a specific statement for saving data in a database.

D) SAVE AS - This option is incorrect. The SAVE AS statement is not a valid SQL statement for updating data. SQL does not have a specific statement for saving data with a new name or as a copy.

In conclusion, the correct answer is A) UPDATE. This statement is used to modify or update existing data in a database table.

Which SQL statement is used to insert new data in a database?

  1. ADD NEW

  2. INSERT INTO

  3. ADD RECORD

  4. INSERT NEW


Correct Option: B

What does SQL stand for?

  1. Strong Question Language

  2. Structured Query Language

  3. Structured Question Language

  4. Strong Query Language


Correct Option: B

With SQL, how do you select all the columns from a table named "Persons"?

  1. SELECT * FROM Persons

  2. SELECT [all] FROM Persons

  3. SELECT Persons

  4. SELECT FROM Persons


Correct Option: A

Which SQL statement is used to return only different values?

  1. SELECT DIFFERENT

  2. SELECT UNIQUE

  3. SELECT DISTINCT

  4. SELECT EXACT


Correct Option: C

AI Explanation

To answer this question, you need to understand how to retrieve only distinct values from a table using SQL queries. Let's go through each option to understand why it is correct or incorrect:

Option A) SELECT DIFFERENT - This option is incorrect because there is no SQL keyword or function called "DIFFERENT" to retrieve only different values.

Option B) SELECT UNIQUE - This option is incorrect because "UNIQUE" is not used as a keyword or function to retrieve only different values. Instead, "UNIQUE" is used to enforce uniqueness on a column or a combination of columns in a table.

Option C) SELECT DISTINCT - This option is correct because the "DISTINCT" keyword is used in SQL to retrieve only different values from a column or a combination of columns in a table. It eliminates duplicate values and returns only unique values.

Option D) SELECT EXACT - This option is incorrect because there is no SQL keyword or function called "EXACT" to retrieve only different values.

The correct answer is Option C) SELECT DISTINCT. This option is correct because the "DISTINCT" keyword is used to return only different values.

With SQL, how can you insert a new record into the "Persons" table?

  1. INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

  2. INSERT VALUES ('Jimmy', 'Jackson') INTO Persons

  3. INSERT ('Jimmy', 'Jackson') INTO Persons

  4. INSERT VALUES ('Jimmy', 'Jackson')


Correct Option: A

With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

  1. INSERT INTO Persons (LastName) VALUES ('Olsen')

  2. INSERT ('Olsen') INTO Persons (LastName)

  3. INSERT INTO Persons ('Olsen') INTO LastName

  4. INSERT INTO Persons ('Olsen')


Correct Option: A

With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

  1. DELETE ROW FirstName='Peter' FROM Persons

  2. DELETE FROM Persons WHERE FirstName = 'Peter'

  3. DELETE FirstName='Peter' FROM Persons

  4. REMOVE FROM Persons WHERE FirstName = 'Peter'


Correct Option: B

AI Explanation

To delete records where the "FirstName" is "Peter" in the Persons table using SQL, you would use the DELETE statement along with the WHERE clause to specify the condition.

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

Option A) DELETE ROW FirstName='Peter' FROM Persons - This option is incorrect because the correct syntax for the DELETE statement is DELETE FROM table_name.

Option B) DELETE FROM Persons WHERE FirstName = 'Peter' - This option is correct because it follows the correct syntax for the DELETE statement. It specifies the table name as "Persons" and uses the WHERE clause to specify the condition "FirstName = 'Peter'".

Option C) DELETE FirstName='Peter' FROM Persons - This option is incorrect because the correct syntax for the DELETE statement is DELETE FROM table_name. Additionally, the condition should be specified using the WHERE clause.

Option D) REMOVE FROM Persons WHERE FirstName = 'Peter' - This option is incorrect because the correct keyword to use for deleting records in SQL is DELETE, not REMOVE. The correct syntax should be DELETE FROM table_name.

The correct answer is Option B. This option is correct because it uses the correct syntax for the DELETE statement and specifies the condition using the WHERE clause.

Which SQL statement is used to delete data from a database?

  1. DELETE

  2. COLLAPSE

  3. REMOVE

  4. ERASE


Correct Option: A

With SQL, how do you select a column named "FirstName" from a table named "Persons"?

  1. EXTRACT FirstName FROM Persons

  2. SELECT FirstName FROM Persons

  3. SELECT Persons.FirstName

  4. SELECT * FROM Persons


Correct Option: B

AI Explanation

To select a column named "FirstName" from a table named "Persons" in SQL, you would use the following query:

B. SELECT FirstName FROM Persons

Option A) EXTRACT FirstName FROM Persons - This option is incorrect because the EXTRACT keyword is used to extract specific parts of a date or time, not to select columns from a table.

Option B) SELECT FirstName FROM Persons - This option is correct. It uses the SELECT keyword to specify the column "FirstName" and the FROM keyword to specify the table "Persons".

Option C) SELECT Persons.FirstName - This option is incorrect because it uses the table name "Persons" as a prefix to the column name "FirstName". In SQL, the correct syntax is to specify the column name directly after the SELECT keyword.

Option D) SELECT * FROM Persons - This option is incorrect because it uses the asterisk (*) symbol to select all columns from the table "Persons". To select only the "FirstName" column, you need to specify it explicitly as shown in option B.

The correct answer is B. This option is correct because it uses the correct syntax to select the "FirstName" column from the "Persons" table.

With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"?

  1. SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

  2. SELECT FirstName='Peter', LastName='Jackson' FROM Persons

  3. SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'

  4. SELECT * FROM Persons WHERE FirstName='Jackson' AND LastName='Peter'


Correct Option: A

With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

  1. SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName

  2. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

  3. SELECT LastName>'Hansen' AND LastName

  4. SELECT LastName<>'Hansen' AND LastName<>'Pettersen' FROM Persons


Correct Option: B
Explanation:

To solve this question, the user needs to know the syntax for the SELECT statement in SQL and how to use the WHERE clause to filter records based on a specific condition. The user must also understand the BETWEEN operator in SQL that is used to select values within a range.

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

A. SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName'Hansen' AND LastName'Hansen' AND LastName<>'Pettersen' FROM Persons This option is incorrect. The query selects all the records except the records with the last name "Hansen" and "Pettersen" from the "Persons" table, which is not what we want. We need to select records with last name between (and including) "Hansen" and "Pettersen".

The Answer is: B

Which SQL statement defines a FOREIGN KEY constraint on the DEPT NO column of the EMP table?

  1. CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) NOT NULL, CONSTRAINT emp_deptno_fk FOREIGN KEY deptno REFERENCES dept deptno);

  2. CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) CONSTRAINT emp_deptno_fk REFERENCES dept (deptno));

  3. CRETE TABLE EM (empno NUMBER(4), ename VARCHAR2(35) deptno NUMBER (7,2) NOT NULL, CONSTRAINT em_deptno_fk REFERENCES dept (deptno) FOREIGN KEY (deptno));

  4. CREATE TABLE EMP (empno NUMBER (4), ename VARCHAR2(35), deptno NUMBER(7,2) FOREIGN KEY CONSTRAINT emp deptno fk REFERENCES dept (deptno));


Correct Option: B
Explanation:

To understand this question, the user needs to know how to define foreign key constraints in SQL. A foreign key is a column or combination of columns that is used to establish a link between the data in two tables. The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.

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

A. CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) NOT NULL, CONSTRAINT emp_deptno_fk FOREIGN KEY deptno REFERENCES dept deptno);

This option is incorrect because it has a syntax error. The FOREIGN KEY constraint is not properly defined. It is missing parentheses around the column name, and the table name should be followed by the column name in parentheses.

B. CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) CONSTRAINT emp_deptno_fk REFERENCES dept (deptno));

This option is correct. It defines a FOREIGN KEY constraint called emp_deptno_fk on the deptno column of the EMP table. The constraint references the DEPTNO column of the DEPT table.

C. CRETE TABLE EM (empno NUMBER(4), ename VARCHAR2(35) deptno NUMBER (7,2) NOT NULL, CONSTRAINT em_deptno_fk REFERENCES dept (deptno) FOREIGN KEY (deptno));

This option is incorrect because it has a syntax error. The table name is misspelled, and the FOREIGN KEY constraint is not properly defined. It should be defined before the REFERENCES keyword.

D. CREATE TABLE EMP (empno NUMBER (4), ename VARCHAR2(35), deptno NUMBER(7,2) FOREIGN KEY CONSTRAINT emp deptno fk REFERENCES dept (deptno));

This option is incorrect because it has a syntax error. The FOREIGN KEY constraint is not properly defined. It is missing parentheses around the column name, and the table name should be followed by the column name in parentheses.

Therefore, the correct answer is:

The Answer is: B

  1. The DESCRIBE DEPT statement displays the structure of the DEPT table

  2. The ROLLBACK statement frees the storage space occupied by the DEPT table.

  3. The DESCRIBE DEPT statement returns an error ORA-04043: object DEPT does not exist

  4. The DESCRIBE DEPT statement displays the structure of the DEPT table only if there is a COMMIT statement introduced before the ROLLBACK statement.


Correct Option: A

Which two are attributes of /SQL* Plus? (Choose two).

  1. /SQL * Plus commands cannot be abbreviated

  2. /SQL* Plus commands are accessed from a browser.

  3. /SQL*Plus commands are used to manipulate data in tables

  4. /SQL* Plus command manipulate table definitions in the database

  5. /SQL* Plus is the Oracle proprietary interface for executing SQL statements.


Correct Option: C,E

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) /SQL * Plus commands cannot be abbreviated - This option is incorrect. SQL*Plus commands can be abbreviated using a combination of the first few letters of the command.

Option B) /SQL* Plus commands are accessed from a browser - This option is incorrect. SQL*Plus commands are accessed through a command-line interface, not a browser.

Option C) /SQL*Plus commands are used to manipulate data in tables - This option is correct. SQL*Plus commands are used to interact with the Oracle database, including manipulating data in tables through SQL statements.

Option D) /SQL* Plus commands manipulate table definitions in the database - This option is incorrect. SQL*Plus commands are mainly used to interact with data, not to manipulate table definitions.

Option E) /SQL* Plus is the Oracle proprietary interface for executing SQL statements - This option is correct. SQL*Plus is a command-line interface provided by Oracle for executing SQL statements and managing the Oracle database.

The correct answers are C and E. These options correctly describe attributes of SQL*Plus, as it is used to manipulate data in tables and is the Oracle proprietary interface for executing SQL statements.

Is the database and DBMS software together is called as Database system?

  1. True

  2. False


Correct Option: A

which of the following are the advantages of DBMS? (Select 2)

  1. Redundancy is controlled

  2. graphical and statistical capabilities

  3. proprietary formats may limit arichival quality of data

  4. Providing multiple user interfaces


Correct Option: A,D
- Hide questions