Presentation on theme: "Oracle Bulk Loader1 Loading data from a file Based on: Ullman et al. Using the Oracle Bulk Loader, www-db.stanford.edu/~ullman/fcdb/oracle/or-load.html."— Presentation transcript:
Oracle Bulk Loader1 Loading data from a file Based on: Ullman et al. Using the Oracle Bulk Loader, www-db.stanford.edu/~ullman/fcdb/oracle/or-load.html
Oracle Bulk Loader2 Purpose of the bulk loader Data comes from many sources –other databases –spread sheets –simple text files Most DBMS's and spread sheets can save data in a simple text file. The Oracle bulk loader reads data from a text file inserting the data into an Oracle table.
Oracle Bulk Loader3 How the bulk reader works 2 input files –the data file someThing.dat –the control file someName.ctl tells the bulk loader how to read the data file –examples constants.ctl –data in the control file - that's exceptional! externalData.ctl + externalData.dat
Oracle Bulk Loader4 Execution The receiving Oracle table must exist prior to execution! sqlldr username control=someName.ctl –sqlldrthe loader (a simple.exe file) –usernamethe owner of the receiving table you'll be prompted for password Result –data inserted into the Oracle table –status files someName.log –a log file telling everything about the execution someName.bad –a file with the data that couldn't be inserted in the table due to constraints, etc.
Oracle Bulk Loader5 Tabs Sometimes the data in the data files are separated by tabs. No problem: Just use tab in the control file Example –tab.ctl
Oracle Bulk Loader6 Dates Problem –Dates can have many formats Solution –Specify the date format in the control file Example –data.ctl
Oracle Bulk Loader7 Nulls Missing data in the data file is interpreted as nulls Example –null.ctl ',' a separator - put more spaces in the missing field.
Oracle Bulk Loader8 Further examples Oracle comes with some examples showing data and control files. On my machine the examples are in –C:\oracle\ora82\RDBMS\demo –Name: ulcaseN.ctlcontrol file ulcaseN.datdata file
Oracle Bulk Loader9 Loading by position Data in data file is structured by position Examples –ulcase2.dat –ulcase2.ctl