SQL and Database Fundamentals

Covers SQL commands, functions, data types, and database operations for Oracle and SQL Server

22 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

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

  1. INSERT NEW
  2. ADD NEW
  3. ADD RECORD
  4. INSERT INTO
Question 2 Multiple Choice (Single Answer)

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

  1. SELECT FirstName FROM Persons
  2. EXTRACT FirstName FROM Persons
  3. SELECT Persons.FirstName
  4. SELECT * FROM Persons
Question 3 Multiple Choice (Single Answer)

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

  1. COLLAPSE
  2. REMOVE
  3. DELETE
  4. TRUNCATE
Question 4 Multiple Choice (Single Answer)

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

  1. SELECT [all] FROM Persons
  2. SELECT * FROM Persons
  3. SELECT *.Persons
  4. SELECT Persons
Question 5 Multiple Choice (Single Answer)

With SQL, how do you select all the records from a table named 'Persons' where the value of the column 'FirstName' is 'Peter'?

  1. SELECT * FROM Persons WHERE FirstName <> 'Peter'
  2. SELECT [all] FROM Persons WHERE FirstName='Peter'
  3. SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'
  4. SELECT * FROM Persons WHERE FirstName='Peter'
Question 6 Multiple Choice (Single Answer)

With SQL, how do you select all the records from a table named 'Persons' where the value of the column 'FirstName' starts with an 'a'?

  1. SELECT * FROM Persons WHERE FirstName LIKE 'a%'
  2. SELECT * FROM Persons WHERE FirstName LIKE '%a'
  3. SELECT * FROM Persons WHERE FirstName='a'
  4. SELECT * FROM Persons WHERE FirstName='%a%'
Question 7 Multiple Choice (Single Answer)

Which SQL statement is used to return only different values?

  1. SELECT DISTINCT
  2. SELECT DIFFERENT
  3. SELECT UNIQUE
  4. SELECT ALL
Question 8 Multiple Choice (Single Answer)

Which SQL keyword is used to sort the result-set?

  1. ORDER
  2. ORDER BY
  3. SORT BY
  4. SORT
Question 9 Multiple Choice (Single Answer)

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

  1. SELECT * FROM Persons ORDER FirstName DESC
  2. SELECT * FROM Persons ORDER BY FirstName DESC
  3. SELECT * FROM Persons SORT BY 'FirstName' DESC
  4. SELECT * FROM Persons SORT 'FirstName' DESC
Question 10 Multiple Choice (Single Answer)

What is the output? SELECT SUBSTRING('123456', 0, 3)

  1. 123
  2. 12
  3. 123456
  4. 456
Question 11 Multiple Choice (Single Answer)

What would be the output of the code below in SQL Server 2005 and earlier versions? declare @d date select @d = '09/09/2008' select @d

  1. 09/09/2008
  2. 09-09-2008 00:00:00:000
  3. Error Message
  4. None of the above
Question 12 Multiple Choice (Single Answer)

What is the output? declare @d decimal select @d = 3.564636 select @d

  1. 4
  2. 3.56
  3. 3.564636
  4. 3
Question 13 Multiple Choice (Single Answer)

What is the output? DECLARE @val CHAR(20) SET @val = ' SQL is cool ' select LEN(@val)

  1. 20
  2. 14
  3. 12
  4. 13
Question 14 Multiple Choice (Single Answer)

what is the len of @c? declare @c varchar(8000) set @c = N'hello' + replicate('-',8000) print len(@c) print @c

  1. 8000
  2. 4000
  3. 4005
  4. 5
Question 15 Multiple Choice (Single Answer)

What is the output? SELECT SUBSTRING('123456', 0, 3)

  1. 123
  2. 12
  3. 123456
  4. 456
Question 16 Multiple Choice (Single Answer)

Which of the following SQL functions can operate on any datatype?

  1. to_char
  2. max
  3. rollup
  4. cube
Question 17 Multiple Choice (Single Answer)

Which Oracle access method is the fastest way for Oracle to retrieve a single row?

  1. Primary key access
  2. Full table scan
  3. Access via unique index
  4. Table access by ROWID
  5. None of the above
Question 18 Multiple Choice (Single Answer)

Which command will delete all data from a table and will not write to the rollback segment?

  1. DROP
  2. DELETE
  3. TRUNCATE
  4. REMOVE
  5. NONE OF THE ABOVE
Question 19 Multiple Choice (Single Answer)

What is the default behaviour of OUT parameter mode in PL/SQL

  1. By value
  2. By reference
  3. By type
  4. none of the above
Question 20 Multiple Choice (Single Answer)

What is RAC

  1. Real abstarct clustersl
  2. Real application cursors
  3. Real application clusters
  4. none of the above
Question 21 Multiple Choice (Single Answer)

Which of the following SQL functions can operate on any datatype?

  1. to_char
  2. max
  3. cube
  4. rollup
Question 22 Multiple Choice (Single Answer)

Which Oracle access method is the fastest way for Oracle to retrieve a single row?

  1. Primary key access
  2. Full table scan
  3. Access via unique index
  4. Table access by ROWID