Help > AWS > redshift >
sqlexec
PreviousNext

  • Overview
  • Syntax
  • Arguments
  • Notes
  • Examples
  • Overview

    Run any valid SQL command against Redshift instance. You can supply sql command of script file containing multiple commands (e.g. drop/create tables)

    Download ZappyShell

    Syntax

    sqlexec [--connstr INPUT] [--sql INPUT] [--script-file INPUT]
               [--consoleout FILEPATH] [-v|--verbose] [-w|--wait] [-i|--interactive] 
    

    Arguments

    Parameter Description
    --connstr
    Redshift DB connection string
    --sql
    Redshift DB connection string
    --script-file
    Path of script file which contains SQL Commands you like to execute. Script can contain single or multiple commands (DDL or DML). For multiple commands use [;] as separator (e.g. DROP TABLE1;DROP TABLE2; )
    --consoleout FILEPATH
    Captures console output and saves to file
    -v | --verbose
    Log verbosity level. -v means detailed, If you don't specify this option then minimum logging will be done.
    -w | --wait
    Wait for user input before exit
    -i | --interactive
    Continue in interactive mode after this command is completed. This switch is not applicable if you already in interactive mode

    Notes

    How to Setup Amazon Redshift Cluster

    Click here to learn more

    Examples

    Examples
    Execute single command using direct sql mode.

    sqlexec --sql "drop table public.customers;" --connstr "Host=mytestcluster-1.csu********.us-east-1.redshift.amazonaws.com;Port=5439;Database=dev;UserName=masteruser;Password=*********;EnableSsl=true;Timeout=30;CommandTimeout=3600;"
    Execute multiple commands using direct sql mode.

    sqlexec --sql "drop table public.customers; drop table public.orders;" --connstr "Host=mytestcluster-1.csu********.us-east-1.redshift.amazonaws.com;Port=5439;Database=dev;UserName=masteruser;Password=*********;EnableSsl=true;Timeout=30;CommandTimeout=3600;"
    Execute multiple commands using script file.

    sqlexec --script-file "c:\script\drop-tables.sql" --connstr "Host=mytestcluster-1.csu********.us-east-1.redshift.amazonaws.com;Port=5439;Database=dev;UserName=masteruser;Password=*********;EnableSsl=true;Timeout=30;CommandTimeout=3600;"
    Execute DROP Table Commands (inline SQL)

    sqlexec 
    	--sql "DROP TABLE tbl1;DROP TABLE tbl2;" 
    	--connstr "Host=mytestcluster-1.csu********.us-east-1.redshift.amazonaws.com;Port=5439;Database=dev;UserName=masteruser;Password=*********;EnableSsl=true;Timeout=30;CommandTimeout=3600;"
      
    Execute Commands Stored in Script File

    sqlexec 
    	--script-file "c:\scripts\create-all-tables.sql" 
    	--connstr "Host=mytestcluster-1.csu********.us-east-1.redshift.amazonaws.com;Port=5439;Database=dev;UserName=masteruser;Password=*********;EnableSsl=true;Timeout=30;CommandTimeout=3600;"
      


    www.zappysys.com | Products | All copyrights reserved. ZappySys LLC.