+ All Categories
Home > Documents > Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your...

Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your...

Date post: 19-Mar-2018
Category:
Upload: lamanh
View: 226 times
Download: 1 times
Share this document with a friend
20
CUSTOMER SAP BusinessObjects Predictive Analytics 3.1 2017-10-26 Importing Flat Data Files Into Your DBMS Automated Analytics Configuration Guide
Transcript
Page 1: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

CUSTOMER

SAP BusinessObjects Predictive Analytics 3.12017-10-26

Importing Flat Data Files Into Your DBMSAutomated Analytics Configuration Guide

Page 2: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

Content

1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Importing Flat Files into an Oracle Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.1 Creating the Target Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

Writing the SQL Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Executing the SQL Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Example: Creating a Target Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6

2.2 Creating the Control File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Sample Control Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.3 Importing the Flat File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 Importing a Flat File into IBM DB2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.1 Writing an SQL Query for IBM DB2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.2 Connecting to IBM DB2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.3 Creating Target Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10

Basic IBM DB2 Datatypes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.4 Defining Import Specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.5 Sample SQL Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Sample Customers Data File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Sample Demog Data File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Sample mailings_1_2 Data File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13Sample Sales Data File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.6 Importing the Flat File into IBM DB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4 Importing Flat Files into Microsoft Access. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174.1 Importing a Flat File into a Microsoft Access Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2 C U S T O M E RImporting Flat Data Files Into Your DBMS

Content

Page 3: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

1 Introduction

This document explains how to import flat data files into the following database management systems (DBMS):

● Oracle 8i and lower versions.● IBM DB2 v7.2 and lower versions.● Microsoft Access 2000.

It presents scripts that enable you to:

● Create target tables – which correspond to the flat data files to import – in your DBMS,● Import flat data files into these tables.

These scripts have been tested and will work under UNIX and Windows operating systems (OS). All the examples used for the scripts are based on the flat data files provided as samples for the Data Manager - Event Logging use case. For more information, see the Event Log Aggregation Scenario - Data Manager User Guide on SAP Help Portal at http://help.sap.com/pa.

Importing Flat Data Files Into Your DBMSIntroduction C U S T O M E R 3

Page 4: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

2 Importing Flat Files into an Oracle Database

To Import a flat file into an Oracle Database, you need to:

1. Create a target table, into which the flat file will be imported.2. Create a control file that specifies the import settings.3. Run the control files using the Oracle tool SQL*Loader.

2.1 Creating the Target Table

You need to create a table in an Oracle database before importing flat files.

1. Write an SQL query containing creation statements for the fields contained in the flat file to be imported.2. Execute this query using the Oracle tool SQL*Plus.

Note– SQL*Plus is a command line SQL and PL/SQL language interface and reporting tool that ships with the Oracle Database Server. It can be used interactively or driven from scripts.

NoteAll the scripts were tested on Oracle 8i.

2.1.1 Writing the SQL Query

You need to write a SQL query to create a table in an Oracle database.

● Specify the following information in the query:a. Owner (table schema or user)b. Table namec. Columns specification (name, type, constraints)d. Primary key (if exists)e. Tablespace (logical space disk)

Here is a sample script:

Sample Code

-- Specify the owner

4 C U S T O M E RImporting Flat Data Files Into Your DBMS

Importing Flat Files into an Oracle Database

Page 5: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

CREATE TABLE TABLE_USER.TABLE_NAME(-- Specify the name, type and constraints for each columnCOLUMN_1_NAME datatype,COLUMN_2_NAME datatype,…,COLUMN_N_NAME datatype -- Specify the primary keyPRIMARY KEY(COLUMN_1_NAME))-- Specify the table spaceTABLESPACE TABLE_TABLESPACE;

NoteIn the above script, the command line starting with "--" represents comments.

2.1.1.1 Basic Oracle Datatypes: Uses and Syntax

Use and syntax of basic Oracle datatypes:

● VARCHAR2 – Character data type. Can contain letters, numbers and punctuation. The syntax for this data type is: VARCHAR2(size) where size is the maximum number of alphanumeric characters the column can hold. For example VARCHAR2(25) can hold up to 25 alphanumeric characters. In Oracle8, the maximum size of a VARCHAR2 column is 4,000 bytes.

● NUMBER – Numeric data type. Can contain integer or floating point numbers only. The syntax for this data type is: NUMBER(precision, scale) where precision is the total size of the number including decimal point and scale is the number of places to the right of the decimal. For example, NUMBER(6,2) can hold a number between -999.99 and 999.99.

● DATE – Date and Time data type. Can contain a date and time portion in the format: DD-MON-YY HH:MI:SS. No additional information is needed when specifying the DATE data type. If no time component is supplied when the date is inserted, the time of 00:00:00 is used as a default. The output format of the date and time can be modified to conform to local standards.

2.1.2 Executing the SQL Query

To execute an Oracle SQL query, you need to use the Oracle tool SQL*Plus.

The query is executed in a Microsoft Windows or a UNIX Operating System.

1. Start the tool SQL*Plus., using the command sqlplus.

2. Connect to your database, entering your user name and password.3. To run the script from your database, use the command @SCRIPTNAME.

If you want to run the script contained in the file script.sql, use the command @script.sql.

When you run the command @script.sql, the script.sql file can be proceeded by its folder (from where sqlplus has been started).

Importing Flat Data Files Into Your DBMSImporting Flat Files into an Oracle Database C U S T O M E R 5

Page 6: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

2.1.3 Example: Creating a Target Table

The following SQL script creates Oracle tables for the flat data files provided as samples for the Data Manager - Event Logging use case. For more information about these files, see the Event Log Aggregation Scenario - Data Manager User Guide on SAP Help Portal at http://help.sap.com/pa. In this script, tables are created using the values YOURUSER as the user and YOURTABLESPACE as the tablespace

Sample Code

CREATE TABLE YOURUSER.CUSTOMERS( ID NUMBER NOT NULL,SEX VARCHAR2(10),MARITAL_STATUS VARCHAR2(30),GEOID NUMBER,EDUCATIONNUM NUMBER,OCCUPATION VARCHAR2(20),AGE NUMBER,REFCONT1 NUMBER,REFCONT2 NUMBER,REFCONT3 NUMBER,NOM1 VARCHAR2(1),NOM2 VARCHAR2(1),NOM3 VARCHAR2(2),PRIMARY KEY(ID)) TABLESPACE YOURTABLESPACE;CREATE TABLE YOURUSER.DEMOG(GEO_ID NUMBER NOT NULL,INHABITANTS_K NUMBER,INCOME_K$ NUMBER,CONT1 NUMBER,CONT2 NUMBER,CONT3 NUMBER,CONT4 NUMBER,CONT5 NUMBER,CONT6 NUMBER,CONT7 NUMBER,CONT8 NUMBER,CONT9 NUMBER,CONT10 NUMBER,CONT11 NUMBER,CONT12 NUMBER,CONT13 NUMBER,CONT14 NUMBER,CONT15 NUMBER,CONT16 NUMBER,CONT17 NUMBER,CONT18 NUMBER,CONT19 NUMBER,CONT20 NUMBER,CONT21 NUMBER,CONT22 NUMBER,CONT23 NUMBER,CONT24 NUMBER,CONT25 NUMBER,CONT26 NUMBER,CONT27 NUMBER,CONT28 NUMBER,CONT29 NUMBER,CONT30 NUMBER,CONT31 NUMBER,CONT32 NUMBER,CONT33 NUMBER,CONT34 NUMBER,

6 C U S T O M E RImporting Flat Data Files Into Your DBMS

Importing Flat Files into an Oracle Database

Page 7: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

CONT35 NUMBER,CONT36 NUMBER,CONT37 NUMBER,CONT38 NUMBER,CONT39 NUMBER,CONT40 NUMBER,PRIMARY KEY(GEO_ID))TABLESPACE YOURTABLESPACE;CREATE TABLE YOURUSER.MAILINGS1_2(REFID NUMBER NOT NULL,REF_DATE DATE,RESPONSE VARCHAR2(10),PRIMARY KEY(REFID)) TABLESPACE YOURTABLESPACE;CREATE TABLE YOURUSER.SALES(EVENTID NUMBER NOT NULL,REFID NUMBER,EVENT_DATE DATE,AMOUNT NUMBER,PRIMARY KEY(EVENTID)) TABLESPACE YOURTABLESPACE;

2.2 Creating the Control File

A control file is used to describe the mapping between the flat file to be imported and its corresponding table – that you have created beforehand – in the database. It is also used to describe the specification (delimiter, file name) of the flat file.

● Specify the following:a. Flat data file nameb. Field delimiterc. Columns order

ExampleA control file looks as follows:

LOAD DATA INFILE 'file.txt'-- The command TRUNCATE removes all the rows in the target table.TRUNCATE-- The following specifies TABLE_NAME as the target table.INTO TABLE TABLE_NAME-- The following command specifies that data values are separated by commas.FIELDS TERMINATED BY ','(COLUMN1_NAME, COLUMN2_NAME, COLUMN3_NAME,…, COLUMNN_NAME)

Importing Flat Data Files Into Your DBMSImporting Flat Files into an Oracle Database C U S T O M E R 7

Page 8: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

2.2.1 Sample Control Files

The control files described here are used to import the flat data files provided as samples, for the Data Manager - Event Logging use case, into an Oracle database. For more information about these files, see the Event Log Aggregation Scenario - Data Manager User Guide on SAP Help Portal at http://help.sap.com/pa.

Related Information

Sample Control File for Customers Data [page 8]Sample Control File for Demog Data [page 8]Sample Control File for Mailings1_2 Data [page 9]Sample Control File for Sales Data [page 9]

2.2.1.1 Sample Control File for Customers Data

Sample Code

customers.control LOAD DATAINFILE 'customers.csv'INTO TABLE CUSTOMERSFIELDS TERMINATED BY ';'(ID,SEX,MARITAL_STATUS,GEOID,EDUCATIONNUM,OCCUPATION,AGE,REFCONT1,REFCONT2,REFCONT3,NOM1,NOM2,NOM

2.2.1.2 Sample Control File for Demog Data

Sample Code

demog.control LOAD DATAINFILE 'demog.csv'INTO TABLE DEMOGFIELDS TERMINATED BY ';'(GEO_ID,INHABITANTS_K,INCOME_K$,CONT1,CONT2,CONT3,CONT4,CONT5,CONT6,CONT7,CONT8,CONT9,CONT10,CONT11,CONT12,CONT13,CONT14,CONT15,CONT16,CONT17,CONT18,CONT19,CONT20,CONT21,CONT22,CONT23,CONT24,CONT25,CONT26,CONT27,CONT28,CONT29,CONT30,CONT31,CONT32,CONT33,CONT34,CONT35,CONT36,CONT37,CONT38,CONT39,CONT40)

8 C U S T O M E RImporting Flat Data Files Into Your DBMS

Importing Flat Files into an Oracle Database

Page 9: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

2.2.1.3 Sample Control File for Mailings1_2 Data

Sample Code

mailings1_2.control LOAD DATAINFILE 'mailings1_2.csv'INTO TABLE MAILINGS1_2FIELDS TERMINATED BY ';'(REFID,REF_DATE DATE 'yyyy-mm-dd',RESPONSE)

2.2.1.4 Sample Control File for Sales Data

Sample Code

sales.control LOAD DATAINFILE 'sales.csv'INTO TABLE SALESFIELDS TERMINATED BY ';'(EVENTID,REFID,EVENT_DATE DATE 'yyyy-mm-dd',AMOUNT)For our KEL datasets execute these four command lines:sqlldr control=customers.controlsqlldr control=mailings1_2.controlsqlldr control=demog.controlsqlldr control=sales.control

2.3 Importing the Flat File

To import flat files into an Oracle database, you need to run one control file for each flat file to be imported. To run the control files, you need to use the Oracle tool SQL*Loader.

1. Run the Oracle tool SQL*Loader.2. Run the command sqlldr control=controlfile.

Importing Flat Data Files Into Your DBMSImporting Flat Files into an Oracle Database C U S T O M E R 9

Page 10: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

3 Importing a Flat File into IBM DB2

To import a flat file into IBM DB2, you need to:

1. Write a DB2 SQL query whose function is to connect to IBM DB2, to create the empty table into which the flat data files will be imported, and then to define the import specifications.

2. Execute this DB2 SQL query, using the IBM DB2 command interpreter.

NoteAll the scripts were tested on IBM UDB DB2 v7.1 and v7.2.

3.1 Writing an SQL Query for IBM DB2

● Create an SQL query whose function is to:a. Connect to your IBM DB2 database.b. Create the table into which the flat data files will be imported.c. Define the import specifications.

3.2 Connecting to IBM DB2

● To connect to your IBM DB2 Database, use the following command line, with your database and user names:Connect to DATABASE_NAME user USER_NAME

3.3 Creating Target Table

● Use the following SQL statement to create a target table for IBM DB2:

CREATE TABLE SCHEMA_NAME.TABLE_NAME( COLUMN_1_NAME datatype,COLUMN_2_NAME datatype,…,COLUMN_N_NAME datatype,PRIMARY KEY (COLUMN1_NAME));

10 C U S T O M E RImporting Flat Data Files Into Your DBMS

Importing a Flat File into IBM DB2

Page 11: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

3.3.1 Basic IBM DB2 Datatypes

Here is the list of the main IBM DB2 datatypes:

● CHARACTER● INTEGER● DOUBLE● REAL● TIME● DATE

3.4 Defining Import Specifications

An SQL query whose function is to define the import specification looks like the following:

Sample Code

import from file.txt of del modified by coldel, decpt. method P(1,2,…,N) commitcount NbRows insert into SCHEMA_NAME.TABLE_NAME;

The table below describes each of its commands.

Command Description

coldel, Data values are separated by commas.

decpt. The decimal separator of the flat data file is a dot.

commitcount NbRows IBM DB2 will make a commit after each NbRows rows im­ported.

insert into SCHEMA_NAME.TABLE_NAME The target table is SCHEMA_NAME.TABLE_NAME.

method P(1,2,…N) The N first fields of the flat data file will be imported in the target table.

3.5 Sample SQL Queries

The SQL queries to use for the flat data files provided as samples for the Data Manager - Event Logging use case, into IBM DB2. The function of these queries is to:

● Connect to the IBM DB2 database,● Create the target table, into which the flat data files will be imported,● Define the import specifications.

For more information about these files, see the Event Log Aggregation Scenario - Data Manager User Guide on SAP Help Portal at http://help.sap.com/pa.

Importing Flat Data Files Into Your DBMSImporting a Flat File into IBM DB2 C U S T O M E R 11

Page 12: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

Related Information

Sample Customers Data File [page 12]Sample Demog Data File [page 12]Sample mailings_1_2 Data File [page 13]Sample Sales Data File [page 14]

3.5.1 Sample Customers Data File

Sample Code

db2_customers.sql connect to YOURDATABASE user YOURUSER;create table YOURSCHEMA.CUSTOMERS(ID INTEGER NOT NULL,SEX CHAR(10),MARITAL_STATUS CHAR(30),GEOID INTEGER,EDUCATIONNUM INTEGER,OCCUPATION CHAR(20),AGE INTEGER,REFCONT1 DOUBLE,REFCONT2 DOUBLE,REFCONT3 DOUBLE,NOM1 CHAR(1),NOM2 CHAR(1),NOM3 CHAR(2),PRIMARY KEY (ID));import from customers.csv of del modified by coldel, decpt. method P(1,2,3,4,5,6,7,8,9,10,11,12,13) commitcount 1000 insert into YOURSCHEMA.CUSTOMERS;disconnect YOURDATABASE;

3.5.2 Sample Demog Data File

Sample Code

db2_demog.sql connect to YOURDATABASE user YOURUSER;create table YOURSCHEMA.DEMOG(GEO_ID INTEGER NOT NULL,INHABITANTS_K DOUBLE,INCOME_K$ DOUBLE,CONT1 DOUBLE,CONT2 DOUBLE,CONT3 DOUBLE,CONT4 DOUBLE,CONT5 DOUBLE,CONT6 DOUBLE,CONT7 DOUBLE,

12 C U S T O M E RImporting Flat Data Files Into Your DBMS

Importing a Flat File into IBM DB2

Page 13: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

CONT8 DOUBLE,CONT9 DOUBLE,CONT10 DOUBLE,CONT11 DOUBLE,CONT12 DOUBLE,CONT13 DOUBLE,CONT14 DOUBLE,CONT15 DOUBLE,CONT16 DOUBLE,CONT17 DOUBLE,CONT18 DOUBLE,CONT19 DOUBLE,CONT20 DOUBLE,CONT21 DOUBLE,CONT22 DOUBLE,CONT23 DOUBLE,CONT24 DOUBLE,CONT25 DOUBLE,CONT26 DOUBLE,CONT27 DOUBLE,CONT28 DOUBLE,CONT29 DOUBLE,CONT30 DOUBLE,CONT31 DOUBLE,CONT32 DOUBLE,CONT33 DOUBLE,CONT34 DOUBLE,CONT35 DOUBLE,CONT36 DOUBLE,CONT37 DOUBLE,CONT38 DOUBLE,CONT39 DOUBLE,CONT40 DOUBLE,PRIMARY KEY (GEO_ID));import from demog.csv of del modified by coldel, decpt. method P(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43) commitcount 1000 insert into YOURSCHEMA.DEMOG;disconnect YOURDATABASE;

3.5.3 Sample mailings_1_2 Data File

Sample Code

db2_demog.sql connect to YOURDATABASE user YOURUSER;create table YOURSCHEMA.DEMOG(GEO_ID INTEGER NOT NULL,INHABITANTS_K DOUBLE,INCOME_K$ DOUBLE,CONT1 DOUBLE,CONT2 DOUBLE,CONT3 DOUBLE,CONT4 DOUBLE,CONT5 DOUBLE,CONT6 DOUBLE,CONT7 DOUBLE,CONT8 DOUBLE,CONT9 DOUBLE,

Importing Flat Data Files Into Your DBMSImporting a Flat File into IBM DB2 C U S T O M E R 13

Page 14: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

CONT10 DOUBLE,CONT11 DOUBLE,CONT12 DOUBLE,CONT13 DOUBLE,CONT14 DOUBLE,CONT15 DOUBLE,CONT16 DOUBLE,CONT17 DOUBLE,CONT18 DOUBLE,CONT19 DOUBLE,CONT20 DOUBLE,CONT21 DOUBLE,CONT22 DOUBLE,CONT23 DOUBLE,CONT24 DOUBLE,CONT25 DOUBLE,CONT26 DOUBLE,CONT27 DOUBLE,CONT28 DOUBLE,CONT29 DOUBLE,CONT30 DOUBLE,CONT31 DOUBLE,CONT32 DOUBLE,CONT33 DOUBLE,CONT34 DOUBLE,CONT35 DOUBLE,CONT36 DOUBLE,CONT37 DOUBLE,CONT38 DOUBLE,CONT39 DOUBLE,CONT40 DOUBLE,PRIMARY KEY (GEO_ID));import from demog.csv of del modified by coldel, decpt. method P(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43) commitcount 1000 insert into YOURSCHEMA.DEMOG;disconnect YOURDATABASE;

3.5.4 Sample Sales Data File

Sample Code

db2_demog.sql connect to YOURDATABASE user YOURUSER;create table YOURSCHEMA.DEMOG(GEO_ID INTEGER NOT NULL,INHABITANTS_K DOUBLE,INCOME_K$ DOUBLE,CONT1 DOUBLE,CONT2 DOUBLE,CONT3 DOUBLE,CONT4 DOUBLE,CONT5 DOUBLE,CONT6 DOUBLE,CONT7 DOUBLE,CONT8 DOUBLE,CONT9 DOUBLE,CONT10 DOUBLE,CONT11 DOUBLE,

14 C U S T O M E RImporting Flat Data Files Into Your DBMS

Importing a Flat File into IBM DB2

Page 15: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

CONT12 DOUBLE,CONT13 DOUBLE,CONT14 DOUBLE,CONT15 DOUBLE,CONT16 DOUBLE,CONT17 DOUBLE,CONT18 DOUBLE,CONT19 DOUBLE,CONT20 DOUBLE,CONT21 DOUBLE,CONT22 DOUBLE,CONT23 DOUBLE,CONT24 DOUBLE,CONT25 DOUBLE,CONT26 DOUBLE,CONT27 DOUBLE,CONT28 DOUBLE,CONT29 DOUBLE,CONT30 DOUBLE,CONT31 DOUBLE,CONT32 DOUBLE,CONT33 DOUBLE,CONT34 DOUBLE,CONT35 DOUBLE,CONT36 DOUBLE,CONT37 DOUBLE,CONT38 DOUBLE,CONT39 DOUBLE,CONT40 DOUBLE,PRIMARY KEY (GEO_ID));import from demog.csv of del modified by coldel, decpt. method P(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43) commitcount 1000 insert into YOURSCHEMA.DEMOG;disconnect YOURDATABASE;

3.6 Importing the Flat File into IBM DB

● Under a Microsoft Windows OS, you have to open the DB2 Command Windows , by using the DOS command db2cmd .

● Under UNIX OS, the login user must be able to run db2.

● To start the Flat File Import, use the command: db2 –stf SCRIPTNAMEIf you want to run the script contained in the file script.sql, you will use the command db2 –stf script.sql

ExampleThe IBM DB2 command lines below are used to start the import of the flat data files provided as samples for the SAP BusinessObjects Predictive Analytics Explorer - Event Logging use case, into IBM DB2. For more information about these files, see the Event Log Aggregation Scenario - Data Manager User Guide on SAP Help Portal at http://help.sap.com/pa.

● db2 –stf customers.sql

Importing Flat Data Files Into Your DBMSImporting a Flat File into IBM DB2 C U S T O M E R 15

Page 16: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

● db2 –stf mailings1_2.sql

● db2 –stf demog.sql

● db2 –stf sales.sql

16 C U S T O M E RImporting Flat Data Files Into Your DBMS

Importing a Flat File into IBM DB2

Page 17: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

4 Importing Flat Files into Microsoft Access

Microsoft Access comes with a Wizard that helps you in importing flat data files.

NoteThis wizard lets you import only one flat file at a time.

4.1 Importing a Flat File into a Microsoft Access Database

1. In Microsoft Access, select File Get External Data Import .The Import dialog box appears.

2. In the drop-down menu associated to the field Files of Type, select Text Files.3. Select the flat data files to import, and click Import.

The Import Text Wizard appears. It will guide you through the process of importing your flat files into MS Access.

4. Pay particular attention to specifying data types, keys and indexes.

The table into which the flat data file is imported is automatically created during the import process.

Importing Flat Data Files Into Your DBMSImporting Flat Files into Microsoft Access C U S T O M E R 17

Page 18: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

Important Disclaimers and Legal Information

Coding SamplesAny software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP intentionally or by SAP's gross negligence.

AccessibilityThe information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be a binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however, does not apply in cases of willful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of SAP.

Gender-Neutral LanguageAs far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as "sales person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun does not exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.

Internet HyperlinksThe SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does not warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any damages caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for transparency (see: http://help.sap.com/disclaimer).

18 C U S T O M E RImporting Flat Data Files Into Your DBMS

Important Disclaimers and Legal Information

Page 19: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

Importing Flat Data Files Into Your DBMSImportant Disclaimers and Legal Information C U S T O M E R 19

Page 20: Importing Flat Data Files Into Your DBMS - SAP · PDF fileImporting Flat Data Files Into Your DBMS ... c. Columns order Example ... To import flat files into an Oracle database,

go.sap.com/registration/contact.html

© 2017 SAP SE or an SAP affiliate company. All rights reserved.No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. The information contained herein may be changed without prior notice.Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors. National product specifications may vary.These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names mentioned are the trademarks of their respective companies.Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.


Recommended