Open In App

SQL*Plus Command Reference

Last Updated : 18 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

SQLPlus is a command-line tool for Oracle Database that allows users to interact with the database using SQL and PL/SQL commands. When passing SQL commands as arguments to SQLPlus in a Linux environment, there are limits on the maximum length of the command line. In this article, we will learn about the Maximum length of command line arguments that can be passed to SQL*Plus.

In this article, we will explore the topic of command line arguments in SQLPlus. We’ll discuss their role in customizing SQLPlus sessions, examine the maximum length constraints imposed by operating systems, and provide a practical example.

Command Line Arguments in SQL*Plus

Command line arguments in SQL*Plus serve as parameters that control the behavior of the tool. These arguments can include script names, connection details, and other options. Users frequently utilize these arguments to streamline their workflows and automate tasks.

Maximum Length of Command Line Argument

The maximum length of a command line argument is determined by the operating system. In Linux, the maximum length is typically 131,072 bytes (or 128 KB). This includes the length of the SQL*Plus command, SQL query, and any additional parameters.

Syntax:

sqlplus [username]/[password]@[database] @script.sql

  • sqlplus: Command to start SQL*Plus.
  • [username]/[password]@[database]: Connection details to log in to the Oracle Database.
  • @script.sql: The SQL script file to be executed.

SQL*Plus Limits

Item

Limit

filename length

system dependent

username length

128 bytes

substitution variable name length

128 bytes

substitution variable value length

240 bytes

command-line length

5000 characters

LONG

2,000,000,000 bytes

LINESIZE

system dependent

LONGCHUNKSIZE value

system dependent

output line size

system dependent

SQL or PL/SQL command- line size after variable substitution

3,000 characters (internal only)

number of characters in a COMPUTE command label

500 characters

number of lines per SQL command

500 (assuming 80 characters per line)

maximum PAGESIZE

50,000 lines

total row width

32,767 characters

maximum ARRAYSIZE

5000 rows

maximum number of nested scripts

20

maximum page number

99,999

maximum PL/SQL error message size

2K

maximum ACCEPT character string length

240 bytes

maximum number of substitution variables

2048

Example of SQL*Plus

Exceeding Maximum Length Limit

Now, imagine you have a more complex SQL script file named long_script.sql with a large query:

— long_script.sql

SELECT * FROM employees WHERE salary > 50000 AND department_id IN
(SELECT department_id FROM departments WHERE location_id = 'XYZ')
AND
hire_date < TO_DATE('2022-01-01', 'YYYY-MM-DD')
AND ... (continued)

And you attempt to run the following SQL*Plus command:

sqlplus system/manager@orcl @long_script.sql

In this case, the total length of the SQL*Plus command, along with the connection details, and the lengthy SQL script, might exceed the maximum limit imposed by the operating system. If the length surpasses the limit, you could encounter an error similar to:

bash: /bin/sqlplus: Argument list too long

This error indicates that the total length of the command line argument has exceeded the maximum allowed, and the command cannot be executed.

To avoid this issue, it’s recommended to store complex and lengthy SQL commands or queries in separate script files and execute them using SQL*Plus.

Conclusion

When working with SQLPlus in a Linux environment, it’s essential to be mindful of the maximum length of command line arguments. If your SQL commands or scripts are complex and lengthy, consider storing them in separate script files and executing them using SQLPlus to avoid exceeding the maximum length limit.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads