SQL and Database Fundamentals
Covers SQL commands, functions, data types, and database operations for Oracle and SQL Server
Questions
Which SQL statement is used to insert new data in a database?
- INSERT NEW
- ADD NEW
- ADD RECORD
- INSERT INTO
With SQL, how do you select a column named 'FirstName' from a table named 'Persons'?
- SELECT FirstName FROM Persons
- EXTRACT FirstName FROM Persons
- SELECT Persons.FirstName
- SELECT * FROM Persons
Which SQL statement is used to delete data from a database?
- COLLAPSE
- REMOVE
- DELETE
- TRUNCATE
With SQL, how do you select all the columns from a table named 'Persons'?
- SELECT [all] FROM Persons
- SELECT * FROM Persons
- SELECT *.Persons
- SELECT Persons
With SQL, how do you select all the records from a table named 'Persons' where the value of the column 'FirstName' is 'Peter'?
- SELECT * FROM Persons WHERE FirstName <> 'Peter'
- SELECT [all] FROM Persons WHERE FirstName='Peter'
- SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'
- SELECT * FROM Persons WHERE FirstName='Peter'
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'?
- SELECT * FROM Persons WHERE FirstName LIKE 'a%'
- SELECT * FROM Persons WHERE FirstName LIKE '%a'
- SELECT * FROM Persons WHERE FirstName='a'
- SELECT * FROM Persons WHERE FirstName='%a%'
Which SQL statement is used to return only different values?
- SELECT DISTINCT
- SELECT DIFFERENT
- SELECT UNIQUE
- SELECT ALL
Which SQL keyword is used to sort the result-set?
- ORDER
- ORDER BY
- SORT BY
- SORT
With SQL, how can you return all the records from a table named 'Persons' sorted descending by 'FirstName'?
- SELECT * FROM Persons ORDER FirstName DESC
- SELECT * FROM Persons ORDER BY FirstName DESC
- SELECT * FROM Persons SORT BY 'FirstName' DESC
- SELECT * FROM Persons SORT 'FirstName' DESC
What is the output? SELECT SUBSTRING('123456', 0, 3)
- 123
- 12
- 123456
- 456
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
- 09/09/2008
- 09-09-2008 00:00:00:000
- Error Message
- None of the above
What is the output? declare @d decimal select @d = 3.564636 select @d
- 4
- 3.56
- 3.564636
- 3
What is the output? DECLARE @val CHAR(20) SET @val = ' SQL is cool ' select LEN(@val)
- 20
- 14
- 12
- 13
what is the len of @c? declare @c varchar(8000) set @c = N'hello' + replicate('-',8000) print len(@c) print @c
- 8000
- 4000
- 4005
- 5
What is the output? SELECT SUBSTRING('123456', 0, 3)
- 123
- 12
- 123456
- 456
Which of the following SQL functions can operate on any datatype?
- to_char
- max
- rollup
- cube
Which Oracle access method is the fastest way for Oracle to retrieve a single row?
- Primary key access
- Full table scan
- Access via unique index
- Table access by ROWID
- None of the above
Which command will delete all data from a table and will not write to the rollback segment?
- DROP
- DELETE
- TRUNCATE
- REMOVE
- NONE OF THE ABOVE
What is the default behaviour of OUT parameter mode in PL/SQL
- By value
- By reference
- By type
- none of the above
What is RAC
- Real abstarct clustersl
- Real application cursors
- Real application clusters
- none of the above
Which of the following SQL functions can operate on any datatype?
- to_char
- max
- cube
- rollup
Which Oracle access method is the fastest way for Oracle to retrieve a single row?
- Primary key access
- Full table scan
- Access via unique index
- Table access by ROWID