Chapter 4 - Constraints

¡Supera tus tareas y exámenes ahora con Quizwiz!

B. The constraint can be created only with the table-level approach.

In the initial creation of a table, if a UNIQUE constraint is included for a composite column that requires the combination of entries in the specified columns to be unique, which of the following statements is correct? A. The constraint can be created only with the ALTER TABLE command. B. The constraint can be created only with the table-level approach. C. The constraint can be created only with the column-level approach. D. The constraint can be created only with the ALTER TABLE...MODIFY command.

A. 1

What are the maximum number of PRIMARY KEY constraints allowed for a table? A. 1 B. 2 C. 30 D. 255

B. 1

What is the maximum number of columns you can define as a primary key when using the column-level approach to creating a table? A. 0 B. 1 C. 30 D. 255

A. 0

How many NOT NULL constraints can be created at the table level by using the CREATE TABLE command? A. 0 B. 1 C. 12 D. 30 E. 255

C. ALTER TABLE books ADD CONSTRAINT books_pubid_nn NOT NULL (pubid);

Which of the following SQL statements is invalid and returns an error message? A. ALTER TABLE books ADD CONSTRAINT books_pubid_uk UNIQUE (pubid); B. ALTER TABLE books ADD CONSTRAINT books_pubid_pk Primary Key (pubid); C. ALTER TABLE books ADD CONSTRAINT books_pubid_nn NOT NULL (pubid); D. ALTER TABLE books ADD CONSTRAINT books_pubid_fk FOREIGN KEY (pubid) REFERENCES publisher (pubid); E. All of the above statements are invalid

D. ALTER TABLE...ENABLE

Which of the following commands can be used to enable a disabled constraint? A. ALTER TABLE...MODIFY B. ALTER TABLE...ADD C. ALTER TABLE...DISABLE D. ALTER TABLE...ENABLE

E. None of the above commands can be used.

Which of the following commands can you use to rename a constraint? A. RENAME B. ALTER CONSTRAINT C. MOVE D. NEW NAME E. None of the above commands can be used.

D. USER_CONSTRAINTS

Which of the following data dictionary objects should be used to view information about the constraints in a database? A. USER_TABLES B. USER_RULES C. USER_COLUMNS D. USER_CONSTRAINTS E. None of the above objects should be used.

E. None of the above commands is valid

Which of the following is a valid SQL command? A. ALTER TABLE books ADD CONSTRAINT UNIQUE (pubid); B. ALTER TABLE books ADD CONSTRAINT PRIMARY KEY (pubid); C. ALTER TABLE books MODIFY (pubid CONSTRAINT NOT NULL); D. ALTER TABLE books ADD FOREIGN KEY CONSTRAINT (pubid) REFERENCES publisher (pubid); E. None of the above commands is valid

D. None of the above commands can be used. Should be ALTER TABLE...DROP

Suppose you created a PRIMARY KEY constraint at the same time you created a table and later decide to name the constraint. Which of the following commands can you use to change the constraint's name? A. ALTER TABLE...MODIFY B. ALTER TABLE...ADD C. ALTER TABLE...DISABLE D. None of the above commands can be used.

C. the child table in a parent-child relationship

The FOREIGN KEY constraint should be added to which table? A. the table representing the "one" side of a one-to-many relationship B. the parent table in a parent-child relationship C. the child table in a parent-child relationship D. the table that doesn't have a primary key

B. CREATE TABLE table1 (coll1 NUMBER PRIMARY KEY, col2 VARCHAR2 (20), col3 DATE, col4 VARCHAR2 (2) NOT NULL); CONSTRAINT table1_col3_ck CHECK (col3=SYSDATE));

Which of the following is a valid SQL statement? A. CREATE TABLE table1 (coll1 NUMBER PRIMARY KEY, col2 VARCHAR2 (20) PRIMARY KEY, col3 DATE DEFAULT SYSDATE, col4 VARCHAR2 (2)); B. CREATE TABLE table1 (coll1 NUMBER PRIMARY KEY, col2 VARCHAR2 (20), col3 DATE, col4 VARCHAR2 (2) NOT NULL); CONSTRAINT table1_col3_ck CHECK (col3=SYSDATE)); C. CREATE TABLE table1 (coll1 NUMBER, col2 VARCHAR2 (20), col3 DATE, col4 VARCHAR2 (2) PRIMARY KEY (col1)); D. CREATE TABLE table1 (coll1 NUMBER, col2 VARCHAR2 (20), col3 DATE DEFAULT SYSDATE, col4 VARCHAR2 (2);

A. PRIMARY KEYS

Which of the following is not a valid constraint type? A. PRIMARY KEYS B. UNIQUE C. CHECK D. FOREIGN KEY

A. ALTER TABLE tablename ADD CONSTRAINT PRIMARY KEY (columnname);

Which of the following is the valid syntax for adding a PRIMARY KEY constraint to an existing table? A. ALTER TABLE tablename ADD CONSTRAINT PRIMARY KEY (columnname); B. ALTER TABLE tablename ADD CONSTRAINT (columnname) PRIMARY KEY constraintname; C. ALTER TABLE tablename ADD [CONSTRAINT constraint name] PRIMARY KEY; D. None of the above is valid syntax.

E. ON DELETE CASCADE

Which of the following keywords allows the user to delete a record from a table, even if rows in another table reference the record through a FOREIGN KEY constraint? A. CASCADE B. CASCADE ON DELETE C. DELETE ON CASCADE D. DROP E. ON DELETE CASCADE

D. None of the above statements is correct

Which of the following statements is correct? A. A PRIMARY KEY constraint allows NULL values in the primary key column(s) B. You can enable a dropped constraint if you need it in the future C. Every table must have at least one PRIMARY KEY constraint, or Oracle 11g doesn't allow the table to be created D. None of the above statements is correct

A. NOT NULL

Which of the following types of constraints can't be created at the table level? A. NOT NULL B. PRIMARY KEY C. CHECK D. FOREIGN KEY E. None of the above constraints can be created at the table level.

A. NOT NULL

Which of the following types of restrictions can be viewed with the DESCRIBE command? A. NOT NULL B. FOREIGN KEY C. UNIQUE D. CHECK

C. CHECK

Which type of constraint should you use on a column to allow entering only values above 100? A. PRIMARY KEY B. UNIQUE C. CHECK D. NOT NULL

B. 2 Primary keys are already unique and not null by default

You're creating a new table consisting of three columns: col1, Col2, Col3. Col1 should be the primary key and can't have any NULL values, and each entry should be unique. Col3 must not contain any NULL values either. How many total constraints do you have to create? A. 1 B. 2 C. 3 D. 4


Conjuntos de estudio relacionados

Chapter 13 Quiz- Principals of Financial Accounting

View Set

Final Exam for Anatomy and Physiology 1 Mathew Lovelace

View Set

Stratified Random and Cluster Sampling

View Set

respiratory chapter 21 questions

View Set

PrepU Safety, Security, Emergency Preparedness

View Set

Chapter 7 Selecting a mutual fund for a client

View Set

10 - Data Privacy and Protection

View Set