Sei sulla pagina 1di 4
SELF TEST Categorize the Main Database Objects 1. A. It will be an orphaned table,
SELF TEST
Categorize the Main Database Objects
1.
A.
It will be an orphaned table, without a schema.
B.
The creation will fail.

C.

D. It will be in the schema of the user creating it.

E. It will be in the PUBLIC schema.

It will be in the SYS schema.

Self Test

479

The following questions will help you measure your understanding of the material presented in this chapter. Read all the choices carefully because there might be more than one correct answer. Choose all the correct answers for each question.

If a table is created without specifying a schema, in which schema will it be? (Choose the best answer.)

2. Several object types share the same namespace, and therefore cannot have the same name in the same schema. Which of the following object types is not in the same namespace as the others? (Choose the best answer.)

A. Index

B. PL/SQL stored procedure

C. Synonym

D. Table

E. View

3. Which of these statements will fail because the table name is not legal? (Choose two answers.)

A. create table “SELECT” (col1 date);

B. create table “lowercase” (col1 date);

C. create table number1 (col1 date);

D. create table 1number (col1 date);

E. create table update (col1 date);

Review the Table Structure

4. What are distinguishing characteristics of heap tables? (Choose two answers.)

A. A heap can store variable length rows.

B. More than one table can store rows in a single heap.

C. Rows in a heap are in random order.

480 Chapter 11:

Using DDL Statements to Create and Manage Tables

D. Heap tables cannot be indexed.

E. Tables in a heap do not have a primary key.

List the Data Types that Are Available for Columns

5. Which of the following data types are variable length? (Choose all correct answers.)

A. BLOB

B. CHAR

C. LONG

D. NUMBER

E. RAW

F. VARCHAR2

6. Study these statements:

create table tab1 (c1 number(1), c2 date); alter session set nls_date_format='dd-mm-yy'; insert into tab1 values (1.1,’31-01-07’);

Will the insert succeed? (Choose the best answer)

A. The insert will fail because the 1.1 is too long.

B. The insert will fail because the ’31-01-07’ is a string, not a date.

C. The insert will fail for both reasons A and B.

D. The insert will succeed.

7. Which of the following is not supported by Oracle as an internal data type? (Choose the best answer.)

A. CHAR

B. FLOAT

C. INTEGER

D. STRING

Create a Simple Table

8. Consider this statement:

create table t1 as select * from regions where 1=2;

What will be the result? (Choose the best answer.)

Self Test

481

A. There will be an error because of the impossible condition.

B. No table will be created because the condition returns FALSE.

C. The table T1 will be created but no rows inserted because the condition returns FALSE.

D. The table T1 will be created and every row in REGIONS inserted because the condition returns a NULL as a row filter.

9. When a table is created with a statement such as the following:

create table newtab as select * from tab;

will there be any constraints on the new table? (Choose the best answer.)

A. The new table will have no constraints, because constraints are not copied when creating tables with a subquery.

B. All the constraints on TAB will be copied to NEWTAB.

C. Primary key and unique constraints will be copied but not check and not null constraints.

D. Check and not null constraints will be copied but not unique or primary key.

E. All constraints will be copied, except foreign key constraints.

Explain How Constraints Are Created at the Time of Table Creation

10. Which types of constraint require an index? (Choose all that apply.)

A. CHECK

B. NOT NULL

C. PRIMARY KEY

D. UNIQUE

11. A transaction consists of two statements. The first succeeds, but the second (which updates several rows) fails partway through because of a constraint violation. What will happen? (Choose the best answer.)

A. The whole transaction will be rolled back.

B. The second statement will be rolled back completely, and the first will be committed.

C. The second statement will be rolled back completely, and the first will remain uncommitted.

D. Only the one update that caused the violation will be rolled back; everything else will be committed.

E. Only the one update that caused the violation will be rolled back; everything else will remain uncommitted.

482 Chapter 11:

Using DDL Statements to Create and Manage Tables

LAB QUESTION

Consider this simple analysis of a telephone billing system:

A subscriber is identified by a customer number and also has a name and possibly one or more

telephones.

A telephone is identified by its number, which must be a 7-digit integer beginning with 2 or 3, and

also has a make, an activation date, and a flag for whether it is active. Inactive telephones are not

assigned to a subscriber; active telephones are. For every call, it is necessary to record the time it started and the time it finished. Create tables with constraints and defaults that can be used to implement this system.