Ch. 3 Flashcards

1
Q

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;
  • NONE OF THESE INSERT STATEMENTS WILL SUCCEED.
A
  • INSERT INTO T3 VALUES (3, 6, 7, NULL);
  • INSERT INTO T3 VALUES (‘3’, ‘9’, ‘10’, ‘12’);
  • INSERT INTO T3 SELECT * FROM T3;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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 DROP TABLE command
- A TRUNCATE command
- UPDATE command, setting every column to NULL with no WHERE clause

A
  • A DELETE command with no WHERE clause
  • A TRUNCATE command
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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.)

A

MELVIN cannot see SALLY’s updates because she has not entered the COMMIT command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.

  • DELETE COLUMN
  • DROP COLUMN
  • UPDATE without a WHERE clause
  • ALTER TABLE
A
  • UPDATE without a WHERE clause
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.)

A
  • MELVIN will see the old versions of the rows
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The ALTER command is used to make changes to the data in a table?

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

For a transaction, which consists of a series of SQL commands, the idea is that all of them must complete successfully, or none of them.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

______ returns the next available number in the sequence.
- NEXTVAL
- GET_NUM
- NEXT_VAL
- AVAIL_VA

A
  • NEXTVAL
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The following statement will remove all rows from the vendors table, but leave the table and index structure intact: TRUNCATE TABLE vendors:

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

If you create a SEQUENCE, then you must use it to genererate primary key values

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What will be the result of the following statement?

UPDATE departments SET location = ‘Chicago’;

  • An error will occur because there is no WHERE clause
  • no departments will have location set to Chicago due to incorrect syntax of the statement
  • all departments in the table will have location set to Chicago
  • the first department in the table will have location set to Chicago
A
  • all departments will have location set to Chicago due to incorrect syntax of the statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following is not a considered to be DML
- INSERT
- DELETE
- COMMIT
- UPDATE
- MERGE

A
  • COMMIT
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the following are considered “Transaction control” (select all that apply)
- COMMIT
- SAVEPOINT
- DELETE
- ROLLBACK
- UPDATE

A
  • COMMIT
  • ROLLBACK
  • SAVEPOINT
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does TRUNCATE TABLE statement do?

A

Deletes the data inside the table, but not the table itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the purpose of a sequence?

A

generates a number sequence

17
Q

What does NEXTVAL do?

A
  • Returns the next available sequence value
  • It returns a unique value every time it is referenced
18
Q

What does CURVAL do?

A
  • Obtains the current sequence value
19
Q

Differences between TRUNCATE and DELETE

A
  • TRUNCATE is a DDL statement, so it has a COMMIT
  • the deleted data cannot be recovered
  • DELETE is a DML statement, which does not have a commit
  • the deleted data can be recovered
  • TRUNCATE is faster than DELETE
20
Q

Once a commit occurs, all existing savepoints are erased and references to them will generate an error

A

True