Db2 Basics, Part 3

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Jimpepin
J
Jimpepin
Community Contributor
Quizzes Created: 2 | Total Attempts: 255
Questions: 46 | Attempts: 114

SettingsSettingsSettings
Database Quizzes & Trivia

Questions and Answers
  • 1. 

    The ________ data type stores data such as images, audio, and video.

    Explanation
    The BLOB (Binary Large Object) data type is used to store large binary data such as images, audio, and video. It allows for efficient storage and retrieval of these types of data in a database. BLOBs are commonly used in applications that require the storage and management of multimedia files.

    Rate this question:

  • 2. 

    The CLOB data type stores single-byte character set (SBCS) or multibyte character set string values.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Multibyte character set is distinguished from double-byte character set (DBCS), which is processed by the DBCLOB data type.

    Rate this question:

  • 3. 

    ________ let you place logic to enforce business rules within the database, rather than in applications.

    Correct Answer
    constraints
    constraint
    Explanation
    Constraints are used to enforce business rules within the database. They define the rules and restrictions that the data must adhere to, such as the uniqueness of values in a column, the range of values allowed, or the relationships between tables. By placing these rules in the database, rather than in applications, it ensures that the data remains consistent and accurate, regardless of how it is accessed or modified.

    Rate this question:

  • 4. 

    Constraints are ________ that govern     1.  how data values can be ________ to a table, and     2.  how data values in a table can be ________.

    Correct Answer
    rules, added, modified
    rules, added, changed
    rules, added, updated
    Explanation
    Constraints are rules that govern how data values can be added to a table and how data values in a table can be modified or changed.

    Rate this question:

  • 5. 

    Constraints are usually defined during table ________; they can also be added to existing tables with the ________ ________ statement.

    Correct Answer
    creation, ALTER TABLE
    Explanation
    Constraints are typically defined during table creation, specifying the rules and limitations for the data stored in the table. However, constraints can also be added to existing tables using the ALTER TABLE statement. This allows for the modification of the table structure and the addition of constraints after the initial creation of the table.

    Rate this question:

  • 6. 

    Unique constraint versus unique index:  Which are the characteristics of a UNIQUE constraint?

    • A.

      Generally cannot be used in a referential constraint

    • B.

      Does not allow NULL values

    • C.

      Enforces uniqueness

    • D.

      Can be referenced in a referential constraint

    • E.

      Allows NULL values

    Correct Answer(s)
    B. Does not allow NULL values
    C. Enforces uniqueness
    D. Can be referenced in a referential constraint
    Explanation
    A UNIQUE constraint is a database constraint that ensures that the values in a column or a group of columns are unique. It does not allow NULL values, meaning that the column(s) must have a value for every row. It enforces uniqueness, meaning that each value in the column(s) must be unique and not duplicated. Additionally, a UNIQUE constraint can be referenced in a referential constraint, which means it can be used in relationships between tables to maintain data integrity.

    Rate this question:

  • 7. 

    Unique constraint versus unique index:  Which are the characteristics of a unique index?

    • A.

      Does not allow NULL values

    • B.

      Generally cannot be used in a referential constraint

    • C.

      Allows NULL values

    • D.

      Can be referenced in a referential constraint

    • E.

      Enforces uniqueness

    Correct Answer(s)
    B. Generally cannot be used in a referential constraint
    C. Allows NULL values
    E. Enforces uniqueness
    Explanation
    A unique index generally cannot be used in a referential constraint because it is not designed to maintain relationships between tables. It enforces uniqueness by not allowing duplicate values in the indexed column(s). Additionally, it allows NULL values, meaning that the indexed column(s) can have NULL values as long as they are not duplicated. However, it cannot be directly referenced in a referential constraint to establish relationships between tables.

    Rate this question:

  • 8. 

    A ________ column is a unique identifier that represents an individual table record.  Its value is a number sequentially incremented with each new record.

    Correct Answer(s)
    identity
    Explanation
    An identity column is a unique identifier in a table that automatically generates a sequential number for each new record. It is used to uniquely identify each individual record in the table.

    Rate this question:

  • 9. 

    To create a table with the same definition as an existing table, use the statement     CREATE TABLE [TableName] ________ [SourceTable] ...

    Correct Answer(s)
    LIKE
    Explanation
    The keyword "LIKE" is used in the CREATE TABLE statement to create a new table with the same definition as an existing table. By using the "LIKE" keyword followed by the name of the source table, the new table will have the same column names, data types, constraints, and indexes as the source table. This allows for easy duplication of table structures without having to manually specify each column and its properties.

    Rate this question:

  • 10. 

    When using the LIKE clause to create a table with the same definition as an existing table, indicate which of the following are true:

    • A.

      UNIQUE constraints are copied.

    • B.

      Default constraints are copied (unless EXCLUDING COLUMN DEFAULTS is specified).

    • C.

      Referential constraints are copied.

    • D.

      Both tables have the same number of columns.

    • E.

      Triggers are copied.

    • F.

      Indexes are copied.

    • G.

      The columns in the new table have the same names, data types, and nullability features.

    Correct Answer(s)
    B. Default constraints are copied (unless EXCLUDING COLUMN DEFAULTS is specified).
    D. Both tables have the same number of columns.
    G. The columns in the new table have the same names, data types, and nullability features.
    Explanation
    When using the LIKE clause to create a table with the same definition as an existing table, the default constraints are copied unless EXCLUDING COLUMN DEFAULTS is specified. Both tables will have the same number of columns, and the columns in the new table will have the same names, data types, and nullability features. However, unique constraints, referential constraints, triggers, and indexes are not automatically copied.

    Rate this question:

  • 11. 

    CREATE TABLE project    (projno         CHAR(6)  NOT NULL.     projname    VARCHAR(24)  NOT NULL,     deptno        SMALLINT,     budget        DECIMAL(6,2),     startdate     DATE,     enddate      DATE)          The table will be created in table space ________ (the default).     Values must be provided for fields ________ and ________.

    Correct Answer(s)
    USERSPACE1, projno, projname
    Explanation
    The table will be created in the default table space, which is USERSPACE1. Values must be provided for the fields projno and projname.

    Rate this question:

  • 12. 

    CREATE TABLE central.sales    (po_number     INTEGER  NOT NULL  CONSTRAINT uc1 UNIQUE,     date                DATE       NOT NULL  WITH DEFAULT,     office              CHAR(128)  NOT NULL  WITH DEFAULT 'Dallas',     amt                DECIMAL(10,2)  NOT NULL  CHECK (amt > 99.99))   IN my_space     Must provide values for fields ________ and ________.  An index was provided for field ________.  The default for the date field is the ________ ________.  The sales table will be created in schema ________ and table space ________.  

    Correct Answer(s)
    po_number, amt, po_number, system date, central, my_space
    Explanation
    Values must be provided for the fields po_number and amt. An index was provided for the field po_number. The default for the date field is the system date. The sales table will be created in the schema central and table space my_space.

    Rate this question:

  • 13. 

    CREATE TABLE payroll.employees      (empid             INTEGER  NOT NULL  PRIMARY KEY,       emp_fname    CHAR(30),       emp_lname    CHAR(30))  CREATE TABLE payroll.paychecks      (empid               INTEGER,       weeknumber    CHAR(3),       pay_amt           DECIMAL(6,2),       CONSTRAINT fkconst  FOREIGN KEY (empid)             REFERENCES employee(empid)  ON DELETE CASCADE,       CONSTRAINT chk1  CHECK (pay_amt > 0  AND  weeknumber BETWEEN 1 AND 52))  For table 'employees':       Values must be provided for ________.       Every value provided for ________ must be unique.       An index was provided for the ________ column.  For table 'paychecks':       pay_amt has a ________ of 6 and a ________ of 2.       Every value in paychecks.________ must have a matching value in employees.________, due to CONSTRAINT ________.       Whenever a row is ________ from table employees, all rows in table paychecks that have the same value will also be ________.   

    Correct Answer(s)
    empid, empid, empid, precision, scale, empid, empid, fkconst, deleted, deleted
    Explanation
    For table 'employees', values must be provided for the empid column. Every value provided for empid must be unique. An index was provided for the empid column.

    For table 'paychecks', pay_amt has a precision of 6 and a scale of 2. Every value in paychecks.empid must have a matching value in employees.empid, due to CONSTRAINT fkconst. Whenever a row is deleted from table employees, all rows in table paychecks that have the same value will also be deleted.

    Rate this question:

  • 14. 

    CREATE TABLE employee      (empid            SMALLINT  NOT NULL  GENERATED BY DEFAULT AS IDENTITY,       firstname       VARCHAR(30)  NOT NULL,       lastname       VARCHAR(30)  NOT NULL,       deptid            CHAR(3),       edlevel          CHAR(1)  CHECK(edlevel IN ('C','H','N')),       CONSTRAINT  emp_pk  PRIMARY KEY (empid),       CONSTRAINT  emp_dept_fk  FOREIGN KEY (deptid)                 REFERENCES department(deptno))  'empid' is a ________ column.  Values must be supplied for fields ________ and ________.  Constraints are not named when they are part of the ________ definition, as for field ________.  Every value entered in field ________ must be unique, due to its constraint.  An index was created for field ________, due to its constraint.  Every value entered entered in field ________ must have a matching value in the ________ field of table ________, due to referential constraint ________.  

    Correct Answer(s)
    identity, firstname, lastname, column, edlevel, empid, empid, deptid, deptno, department, emp_dept_fk
    identity, firstname, lastname, field, edlevel, empid, empid, deptid, deptno, department, emp_dept_fk
    Explanation
    The column "empid" is an identity column. Values must be supplied for fields "firstname" and "lastname". Constraints are not named when they are part of the column definition, as for field "edlevel". Every value entered in field "empid" must be unique, due to its constraint. An index was created for field "empid", due to its constraint. Every value entered in field "deptid" must have a matching value in the "deptno" field of table "department", due to referential constraint "emp_dept_fk".

    Rate this question:

  • 15. 

    CREATE TABLE stock.activity      (activityno   SMALLINT  NOT NULL  GENERATED BY DEFAULT AS IDENTITY                 (START WITH 10  INCREMENT BY 10),       actkwd       CHAR(6)      NOT NULL,       actdesc      VARCHAR(20)  NOT NULL,       UNIQUE (activityno))  'activityno' is a ________ column.  Values must be provided for columns ________ and ________.  An index is created for column ________.  In 'stock.activity', 'stock' identifies the ________.  

    Correct Answer(s)
    identity, actkwd, actdesc, activityno, schema
    Explanation
    In the given CREATE TABLE statement, the column "activityno" is defined as a SMALLINT column with the GENERATED BY DEFAULT AS IDENTITY clause. This means that the values for this column will be automatically generated by the system, starting with 10 and incrementing by 10 for each new row. The columns "actkwd" and "actdesc" are defined as NOT NULL, which means that values must be provided for these columns when inserting data into the table. The UNIQUE constraint is applied to the "activityno" column, which means that each value in this column must be unique. The term "stock" in "stock.activity" identifies the schema to which the table belongs.

    Rate this question:

  • 16. 

    CREATE TABLE self_reference      (idcol1     SMALLINT  NOT NULL  PRIMARY KEY,       idcol2     SMALLINT,       CONSTRAINT fkconst  FOREIGN KEY (idcol2)                 REFERENCES self_reference(idcol1))  Every value in column ________ must have a matching value in column ________, due to constraint ________.  ________ is the parent key, and ________ is the foreign key.  Every value of column ________ must be unique.  A ________ was created for column idcol1, due to the PRIMARY KEY constraint.  Table self_reference will be created in table space ________.  

    Correct Answer(s)
    idcol2, idcol1, fkconst, idcol1, idcol2, idcol1, index, USERSPACE1
    Explanation
    The column idcol2 must have a matching value in column idcol1, due to the foreign key constraint fkconst. In this case, idcol1 is the parent key and idcol2 is the foreign key. Every value of column idcol1 must be unique, which is why an index was created for column idcol1, due to the PRIMARY KEY constraint. The table self_reference will be created in table space USERSPACE1.

    Rate this question:

  • 17. 

    Which are the characteristics of base tables?

    • A.

      Table name must be unique within a schema.

    • B.

      Not persistent - only used by the application that created it.

    • C.

      Only used for the life of the application.

    • D.

      Descriptions and constraints stored in system catalog tables of the database.

    • E.

      Many apps can create a table with the same name.

    Correct Answer(s)
    A. Table name must be unique within a schema.
    D. Descriptions and constraints stored in system catalog tables of the database.
    Explanation
    Base tables are the foundational tables in a database schema. They must have a unique name within a schema to avoid conflicts. Additionally, the descriptions and constraints of the base tables are stored in the system catalog tables of the database, which provide metadata about the tables. This allows for better organization and management of the tables. Other characteristics mentioned in the question, such as not being persistent and being used only for the life of the application, are not specific to base tables and can apply to other types of tables as well.

    Rate this question:

  • 18. 

    Which are the characteristics of declared temporary tables?

    • A.

      Not persistent - only used by the application that created it.

    • B.

      Descriptions and constraints stored in system catalog tables of the database.

    • C.

      Many apps can create a table with the same name.

    • D.

      Only used for the life of the application.

    • E.

      Table name must be unique within a schema.

    Correct Answer(s)
    A. Not persistent - only used by the application that created it.
    C. Many apps can create a table with the same name.
    D. Only used for the life of the application.
    Explanation
    Declared temporary tables are not persistent, meaning that they are not stored permanently in the database. They are only used by the application that created them and exist only for the duration of that application's execution. Additionally, multiple applications can create a table with the same name, as the temporary tables are scoped within the application that created them. The descriptions and constraints of these tables are stored in the system catalog tables of the database.

    Rate this question:

  • 19. 

    The GENERATED ... AS IDENTITY clause may be used when creating a declared temporary table.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The GENERATED ... AS IDENTITY clause can be used when creating a declared temporary table. This clause allows for the automatic generation of unique values for a specified column in the temporary table. Therefore, the statement is true.

    Rate this question:

  • 20. 

    The contents of a declared temporary table may be retained after a transaction is committed.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    True, if the ON COMMIT PRESERVE ROWS clause is used.

    Rate this question:

  • 21. 

    A ________ is an ordered set of ________ that refers to rows in a base table.

    Correct Answer
    index, pointers
    Explanation
    An index is a data structure that contains pointers to the rows in a base table. It provides a quick way to locate specific rows based on the values of one or more columns. By using an index, the database system can efficiently retrieve the desired rows without having to scan the entire table. The pointers in the index refer to the physical locations of the rows, allowing for fast access and retrieval of data.

    Rate this question:

  • 22. 

    An index is based on one or more columns, known as the ________, in the base table.

    Correct Answer
    key
    Explanation
    An index is based on one or more columns, known as the key, in the base table. In other words, the key columns are the columns that the index is created on. These key columns are used to organize and sort the data in the index, making it easier and faster to retrieve specific records from the table.

    Rate this question:

  • 23. 

    To create an index, you must use the CREATE INDEX statement.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    An index may also be created implicitly; e.g., to support a table's primary key.

    Rate this question:

  • 24. 

    Using the CREATE INDEX statement, secondary columns may be stored in the index along with the key.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Unlike the key, the secondary columns are not used to enforce data uniqueness.

    Rate this question:

  • 25. 

    Data uniqueness is automatically enforced when an index is created with the CREATE INDEX statement.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The UNIQUE keyword must be specified; i.e., CREATE UNIQUE INDEX [IndexName] ...

    Rate this question:

  • 26. 

    The ________ option of the CREATE INDEX statement will cause these effects:  *  DB2 Database Manager tries to store records on a page that contains other records that have similar index key values.  *  If no space available on that page, it will try to store the record on a nearby page.  *  Increases performance by decreasing I/O required to access data.  

    Correct Answer
    CLUSTER
    Explanation
    The CLUSTER option of the CREATE INDEX statement will cause these effects: the DB2 Database Manager will attempt to store records on a page that already contains other records with similar index key values. If there is no space available on that page, it will try to store the record on a nearby page. This technique increases performance by reducing the amount of I/O required to access data, as it ensures that related records are physically stored close to each other.

    Rate this question:

  • 27. 

    Only one index in a table can be a clustering index.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A clustering index determines the physical order of data in a table. It is used to arrange the rows in the table based on the values of one or more columns. Since the physical order of data can only be determined by one index, only one index in a table can be a clustering index. Therefore, the statement that only one index in a table can be a clustering index is true.

    Rate this question:

  • 28. 

    ________ provides a way to cluster data along multiple dimensions automatically.

    Correct Answer
    MDC
    MDC index
    multidimensional clustering
    multidimensional clustering index
    Explanation
    Multidimensional clustering (MDC) provides a way to cluster data along multiple dimensions automatically. It is a technique used in database management systems to organize data in a multidimensional space, allowing for efficient retrieval and analysis of data based on multiple criteria. MDC index refers to the index structure used to support multidimensional clustering. Therefore, both MDC and MDC index are correct answers for this question.

    Rate this question:

  • 29. 

    A ________ defines a set of actions to be executed whenever an insert, update, or delete operation is performed against a table or updatable view.

    Correct Answer
    trigger
    Explanation
    A trigger is a database object that defines a set of actions to be executed whenever an insert, update, or delete operation is performed against a table or updatable view. Triggers are used to enforce business rules, maintain data integrity, and automate tasks in response to database changes. When a specified operation occurs, the trigger is activated and the defined actions are executed.

    Rate this question:

  • 30. 

    Triggers can be used to:

    • A.

      Create a table.

    • B.

      Enforce data integrity and business rules.

    • C.

      Invoke functions: e.g. to issue errors or alerts.

    • D.

      Generate/transform values for inserted or updated rows.

    • E.

      Join tables or view.

    • F.

      Update other tables.

    Correct Answer(s)
    B. Enforce data integrity and business rules.
    C. Invoke functions: e.g. to issue errors or alerts.
    D. Generate/transform values for inserted or updated rows.
    F. Update other tables.
    Explanation
    Triggers are used in database management systems to enforce data integrity and business rules. They can be used to invoke functions, such as issuing errors or alerts, when certain conditions are met. Triggers can also generate or transform values for inserted or updated rows, and update other tables. These capabilities make triggers a powerful tool for maintaining the integrity and consistency of data within a database.

    Rate this question:

  • 31. 

    Which are components of a trigger?

    • A.

      Subject table or view

    • B.

      Trigger event

    • C.

      Trigger sensitivity

    • D.

      Trigger activation time

    • E.

      Set of affected columns

    • F.

      Set of affected rows

    • G.

      Trigger granularity

    • H.

      Triggered action

    Correct Answer(s)
    A. Subject table or view
    B. Trigger event
    D. Trigger activation time
    F. Set of affected rows
    G. Trigger granularity
    H. Triggered action
    Explanation
    A trigger is a database object that is associated with a table or view and is automatically executed or fired when a specified event occurs. The components of a trigger include the subject table or view (the table or view on which the trigger is defined), the trigger event (the specific event that will cause the trigger to be fired), the trigger activation time (whether the trigger is fired before or after the event), the set of affected rows (the rows that are affected by the trigger), the trigger granularity (whether the trigger is fired for each affected row or for the entire set of affected rows), and the triggered action (the action or set of actions that the trigger performs when fired).

    Rate this question:

  • 32. 

    A ________ ________ is an SQL operation that, when performed against the subject table or view, activates the trigger; must be an INSERT, UPDATE, or DELETE.

    Correct Answer(s)
    trigger event
    Explanation
    A trigger event in SQL is an operation (INSERT, UPDATE, or DELETE) that, when executed on the subject table or view, activates the trigger. Triggers are database objects that are designed to automatically execute a set of actions or procedures in response to specific events or changes in the database. In this case, the trigger event is the specific operation (INSERT, UPDATE, or DELETE) that triggers the execution of the trigger.

    Rate this question:

  • 33. 

    The three trigger activation time keywords are (in alpha order) ________, ________, and ________.

    Correct Answer(s)
    AFTER, BEFORE, INSTEAD OF
    Explanation
    The three trigger activation time keywords listed in alphabetical order are AFTER, BEFORE, and INSTEAD OF. These keywords are commonly used in programming or database management systems to specify the timing of trigger actions. The AFTER keyword is used to specify that the trigger action should occur after the triggering event, the BEFORE keyword is used to specify that the trigger action should occur before the triggering event, and the INSTEAD OF keyword is used to specify that the trigger action should replace the triggering event.

    Rate this question:

  • 34. 

    The ________ ________ specifies whether the trigger actions will be performed once for the entire insert, update, or delete operation (trigger event), or once for every row affected by the operation.

    Correct Answer(s)
    trigger granularity
    Explanation
    The term "trigger granularity" refers to the level at which trigger actions will be executed. It determines whether the trigger actions will be performed once for the entire insert, update, or delete operation (trigger event), or once for every row affected by the operation. In other words, it specifies whether the trigger actions should be applied at the operation level or at the individual row level.

    Rate this question:

  • 35. 

    The ________ ________ is an optional search condition and a set of SQL statements to be executed when the trigger is activated.

    Correct Answer(s)
    triggered action
    Explanation
    The triggered action refers to the set of SQL statements that are executed when the trigger is activated. It is an optional search condition that determines when the trigger should be triggered and specifies the actions to be performed when the condition is met.

    Rate this question:

  • 36. 

    Possible triggered actions - BEFORE trigger:

    • A.

      Signal SQL states

    • B.

      Retrieve data

    • C.

      Insert, update, and delete records

    • D.

      Set transition variables

    Correct Answer(s)
    A. Signal SQL states
    B. Retrieve data
    D. Set transition variables
    Explanation
    The possible triggered actions that can occur before a trigger are: signaling SQL states, retrieving data, inserting, updating, and deleting records, and setting transition variables. These actions can be performed before the trigger is executed and can help in preparing the environment or gathering necessary information for the trigger to function properly.

    Rate this question:

  • 37. 

    Possible triggered actions - AFTER trigger:

    • A.

      Signal SQL states

    • B.

      Insert, update, and delete records

    • C.

      Retrieve data

    • D.

      Set transition variables

    Correct Answer(s)
    A. Signal SQL states
    B. Insert, update, and delete records
    C. Retrieve data
    Explanation
    The given answer lists the possible triggered actions that can be performed in an AFTER trigger. These actions include signaling SQL states, retrieving data, and performing operations such as inserting, updating, and deleting records. Additionally, it is also possible to set transition variables in an AFTER trigger.

    Rate this question:

  • 38. 

    A ________ variable is a qualified column name that indicates whether the reference is to the original value (before an insert, update, or delete) or to the new value.

    Correct Answer(s)
    transition
    Explanation
    A transition variable is a qualified column name that indicates whether the reference is to the original value (before an insert, update, or delete) or to the new value. This variable helps to differentiate between the original and new values during database operations such as inserts, updates, or deletes. It is used to track the changes made to a column and is particularly useful in trigger functions where the original and new values need to be compared or manipulated.

    Rate this question:

  • 39. 

    A ________ ________ uses subject table names, but allows the complete set of affected rows to be treated as a table.  Can only be used in AFTER triggers.

    Correct Answer(s)
    transition table
    Explanation
    A transition table is a feature that uses subject table names and allows the complete set of affected rows to be treated as a table. This table is specifically used in AFTER triggers. It provides a way to access and manipulate the rows that have been affected by the trigger action. This allows for further processing or analysis of the affected data within the trigger logic.

    Rate this question:

  • 40. 

    CREATE TRIGGER pay_raise  NO CASCADE BEFORE UPDATE ON employees  FOR EACH ROW  SET new.salary = salary * 1.1  The subject table is ________.  The trigger event is ________.  BEFORE is the ________ ________ ________.  

    Correct Answer(s)
    employees, UPDATE, trigger activation time
    Explanation
    The subject table in this trigger is "employees" as specified in the CREATE TRIGGER statement. The trigger event is "UPDATE" as indicated by the BEFORE UPDATE clause. "BEFORE" is the trigger activation time, meaning the trigger will be executed before the update operation takes place on the "employees" table.

    Rate this question:

  • 41. 

    CREATE TRIGGER pay_raise  NO CASCADE BEFORE UPDATE ON employees  FOR EACH ROW  SET new.salary = salary * 1.1  The line  FOR EACH ROW  is an example of ________ ________.  The SET statement is an example of a ________ ________.  new.salary is an example of a ________ ________.   

    Correct Answer(s)
    trigger granularity, triggered action, transition variable
    Explanation
    The line "FOR EACH ROW" is an example of trigger granularity, as it specifies that the trigger should be executed for each row that is updated in the "employees" table. The SET statement is an example of a triggered action, as it defines the action that should be performed when the trigger is activated. "new.salary" is an example of a transition variable, as it refers to the new value of the "salary" column for the updated row.

    Rate this question:

  • 42. 

    CREATE TRIGGER block_deletesNO CASCADE BEFORE DELETE ON activity_historyFOR EACH ROWSIGNAL SQLSTATE '75002'            SET MESSAGE_TEXT = 'Deletes not allowed!'  The subject table is ________.  The trigger event is ________.  The trigger activation time is ________.  

    Correct Answer(s)
    activity_history, DELETE, BEFORE
    Explanation
    The subject table in this trigger is "activity_history". The trigger event is "DELETE" which means the trigger will be activated when a delete operation is performed on the activity_history table. The trigger activation time is "BEFORE" which means the trigger will be executed before the delete operation takes place.

    Rate this question:

  • 43. 

    CREATE TRIGGER block_deletesNO CASCADE BEFORE DELETE ON activity_historyFOR EACH ROW  SIGNAL SQLSTATE '75002'            SET MESSAGE_TEXT = 'deletes not allowed!'  The line  FOR EACH ROW  is an example of ________ ________.  The SIGNAL and SET statements are examples of ________ ________.  

    Correct Answer(s)
    trigger granularity, triggered actions
    Explanation
    The line "FOR EACH ROW" is an example of trigger granularity as it specifies that the trigger should be executed for each row that is affected by the DELETE statement. The SIGNAL and SET statements are examples of triggered actions as they are the actions that are performed when the trigger is executed, in this case, signaling an SQLSTATE and setting the message text.

    Rate this question:

  • 44. 

    CREATE TRIGGER trigger_a  AFTER INSERT ON sales  REFERENCING NEW AS n  FOR EACH ROW  UPDATE sales SET sale_date = CURRENT_DATE            WHERE invoice = n.invoice  The subject table is ________.  INSERT is the ________ ________.      The trigger activation time is ________.    FOR EACH ROW indicates the ________ ________.    The triggered action is the ________ statement.    n.invoice is an example of a ________ ________.    

    Correct Answer(s)
    sales, trigger event, AFTER, trigger granularity, UPDATE, transition variable
    Explanation
    The subject table in this trigger is "sales" because the trigger is defined on the "sales" table. "INSERT" is the trigger event because the trigger is activated after an insert operation on the "sales" table. The trigger activation time is "AFTER" because the trigger is fired after the insert operation. "FOR EACH ROW" indicates that the trigger is executed for each row affected by the insert operation. The triggered action is an "UPDATE" statement because the trigger updates the "sale_date" column. "n.invoice" is an example of a transition variable because it references the new value of the "invoice" column in the inserted row.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 15, 2014
    Quiz Created by
    Jimpepin

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.