55

I am calling SQL*Plus from Linux C Shell:

sqlplus username/password @file.sql var1 var2 var3

If I pass a string as var1, how long can this string be?

Is it governed by the OS? In this case:

Linux version 2.6.9-100.ELsmp ([email protected]) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-11)) #1 SMP Tue Feb 1 12:17:32 EST 2011

Update: Empirical testing yielded the following results:

  • A command line argument of 5200 characters gave the error, "Word too long."
  • 1300 characters then produced the SQL*Plus error, "string beginning "(000796384..." is too long. maximum size is 239 characters."
  • As soon as I got under 239 chars all was well.

I think I'll use sqlldr to overcome this.

2

2 Answers 2

89

Try with: xargs --show-limits </dev/null

Your environment variables take up 2446 bytes
POSIX upper limit on argument length (this system): 2092658
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2090212
Size of command buffer we are actually using: 131072

There is no limit per argument, but a total for the whole command line length. In my system (Fedora 15/zsh) its closer to 2Mb. (line 4).

8
  • 1
    Thanks for this, but unfortunately xargs in this RedHat distribution doesn't have this flag. :( Commented Jul 29, 2011 at 9:51
  • The closest thing to redhat i have is a vps with CentOS 5.4 also with linux 2.6.9. xargs report Maximum length of command we could actually use: 126682. Commented Jul 29, 2011 at 14:30
  • 9
    FYI: A simple way to prevent xargs from hanging after showing the limits is to use echo | xargs --show-limits. It'll cleanly exit.
    – Asclepius
    Commented Jan 23, 2014 at 17:58
  • 6
    @A-B-B FYI: that's not a hang, just press Ctrl-D to give it the EOF it asks for.
    – Behrooz
    Commented Oct 11, 2014 at 13:33
  • Does anyone know whether quotation marks count toward the limit on argument length, or is it just the content of the argument itself? For example, if the limit on argument length was 10, would /bin/echo "0123456789" be at the limit, or two bytes over the limit due to the quotation marks?
    – LinusR
    Commented Jun 16, 2017 at 18:38
58

I came across "How long an argument list your kernel can take on the command line before it chokes?":

getconf ARG_MAX

which gives the following on my system:

131072
10
  • 4
    2621440 here on CentOS 6.2
    – rogerdpack
    Commented Aug 29, 2013 at 17:23
  • 7
    2097152 in Ubuntu Server 14.04 LTS
    – cprcrack
    Commented Aug 5, 2014 at 14:42
  • 2
    262144 on OSX 10.11.2
    – surj
    Commented Feb 18, 2016 at 18:44
  • 1
    2097152 for CentOS 7
    – haxpor
    Commented Oct 29, 2017 at 14:29
  • 1
    2097152 on Ubuntu Server 16.04 LTS
    – pietrop
    Commented Mar 26, 2018 at 15:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.