This chapter explains how to configure your SQL*Plus command-line environment. It has the following topics:
SQL.Plus Configuration. You can set up your SQL.Plus environment to use the same settings with each session. There are two operating system files to do this: The Site Profile file, glogin.sql, for site wide settings. Additionally, the User Profile, login.sql, sets user specific settings. The exact names of these files is system dependent. You only need to open TCP for both the SQL.Plus and Oracle Enterprise Manager exceptions. The exception configuration for the Oracle Enterprise Manager looks like the following: Now that your firewall is open a bit, you can proceed with testing the Mac OS side of the configuration. Don’t forget to click the OK button to save the port.
Oracle sql plus free download - Insight Developer for Oracle, SQLite Database, Orac, and many more programs. Call it sqlplus, make it executable (chmod 755 sqlplus) and put it into a directory on your PATH (e.g. /usr/bin/), so that bash finds it. Run it like sqlplus user/password@host:port/service. Instant Client Downloads for macOS (Intel x86) See the Instant Client Home Page for more information about Instant Client. The installation instructions are at the foot of the page. Client-server version interoperability is detailed in Doc ID 207303.1.For example, Oracle Call Interface 19.3 and 18.1 can connect to Oracle Database 11.2 or later.
SQL*Plus Environment Variables
These environment variables specify the location or path of files used by SQL*Plus. For other environment variables that influence the behavior of SQL*Plus, see the Oracle Database Administrator's Reference.
Table 2-1 Parameters or Environment Variables influencing SQL*Plus
Parameter or Variable | Description |
---|---|
LD_LIBRARY_PATH | Environment variable to specify the path used to search for libraries on UNIX and Linux. The environment variable may have a different name on some operating systems, such as DYLD_LIBRARY_PATH on Apple Mac OS, LIBPATH on IBM/AIX-5L, and SHLIB_PATH on HP-UX. Not applicable to Windows operating systems. Example |
LOCAL | Windows environment variable to specify a connection string. Performs the same function as TWO_TASK on UNIX. |
NLS_LANG | Environment variable to specify globalization behavior. Example |
ORACLE_HOME | Environment variable to specify where SQL*Plus is installed. It is also used by SQL*Plus to specify where message files are located. Examples: |
ORA_EDITION | Environment variable to specify the database edition to use. If you specify the edition with the CONNECT or SQLPLUS command option, edition=value, it is used instead of ORA_EDITION. If no edition is specified in either the CONNECT or SQLPLUS command option, or in ORA_EDITION, SQL*Plus connects to the default edition. |
ORA_NLS10 | Environment variable to specify the locations of the NLS data and the user boot file in SQL*Plus 10.2. The default location is $ORACLE_HOME/nls/data. In a system with both Oracle9i and 10g, or a system under version upgrade, you should set ORA_NLS10 for Oracle 10g and set ORA_NLS33 for 9i. The default NLS location in 9i was $ORACLE_HOME/common/nls/admin/data. |
ORACLE_PATH | Environment variable to specify the location of SQL scripts. If SQL*Plus cannot find the file in ORACLE_PATH, or if ORACLE_PATH is not set, it searches for the file in the current working directory. Not applicable to Windows |
ORACLE_SID | Environment variable to specify the database instance, optional |
PATH | Environment variable to specify the path to search for executables, and DLLs in Windows. Typically includes ORACLE_HOME/bin |
SQLPATH | Environment variable or Windows registry entry to specify the location of SQL scripts. SQL*Plus searches for SQL scripts, including login.sql, in the current directory and then in the directories specified by SQLPATH, and in the subdirectories of SQLPATH directories. SQLPATH is a colon separated list of directories. There is no default value set in UNIX installations. In Windows, SQLPATH is defined in a registry entry during installation. For more information about the SQLPATH registry entry, see SQLPATH Registry Entry. |
TNS_ADMIN | Environment variable to specify the location of the tnsnames.ora file. If not specified, $ORACLE_HOME/network/admin is used Example |
TWO_TASK | UNIX environment variable to specify a connection string. Connections that do not specify a database will connect to the database specified in TWO_TASK. Example is the same as: |
SQLPATH Registry Entry
The SQLPATH registry entry specifies the location of SQL scripts. SQL*Plus searches for SQL scripts in the current directory and then in the directories specified by the SQLPATH registry entry, and in the subdirectories of SQLPATH directories.
The HKEY_LOCAL_MACHINESOFTWAREORACLEHOME0 registry subkey (or the HOMEn directory for the associated ORACLE_HOME) contains the SQLPATH registry entry. SQLPATH is created with a default value of ORACLE_HOMEDBS. You can specify any directories on any drive as valid values for SQLPATH.
When setting the SQLPATH registry entry, you can concatenate directories with a semicolon (;). For example:
c:oracleora11database;c:oracleora11dbs
See the Registry Editor's help system for instructions on how to edit the SQLPATH registry entry.
SQL*Plus Configuration
You can set up your SQL*Plus environment to use the same settings with each session.
There are two operating system files to do this:
- The Site Profile file, glogin.sql, for site wide settings.
- Additionally, the User Profile, login.sql, sets user specific settings.
The exact names of these files is system dependent.
Some privileged connections may generate errors if SET SERVEROUTPUT or SET APPINFO commands are put in the Site Profile or User Profile.
The following tables show the profile scripts, and some commands and settings that affect the Command-line user interface.
Table 2-2 Profile Scripts affecting SQL*Plus User Interface Settings
This script ... | is run in the Command-line... |
---|---|
Site Profile (glogin.sql) Can contain any content that can be included in a SQL*Plus script, such as system variable settings or other global settings the DBA wants to implement. | After successful Oracle Database connection from a SQLPLUS or CONNECT command. Where /NOLOG is specified. |
User Profile (login.sql) Can contain any content that can be included in a SQL*Plus script, but the settings are only applicable to the user's sessions. | Immediately after the Site Profile. |
Table 2-3 Commands in Profile scripts affecting SQL*Plus User Interface Settings
In a profile script, this command ... | affects the Command-line by ... |
---|---|
Also see the SQL*Plus Compatibility Matrix. | Setting the SQL*Plus compatibility mode to obtain the behavior the DBA wants for this site. |
SQLPLUS command COMPATIBILITY Option | As for SET SQLPLUSCOMPATIBILITY but set with the SQLPLUS command COMPATIBILITY option. |
SQLPLUS command RESTRICT Option | Starting SQL*Plus with the RESTRICT option set to 3 prevents the User Profile script from being read. |
Site Profile
A Site Profile script is created during installation. It is used by the database administrator to configure site-wide behavior for SQL*Plus Command-line connections. The Site Profile script installed during installation is an empty script.
The Site Profile script is generally named glogin.sql. SQL*Plus executes this script whenever a user starts a SQL*Plus session and successfully establishes the Oracle Database connection.
The Site Profile enables the DBA to set up site wide SQL*Plus environment defaults for all users of a particular SQL*Plus installation
Users cannot directly access the Site Profile.
Default Site Profile Script
The Site Profile script is $ORACLE_HOME/sqlplus/admin/glogin.sql in UNIX, and ORACLE_HOMEsqlplusadminglogin.sql in Windows. If a Site Profile already exists at this location, it is overwritten when you install SQL*Plus. If SQL*Plus is removed, the Site Profile script is deleted.
User Profile
For SQL*Plus command-line connections, SQL*Plus also supports a User Profile script. The User Profile is executed after the Site Profile and is intended to allow users to specifically customize their session. The User Profile script is generally named login.sql. SQL*Plus searches for the User Profile in your current directory, and then the directories you specify with the SQLPATH environment variable. SQL*Plus searches this colon-separated list of directories and their subdirectories in the order they are listed.
You can add any SQL commands, PL/SQL blocks, or SQL*Plus commands to your user profile. When you start SQL*Plus, it automatically searches for your user profile and runs the commands it contains.
Modifying Your LOGIN File
You can modify your LOGIN file just as you would any other script. The following sample User Profile script shows some modifications that you could include:
See Also:
Sqlplus Macbook
- SET command for more information on these and other SET command variables you may wish to set in your SQL*Plus LOGIN file.
- Using Predefined Variables for more information about predefined variables.
Storing and Restoring SQL*Plus System Variables
From the Command-line you can store the current SQL*Plus systemvariables in a script with the STORE command. If you alter any variables, this script can be run to restore the original values. This is useful if you want to reset system variables after running a report that alters them. You could also include the script in your User Profile script so that these system variables are set each time you start SQL*Plus.
To store the current setting of all system variables, enter
Enter a file name and file extension, or enter only the file name to use the default extension .SQL. You can use theSET SUF[FIX] {SQL | text} command to change the default file extension.
Restoring the System Variables
To restore the stored system variables, enter
If the file has the default extension (as specified by the SET SUF[FIX] {SQL | text} command), you do not need to add the period and extension to the file name.
You can also use the @ (at sign) or the @@ (double at sign) commands to run the script.
Example 2-1 Storing and Restoring SQL*Plus System Variables
To store the current values of the SQL*Plus system variables in a new script 'plusenv.sql':
Now the value of any system variable can be changed:
The original values of system variables can then be restored from the script:
Installing Command-line Help
Command-line help is usually installed during Oracle Database installation. If not, the database administrator can create the SQL*Plus command-line help tables and populate them with SQL*Plus help data by running a supplied SQL script from SQL*Plus.
The database administrator can also remove the SQL*Plus command-line help tables by running a SQL script from SQL*Plus.
Before you can install or remove SQL*Plus help, ensure that:
- SQL*Plus is installed.
- The ORACLE_HOME environment variable is set.
- The SQL*Plus help script files exist:
- HLPBLD.SQL - to drop and create new help tables.
- HELPDROP.SQL - to drop existing help tables.
- HELPUS.SQL - to populate the help tables with the help data.
Running the hlpbld.sql Script to Install Command-line Help
Run the provided SQL script, HLPBLD.SQL, to load command-line help.
- Log in to SQL*Plus as the SYSTEM user with:You are prompted to enter the password you have defined for the SYSTEM user.
- In UNIX run the SQL script, HLPBLD.SQL, from SQL*Plus with:In Windows run the SQL script, HLPBLD.SQL, from SQL*Plus with:The HLPBLD.SQL script creates and loads the help tables.
Running the helpdrop.sql Script to Remove Command-line Help
Run the provided SQL script, HELPDROP.SQL, to remove the command-line help.
- Log in to SQL*Plus as the SYSTEM user with:You are prompted to enter the password you have defined for the SYSTEM user.
- In UNIX run the SQL script, HELPDROP.SQL, from SQL*Plus with:In Windows run the SQL script, HELPDROP.SQL, from SQL*Plus with:The HELPDROP.SQL script drops the help tables, and then disconnects.
Sql Plus For Macbook
Configuring Oracle Net Services
If you plan to connect to a database other than the default, whether on the same computer or another computer, you need to ensure that Oracle Net is installed, and the database listener is configured and running. Oracle Net services are used by SQL*Plus.
Oracle Net services and the database listener are installed by default during Oracle Database installation. For further information about installing and configuring Oracle Net, see the Oracle Database documentation at
http://www.oracle.com/technology/documentation
.Here I’ll show you how to get SQL Server up and running on your Mac in less than half an hour. And the best part is, you’ll have SQL Server running locally without needing any virtualization software.
Prior to SQL Server 2017, if you wanted to run SQL Server on your Mac, you first had to create a virtual machine (using VirtualBox, Parallels Desktop, VMware Fusion, or Bootcamp), then install Windows onto that VM, then finally SQL Server. This is still a valid option depending on your requirements (here’s how to install SQL Server on a Mac with VirtualBox if you’d like to try that method).
Starting with SQL Server 2017, you can now install SQL Server directly on to a Linux machine. And because macOS is Unix based (and Linux is Unix based), you can run SQL Server for Linux on your Mac. The way to do this is to run SQL Server on Docker.
So let’s go ahead and install Docker. Then we’ll download and install SQL Server.
Install Docker
Download the (free) Docker Community Edition for Mac (unless you’ve already got it installed on your system). This will enable you to run SQL Server from within a Docker container.To download, visit the Docker CE for Mac download page and click Get Docker.To install, double-click on the .dmg file and then drag the Docker.app icon to your Application folder.What is Docker?
Docker is a platform that enables software to run in its own isolated environment. SQL Server (from 2017) can be run on Docker in its own isolated container. Once Docker is installed, you simply download — or “pull” — the SQL Server on Linux Docker Image to your Mac, then run it as a Docker container. This container is an isolated environment that contains everything SQL Server needs to run.Launch Docker
Launch Docker the same way you’d launch any other application (eg, via the Applications folder, the Launchpad, etc).When you open Docker, you might be prompted for your password so that Docker can install its networking components and links to the Docker apps. Go ahead and provide your password, as Docker needs this to run.Increase the Memory
By default, Docker will have 2GB of memory allocated to it. SQL Server needs at least 3.25GB. To be safe, increase it to 4GB if you can.To do this:- Select Preferences from the little Docker icon in the top menu
- Slide the memory slider up to at least 4GB
- Click Apply & Restart
Download SQL Server
Now that Docker is installed and its memory has been increased, we can download and install SQL Server for Linux.Open a Terminal window and run the following command.This downloads the latest SQL Server 2019 for Linux Docker image to your computer.You can also check for the latest container version on the Docker website if you wish.Update: When I first wrote this article, I used the following image:Which downloaded SQL Server 2017. Therefore, the examples below reflect that version.Launch the Docker Image
Run the following command to launch an instance of the Docker image you just downloaded:But of course, use your own name and password. Also, if you downloaded a different Docker image, replacemicrosoft/mssql-server-linux
with the one you downloaded.Here’s an explanation of the parameters:-d
This optional parameter launches the Docker container in daemon mode. This means that it runs in the background and doesn’t need its own Terminal window open. You can omit this parameter to have the container run in its own Terminal window. --name sql_server_demo
Another optional parameter. This parameter allows you to name the container. This can be handy when stopping and starting your container from the Terminal. -e 'ACCEPT_EULA=Y'
The Y
shows that you agree with the EULA (End User Licence Agreement). This is required in order to have SQL Server for Linux run on your Mac.-e 'SA_PASSWORD=reallyStrongPwd123'
Required parameter that sets the sa
database password.-p 1433:1433
This maps the local port 1433 to port 1433 on the container. This is the default TCP port that SQL Server uses to listen for connections. microsoft/mssql-server-linux
This tells Docker which image to use. If you downloaded a different one, use it instead. Password Strength
If you get the following error at this step, try again, but with a stronger password.I received this error when usingreallyStrongPwd
as the password (but of course, it’s not a really strong password!). I was able to overcome this by adding some numbers to the end. However, if it wasn’t just a demo I’d definitely make it stronger than a few dictionary words and numbers.Check the Docker container (optional)
You can type the following command to check that the Docker container is running.If it’s up and running, it should return something like this:Install sql-cli (unless already installed)
Run the following command to install the sql-cli command line tool. This tool allows you to run queries and other commands against your SQL Server instance.This assumes you have NodeJs installed. If you don’t, download it from Nodejs.org first. Installing NodeJs will automatically install npm which is what we use in this command to install sql-cli.Permissions Error?
If you get an error, and part of it reads something likePlease try running this command again as root/Administrator
, try again, but this time prependsudo
to your command:Connect to SQL Server
Now that sql-cli is installed, we can start working with SQL Server via the Terminal window on our Mac.Connect to SQL Server using themssql
command, followed by the username and password parameters.You should see something like this:This means you’ve successfully connected to your instance of SQL Server.Run a Quick Test
Run a quick test to check that SQL Server is up and running and you can query it.For example, you can run the following command to see which version of SQL Server your running:If it’s running, you should see something like this (but of course, this will depend on which version you’re running):If you see a message like this, congratulations — SQL Server is now up and running on your Mac!
A SQL Server GUI for your Mac – Azure Data Studio
Azure Data Studio (formerly SQL Operations Studio) is a free GUI management tool that you can use to manage SQL Server on your Mac. You can use it to create and manage databases, write queries, backup and restore databases, and more.
Azure Data Studio is available on Windows, Mac and Linux.
Here are some articles/tutorials I’ve written for Azure Data Studio:
Sqlplus Mac Os Client
Another Free SQL Server GUI – DBeaver
Sql Plus Download For Mac
Another SQL Server GUI tool that you can use on your Mac (and Windows/Linux/Solaris) is DBeaver.
Sqlplus For Mac
DBeaver is a free, open source database management tool that can be used on most database management systems (such as MySQL, PostgreSQL, MariaDB, SQLite, Oracle, DB2, SQL Server, Sybase, Microsoft Access, Teradata, Firebird, Derby, and more).
I wrote a little introduction to DBeaver, or you can go straight to the DBeaver download page and try it out with your new SQL Server installation.
Limitations of SQL Server for Linux/Mac
SQL Server for Linux does have some limitations when compared to the Windows editions (although this could change over time). The Linux release doesn’t include many of the extra services that are available in the Windows release, such as Analysis Services, Reporting Services, etc. Here’s a list of what’s available and what’s not on SQL Server 2017 for Linux and here’s Microsoft’s list of Editions and supported features of SQL Server 2019 on Linux.
Another limitation is that SQL Server Management Studio is not available on Mac or Linux. SSMS a full-blown GUI management for SQL Server, and it provides many more features than Azure Data Studio and DBeaver (at least at the time of writing). You can still use SSMS on a Windows machine to connect to SQL Server on a Linux or Mac machine, but you just can’t install it locally on the Linux or Mac machine.
If you need any of the features not supported in SQL Server for Linux, you’ll need SQL Server for Windows. However, you can still run SQL Server for Windows on your Mac by using virtualization software. Here’s how to install SQL Server for Windows on a Mac using VirtualBox.