SQL loader v1

 #!/bin/bash


# Variables

CSV_FILE="/path/to/your/file.csv"

USERNAME="your_username"

PASSWORD="your_password"

DATABASE="your_database"

TABLE="your_table"


# SQL Loader Control File

CONTROL_FILE="control_file.ctl"


# Create control file

cat <<EOF > $CONTROL_FILE

LOAD DATA

INFILE '$CSV_FILE'

INTO TABLE $TABLE

FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'

(

  column1,

  column2,

  column3

  -- add all your columns here

)

EOF


# Run SQL*Loader

sqlldr $USERNAME/$PASSWORD@$DATABASE CONTROL=$CONTROL_FILE LOG=loader.log BAD=loader.bad


# Check if sqlldr command was successful

if [ $? -eq 0 ]; then

  echo "Data loaded successfully into $TABLE."

else

  echo "Failed to load data into $TABLE."

fi

Comments

Popular posts from this blog

SQL Loader V3

Db Unix

Standby redo log add