Loading a Database on Sybase

To load the database please follow the procedure outlined below. This will be useful later when you are creating tables and loading actual data into them.

The database will be loaded by first creating the tables and then loading the data for the tables from the data files. Example data definitions are available for the DreamHome and Hotel databases. These are from the book by Connolly and Begg.

Example data files are available for the DreamHome database. These are ready for bulk copying with the field delimiter character being \t and the row delimiter being \n. The delimiters are necessary for the bulk copy utility to parse the files properly. The available data files correspond to the table names. They are as follows.

The procedure for craeting and loading the Dream Home Rental Database is the following:

  1. Set your database option to allow bulk copy.

    At the isql prompt enter (here your database name should be your login ID):

    
    use master 
    go 
    sp_dboption your_database_name, "select into/bulkcopy", true
    go
    use your_database_name
    go
    checkpoint
    go
    
    
  2. Create the tables. You may simply copy the definitions in DreamHome to the isql window, and enter go.
  3. At a terminal prompt, run bcp with the following flags:
    
    bcp table_name in data_file_name -t "\t" -r "\n"
    
    

    For example, to copy data in Branch table use

    
    add dblab
    
    bcp Branch in "/ncsu/dblab/www/mpsingh/local/info/sybase-info/DHRental/Branch.dat" -t "\t" -r "\n"
    
    

    It will prompt for your password and ask a lot of questions to which the default answers are OK. The exceptions are the prefix length for Area in Branch, Address in Owner, Area in Property_For_Rent, and Comment in Viewing, which should be set to 0, and Date in Viewing should be set to 1.

    You can view the complete set of flags for bcp using -h flag.

  4. At this point the tables should have the data in them. You should be able to use SELECT to view the data in the tables:
    	SELECT *
    	FROM Branch
    

The bcp utility can corrupt the non character data. Use UPDATE to correct any fields.