Quiz
Introduction to SQL
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (14)
1Given the following tables:
YEAR_2006
EMPID NAME
---------------------------------
1 Jagger, Mick
2 Richards, Keith
3 Wood, Ronnie
4 Watts, Charlie
5 Jones, Darryl
6 Leavell, Chuck
YEAR_1962
EMPID NAME
-------------------------------
1 Jagger, Mick
2 Richards, Keith
3 Jones, Brian
4 Wyman, Bill
5 Chapman, Tony
6 Stewart, Ian
If the following SQL statement is executed, how many rows will be returned?
SELECT name FROM year_2006
UNION
SELECT name FROM year_1962- A0
- B6
- C10
- D12
2Given the following table definition:
SALES
---------------------------------------------
INVOICE_NO CHAR(20) NOT NULL
SALES_DATE DATE
SALES_PERSON CHAR(20)
REGION CHAR(20)
SALES INTEGER
If the following SELECT statement is executed, which of the following describes the order of the rows
in the result data set produced?
SELECT * FROM sales- AThe rows are sorted by INVOICE_NO in ascending order
- BThe rows are sorted by INVOICE_NO in descending order.
- CThe rows are ordered based on when they were inserted into the table.
- DThe rows are not sorted in any particular order.
3Given the following table:
CURRENT_EMPLOYEES
-----------------------------
EMPID INTEGER NOT NULL
NAME CHAR(20)
SALARY DECIMAL(10,2)
PAST_EMPLOYEES
-----------------------------
EMPID INTEGER NOT NULL
NAME CHAR(20)
SALARY DECIMAL(10,2)
Assuming both tables contain data, which of the following statements will NOT successfully add data to
table CURRENT_EMPLOYEES?- AINSERT INTO current_employees (empid) VALUES (10)
- BINSERT INTO current_employees VALUES (10, 'JAGGER', 85000.00)
- CINSERT INTO current_employees SELECT empid, name, salary FROM
past_employees WHERE empid = 20 - DINSERT INTO current_employees (name, salary) VALUES (SELECT name,
salary FROM past_employees WHERE empid = 20)
4Given the following table definition:
SALES
--------------------------
SALES_DATE DATE
SALES_PERSON CHAR(20)
REGION CHAR(20)
SALES INTEGER
Which of the following SQL statements will remove all rows that had a SALES_DATE in the year 1995?- ADELETE * FROM sales WHERE YEAR(sales_date) = 1995
- BDELETE FROM sales WHERE YEAR(sales_date) = 1995
- CDROP * FROM sales WHERE YEAR(sales_date) = 1995
- DDROP FROM sales WHERE YEAR(sales_date) = 1995
5Given the following two tables:
NAMES POINTS
------------------------ ------------------------
NAME NUMBER NAME POINTS
------------- ------- ------------- -------
Wayne Gretzky 99 Wayne Gretzky 244
Jaromir Jagr 68 Jaromir Jagr 168
Bobby Orr 4 Bobby Orr 129
Bobby Hull 23 Brett Hull 121
Brett Hull 16 Mario Lemieux 189
Mario Lemieux 66 Joe Sakic 94
Mark Messier 11
Which of the following statements will display the player name, number, and points for all players that
have scored points?- ASELECT p.name, n.number, p.points FROM names n
INNER JOIN points p ON n.name = p.name - BSELECT p.name, n.number, p.points FROM names n
LEFT OUTER JOIN points p ON n.name = p.name - CSELECT p.name, n.number, p.points FROM names n
RIGHT OUTER JOIN points p ON n.name = p.name - DSELECT p.name, n.number, p.points FROM names n
FULL OUTER JOIN points p ON n.name = p.name
- ASELECT p.name, n.number, p.points FROM names n
6Given the following two tables:
NAMES POINTS
------------------------ ------------------------
NAME NUMBER NAME POINTS
------------- ------- ------------- -------
Wayne Gretzky 99 Wayne Gretzky 244
Jaromir Jagr 68 Bobby Orr 129
Bobby Orr 4 Brett Hull 121
Bobby Hull 23 Mario Lemieux 189
Mario Lemieux 66 Joe Sakic 94
How many rows would be returned using the following statement?
SELECT name FROM names, points- A0
- B5
- C10
- D25
7If the following SQL statements are executed:
CREATE TABLE make (makeid SMALLINT NOT NULL PRIMARY KEY,
make VARCHAR(25));
CREATE TABLE model (modelid SMALLINT,
model VARCHAR(25),
makeid SMALLINT,
CONSTRAINT const1 FOREIGN KEY (makeid)
REFERENCES make(makeid) ON DELETE RESTRICT);
And each table created is populated as follows:
MAKE MODEL
MAKEID MAKE MODELID MODEL MAKEID
------ --------- ------- ------- --------
1 Ford 1 Mustang 1
2 Chevrolet 2 Escort 1
3 Toyota 3 Malibu 2
4 Camry 3
If the following SQL statement is executed:
DELETE FROM make WHERE makeid = 1
What is the total number of rows that will be deleted?- A0
- B1
- C2
- D3
8Which of the following allows you to modify records in a table?
- ASELECT
- BINSERT
- CUPDATE
- DDELETE
9Which of the following is TRUE about SQL?
- ADDL is used to control access to database and database objects
- BDML is used to access data
- CDCL is used to group DML statements into transactions
- DTCL is used to define properties of data objects
10Given the following UPDATE statement:
UPDATE employees SET workdept =
(SELECT deptno FROM department WHERE deptno = 'A01')
WHERE workdept IS NULL
Which of the following describes the result if this statement is executed?- AThe statement will fail because an UPDATE statement cannot contain a subquery.
- BThe statement will only succeed if the data retrieved by the subquery does not contain multiple
records. - CThe statement will succeed; if the data retrieved by the subquery contains multiple records, only the
first record will be used to perform the update. - DThe statement will only succeed if every record in the EMPLOYEES table has a null value in the
WORKDEPT column.
11Given the following table:
TAB1 RESULT
COL1 COL2 COL1 COL2
----- ----- ----- -----
A 10 A 10
B 20 B 20
C 30 C 30
A 10 D 40
D 40
C 30
Which of the following statements will produce the desired results?- ASELECT UNIQUE * FROM tab1
- BSELECT DISTINCT * FROM tab1
- CSELECT UNIQUE(*) FROM tab1
- DSELECT DISTINCT(*) FROM tab1
12Given the following table definition:
SALES
---------------------------------------
INVOICE_NO CHAR(20) NOT NULL
SALES_DATE DATE
SALES_PERSON VARCHAR(25)
REGION CHAR(20)
SALES_AMT DECIMAL(9,2)
Which of the following queries will return SALES information, sorted by SALES_PERSON, from A to Z,
and SALES_DATE, from most recent to earliest?- ASELECT invoice_no, sales_person, sales_date, sales_amt FROM sales SORT BY sales_person,
sales_date DESC - BSELECT invoice_no, sales_person, sales_date, sales_amt FROM sales SORT BY sales_person
DESC, sales_date - CSELECT invoice_no, sales_person, sales_date, sales_amt FROM sales ORDER BY sales_person,
sales_date DESC - DSELECT invoice_no, sales_person, sales_date, sales_amt FROM sales ORDER BY sales_person
DESC, sales_date
- ASELECT invoice_no, sales_person, sales_date, sales_amt FROM sales SORT BY sales_person,
13Given the following two tables:
TAB1 TAB2
---------------------- -------------------
COL_1 COL_2 COL_A COL_B
----- ----- ----- -----
A 10 A 21
B 12 C 23
C 14 D 25
Assuming the following results are desired:
COL_1 COL_2 COL_A COL_B
A 10 A 21
B 12 - -
C 14 C 23
- - D 25- ASELECT * FROM tab1 INNER JOIN tab2 ON col_1 = col_a
- BSELECT * FROM tab1 LEFT OUTER JOIN tab2 ON col_1 = col_a
- CSELECT * FROM tab1 RIGHT OUTER JOIN tab2 ON col_1 = col_a
- DSELECT * FROM tab1 FULL OUTER JOIN tab2 ON col_1 = col_a
14If table TAB1 is created using the following statement:
CREATE TABLE tab1 (col1 INTEGER NOT NULL,
col2 CHAR(5),
CONSTRAINT cst1 CHECK (col1 in (1, 2, 3)))
Which of the following statements will successfully insert a record into table TAB1?- AINSERT INTO tab1 VALUES (0, 'abc')
- BINSERT INTO tab1 VALUES (NULL, 'abc')
- CINSERT INTO tab1 VALUES (ABS(2), 'abc')
- DINSERT INTO tab1 VALUES (DEFAULT, 'abc')
Information
- Description
- Quiz on Introduction to SQL, created by 2014068975 on 08/10/2015.
- Author
- 2014068975
- Language
- English
- Views
- 2
- Rating
- No ratings yet Rate this quiz