Copying Tables with Defaults, Rules, and/or Triggers

When data is copied into a table, any defaults defined for the columns and datatypes in the table are observed. That is, if there is a null field in the data in a file, the default value is loaded instead during the copy. For example, here are two rows in a file that are to be loaded into authors:

409-56-7008,Bennet,Abraham,415 658-9932,6223 Bateman St.,Berkeley,CA,94705,1
213-46-8915,Green,Marjorie,,309 63rd St. #411,Oakland,CA,94618,1

Commas separate the fields; a new line separates the rows. Note that there is no phone number for Marjorie Green. If the phone column of the titles table had a default of unknown, the rows in the loaded table would look like this:

409-56-7008    Bennet    Abraham        415 658-9932    6223 Bateman St.
    Berkeley CA     94705    1
213-46-8915    Green    Marjorie        unknown         309 63rd St. #41
    Oakland  CA     94618    1

However, rules, triggers and constraints are ignored to load data at the maximum speed. To find any rows that violate rules and triggers, copy the data into the table and run queries or stored procedures that test the rule or trigger conditions. For example:

UPDATE pubs..authors SET au_fname = au_fname