db final Flashcards
Which of the following Oracle tools can be used to execute SQL statements against a database?
SQL Developer
SQL*Plus command line
SQL Live
The relational model consists of which of the following. Choose all that are true:
Primary and foreign keys
Collection of tables (relations)
Data integrity for accuracy and consistency
Set of operators to act on the relations, called the relational algebra
What are a primary key’s identifying characteristics? (Select all that apply.)
It uniquely identifies each row
it cannot be NULL
Consider the following rows in a table called CUSTOMERS:
CUST_ID FIRST_NAME MIDDLE LAST_NAME
1 Bianca M. Canales
2 Chua A. Nguyen
3 Bianca M. Jackson
4 Maya R. Canales
5 Bianca S. Canales
How many rows of data will be displayed as the result of executing the following statement: (one answer)
SELECT DISTINCT LAST_NAME, FIRST_NAME FROM CUSTOMERS;
4
The SHIPS table has two columns: SHIP_ID and SHIP_NAME
Which of the following SELECT statements will produce a syntax error? (Choose two.)
SELECT FROM ships;
SELECT (ship_id, ship_name) FROM ships;
Which of the following is NOT required to form a syntactically correct SELECT statement?
a valid column name
Consider the following table structure:
Name Type
——————– ———
ENGINE_ID NUMBER (PRIMARY KEY)
ENGINE_NAME VARCHAR2(30)
DISPLACEMENT NUMBER
What will be the result of executing the following SELECT statement?
SELECT ENGINE_NAME FROM ENGINES;
it will display the engine name from all of the rows in the ENGINES table, however many there may be (blank space for NULL values)
Given that the columns and table name are all correct, which of the following lines of the SELECT statement contain an error? (line numbers added)
01 SELECT name, contact,
02 “Person to Call”, phone
03 FROM publisher;
02
Which component(s) of the following query is/are a literal (select all that apply):
SELECT order_id || ‘-‘ || line_item_id || ‘ ‘ || quantity “Purchase”
FROM line_item;
‘ ‘
‘-’
You are tasked with creating a SELECT statement to retrieve data from a database table named PORTS. The PORTS table has two columns: PORT_ID, and PORT_NAME. Which of the following is a valid SELECT statement? (Choose all that apply.)
SELECT * FROM PORTS;
SELECT PORT_NAME, PORT_ID FROM PORTS;
SELECT ‘Name of the port ‘ || PORT_NAME FROM PORTS;
To become an Oracle SQL Certified Associate, one must pass one exam, 1Z0-071.
True
Which is the only type of relationship that can be directly implemented by the relational model?
1-Many
The category of SQL commands used to work with the actual data, such as INSERT, UPDATE, and DELETE, is called _____.
Data Manipulation Language (DML)
Which of the following are Oracle Development Environments?
SQL Live
SQL*Plus command line
SQL Developer
A table consists of (choose the single best answer)
Rows and columns, primary key, and possibly foreign keys
A primary key may contain NULL values.
False
The category of SQL commands used to build database objects, such as CREATE, ALTER, and DROP, is called ________.
Data Definition Language (DDL)
The relational model consists of which of the following. Choose all that are true:
Collection of tables (relations)
Set of operators to act on the relations, called the relational algebra
Primary and foreign keys
Data integrity for accuracy and consistency
What is the number one DBMS used worldwide, according to DB-Engines Ranking?
Oracle
A ______ is the intersection of a row and a column.
field
The UNIQUE keyword in the SELECT clause will eliminate duplicate values in the result set
False
What will be the result of the executing the following SELECT statement? SELECT ENGINE_NAME FROM ENGINES; SELECT
It will display engine names from all of the rows in the ENGINES table … (NULL will display as blank)
Consider the following statement:
CREATE TABLE PORTS
(port_id NUMBER,
port_name VARCHAR2(20));
Which of the following modifications to the statement is the only valid way to declare that the port_name is required (not optional)?
port_name VARCHAR2(20) NOT NULL
After executing the following SQL statements:
CREATE TABLE invoices (inv_id NUMBER, discount NUMBER));
INSERT INTO invoices VALUES (7, 5);
INSERT INTO invoices VALUES (3, 12);
Which of the following SQL statements will fail? (Choose two.)
ALTER TABLE invoices MODIFY discount VARCHAR2(3);
ALTER TABLE invoices MODIFY discount DEFAULT ‘ZERO’;
Which of the following are valid CREATE TABLE statements? (Choose all that are valid.)
CREATE TABLE “Boat Inventory”
(ID NUMBER,
CAPTAIN VARCHAR2(20));
CREATE TABLE Work_Schedule (ID NUMBER);
Which of the following would be an invalid column or table name? Select all that apply.
P!nk
21PILOTS
Lady-Gaga
What would happen when the following statement is executed:
CREATE TABLE GGC_Student
( StudentID CHAR(6),
SName VarChar2(40),
gpa Number(5,4)
);
The table will be created without a primary key
Which of the following data type(s) is(are) supported by Oracle?
NCLOB
NUMBER
CHAR
Which two constraints are combined to implement a primary key?
UNIQUE
NOT NULL
The difference between dropping a column from a table with DROP and setting the column to UNUSED is:
The UNUSED column and its data are retained within the table’s storage allocation and counts again the total limit on the number of columns that a table is allowed to have, but no longer appears within the table’s description as shown with a DESC or DESCRIBE
CREATE TABLE NUM_TEST ( A NUMBER(5, 3));
INSERT INTO NUM_TEST (A) VALUES 3.1415;
SELECT A FROM NUM_TEST;
What is the displayed output from the SELECT statement?
the statement will fail because you cannot create two primary key constraints on one table
Which of the following options can be used with the keyword CREATE to form a syntactically correct SQL statement to create a table?
at least one column-definition
the keyword CONSTRAINT
the keyword TABLE
What component of SQL is used to build and manage the database objects and define the structure of the database?
DDL
Which line number illustrates an “in-line constraint”? Choose all that apply.
01 CREATE TABLE PORTS
02 ( Port_ID NUMBER(3) PRIMARY KEY,
03 Port_Name VARCHAR2(30) NOT NULL,
04 Region_ID CHAR(4),
05 CONSTRAINT ports_region_id_FK FOREIGN KEY (Region_ID) REFERENCES Region(Region_ID));
02
03
Which of the following are valid table names that may be used with the CREATE TABLE command? Choose all that apply.
Order_lines
“Boat Inventory”
Retired#Emps
The data type that would be used for a column that will be storing employee photographs for a large, multi-national company is:
BLOB
Which of the following is the recommended constraint name for the SHIPS table having Primary key SHIP_ID?
Ships_Ship_ID_PK
The DESCRIBE command, (DESC) can be used to show which of the following?
a table’s structure, that is, its columns and data types
A collection of the database objects, such as tables, sequences, views, and indexes, that are owned by a single user account is called a(n) _______.
schema
Which of the following are true for ‘RR’ year designation?
25 means 2025
45 means 2045
68 means 1968
The default time for a date is:
12:00 a.m.
Consider the ADDRESS table that has the following 3 columns and no rows:
ID NUMBER NOT NULL,
ZONE NUMBER,
ZIP_CODE VARCHAR2(5)
COMMIT;
INSERT INTO ADDRESS VALUES (1, 1, ‘94506’);
SAVEPOINT ZONE_ADDRESS_1;
UPDATE ADDRESS SET ZONE = 2 WHERE ZIP_CODE =’94506’;
ROLLBACK;
the ADDRESS table will have no rows.
If a table T3 has four numeric columns (A, B, C, D) and no primary key, which of these statements will succeed? Choose all that apply.
INSERT INTO T3 VALUES (3, 6, 7, NULL);
INSERT INTO T3 VALUES (‘3’, ‘9’, ‘10’, ‘12’);
INSERT INTO T3 SELECT * FROM T3;
What is the result of:
UPDATE cruises
SET cruise_name = ‘Bahamas’, SET start_date = SYSDATE
WHERE cruise_id = 1;
For the all records in the CRUISES table whose cruise_id is 1, cruise_name will be set to ‘Bahamas’ and start_date will be set to the current date
Which of these commands will remove every row in a table, but not delete the table itself? Choose one or more answers.
A DELETE command with no WHERE clause
A TRUNCATE command
CREATE TABLE STUDENT_LIST
(STUDENT_ID NUMBER,
STUDENT_NAME VARCHAR2(30),
STUDENT_PHONE VARCHAR2(20));
INSERT INTO STUDENT_LIST VALUES (1, ‘Joe Wookie’, 3185551212);
The table will create successfully. What will result from the INSERT statement execution?
It will execute and the table will contain one row of data.
A user named SALLY updates some rows, and asks another user MELVIN to login and check the changes before she commits them. Which of the following statements is true about this situation? (Choose the best answer.)
MELVIN cannot see SALLY’s updates because she has not entered the COMMIT command.
CREATE TABLE SHIPS (
Ship_ID NUMBER,
Ship_name VARCHAR2(20),
Home_port_id NUMBER(4));
What will be the result of the following DML statement:
INSERT INTO SHIPS(Ship_name, Ship_ID) VALUES (‘Codd Vessel II’, 4001);
One row will be inserted with ship_ID having a value of 4001, ship_name having value ‘Codd Vessel II’, and Home_port_id will be NULL.
To delete the data values from one entire column in a table (but not remove the column from the table), you would use the ______ command.
UPDATE without a WHERE clause
SALLY updates some rows but does not commit. MELVIN queries the rows that SALLY updated. Which of the following statements is true? (Choose the best answer.)
MELVIN will see the old versions of the rows.
Consider the following table called PARTS:
PNO PART_TITLE STATUS
——- —————– ————
1 Processor V1.0 VALID
2 Encasement X770 PENDING
3 Board CPU XER A7 PENDING
Which of the following SQL statements will remove the word VALID from row 1, resulting in that row with a status of NULL and two rows with a status of PENDING?
None of these answers is correct
The following statement will remove all rows from the vendors table, but leave the table and index structure intact: TRUNCATE TABLE vendors;
True
If you create a SEQUENCE, then you must use it to generate primary key values.
False
Which of the following are true concerning inserting multiple rows at a time? Select 2 correct answers.
the source table must already exist
the columns and datatypes of the source and destination tables must correspond
Which of the following are considered “Transaction control” (select all that apply)
SAVEPOINT
COMMIT
ROLLBACK
Which of the following is not a considered to be DML:
COMMIT
The ALTER command is used to make changes to the data in a table.
FALSE
If all of the records in a table need to be removed, a TRUNCATE is faster than a DELETE, especially if the table is large and contains many rows.
TRUE
An SQL TRUNCATE statement can be undone.
FALSE
______ returns the next available number in the sequence.
NEXTVAL
What value would successfully complete the statement (one answer):
INSERT INTO employees (emp_id, last_name, hire_date) VALUES (256, ‘Monroe’ …
SYSDATE
if a table T3 has four numeric columns (A-D) and no primary key, which of these statements will succeed
INSERT INTO T3 VALUES (3, 9, 10, 12);
INSERT INTO T3 VALUES (3,6,7,NULL)
INSERT INTO T3 SELECT * FROM T3;
What will be the result of the following
CREATE TABLE MAILING_LIST … (‘Smith’, ‘Mary’)
It will execute sucessfully, create a new table and insert 1 row
How can you change the primary key value of a row?
The UPDATE command may be used, but only if the value being inserted is not a duplicate of any primary key values that already exsist
Which of the following commands will terminate a transaction
COMMIT
ROLLBACK
A transaction of one or more SQL statements, followed by either a COMMIT or ROLLBACK command
True
What will be the result of executing the following DML statement:
UPDATE employees SET salary = salary +100;
Every row in the employees table is updated except for the rows that contain NULL as the salary value
Consider the following SELECT statement:
SELECT ship_id
FROM ships
WHERE 10 = 5 + 5;
Which of the following is true of this statement?
It will execute and return the ship_id for each row in the table
Consider the following table named “ports”:
PORT_ID PORT_NAME CAPACITY
———– ————– ————
1 Galveston 4
2 San Diego 4
3 San Francisco 3
4 Los Angeles 4
5 San Juan 3
6 Grand Cayman 3
Now consider the following SELECT statement:
SELECT *
FROM ports
WHERE port_name LIKE ‘San%’
OR port_name LIKE ‘Grand%’
OR capacity = 3;
How many rows from the data in the table will be returned?
4
ACCT_ID CRUISE_NAME START_DATE END_DATE
1 Hawaii 11-JUL-12 24-JUL-12
2 Hawaii 10-OCT-12 23-OCT-12
3 Mexico 04-OCT-12 17-OCT-12
4 Mexico 06-DEC-12 19-DEC-12
What will be the value of the ACCT_ID for the first row displayed, given the following ORDER BY clause:
ORDER BY cruise_name DESC, start_date;
3
The ACCOUNT table contains these columns:
ACCOUNT_ID NUMBER(12)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
You need to accomplish these requirements:
1. Display accounts that have a new balance that is less than the previous balance.
2. Display accounts that have a finance charge that is less than $25.00
3. Display accounts have no finance charge.
Which of the 3 requirements will this SELECT statement accomplish?
SELECT account_ID FROM account
WHERE new_balance < prev_balance OR NVL(finance_charge, 0) < 25;
All three
SELECT order_num, ‘&order_date’
FROM Orders
WHERE order_date_placed = ‘&order_date’;
Which statement regarding the execution of this statement is true?
The user will be prompted for the order_date twice, each time the statement is executed in a session
Which of the following are true of the WHERE clause? Select all that apply.
The WHERE clause comes after the FROM clause
WHERE identifies which rows are to be included in the result set of the SELECT statement
WHERE may be used by SELECT, UPDATE, and DELETE statements
The WHERE clause is optional
A substitution variable can be used to replace: (select all that apply)
a table name
a column name
a WHERE clause
ORDER BY options
What does the following command do? Choose all that apply.
ACCEPT vDept_ID PROMPT ‘Enter a department ID code: ‘
It pauses until the user enters a value and presses RETURN
It displays the text Enter a department ID code:
Which of the following will complete this SELECT statement to return EXACTLY 50% of the resulting rows?
SELECT * FROM ORDERS
FETCH NEXT 50 PERCENT ROWS ONLY
Which of the following is equivalent to:
WHERE salary BETWEEN 3500 and 5000
WHERE salary >= 3500 AND salary <= 5000
Which operator returns records that have no value at all?
IS NULL
The _______ operator is used to test whether a value falls within a range of two boundary values.
BETWEEN
Which of the following job titles will make the following WHERE clause true? (Select all that apply.)
WHERE job_title = ‘SALES_REP’
SALES_REP
Consider the following WHERE clause:
WHERE ship_name LIKE ‘Viking%’
What is function of the percent sign after the word Viking? Select all that apply.
It is the Oracle wildcard symbol
It represents zero of more characters
It means to find all words that start with the word Viking followed by any characters
If you wanted to sort output by a certain column, you would enter
ORDER BY
If a WHERE clause returns no rows, an error message is displayed.
False
Operators such as AND, OR, and NOT are called _____ operators.
Boolean