Data integrity: defaults, rules, and triggers  Rules and triggers

Chapter 4: Using bcp to Transfer Data to and from Adaptive Server

Defaults and datatypes

When copying data into a table, bcp observes any defaults defined for the columns and datatypes. That is, if there is a null field in the data in a file, bcp loads the default value instead of the null value during the copy.

For example, here are two rows in a file to be loaded into authors:

409-56-7008,Bennet,David,415 658-9932,622 Pine
St.,Berkeley,CA,USA,94705213-46-8915,Green,Marjorie,,309 63rd St.
#411,Oakland,CA,USA,94618

Commas separate the fields; a newline terminator separates the rows. There is no phone number for Marjorie Green. Because the phone column of the authors table has a default of “unknown,” the rows in the loaded table look like this:

409-56-7008  Bennet  David 415 658-9932  622 Pine St.
    Berkeley  CA  USA  94705
213-46-8915  Green   Marjorie  unknown       309 63rd St. #411
    Oakland   CA  USA  94618




Copyright © 2005. Sybase Inc. All rights reserved. Rules and triggers

View this book as PDF