PL/SQL - Environment Setup
PL/SQL is not a stand-alone programming language; it is a tool within the Oracle programming environment. SQL* Plus is an interactive tool that allows you to type SQL and PL/SQL statements at the command prompt. These commands are then sent to the database for processing. Once the statements are processed, the results are sent back and displayed on screen.
To run PL/SQL programs, you should have Oracle RDBMS Server installed in your machine which will take care of executing SQL commands. Most recent version of Oracle RDBMS is 11g. You can download a trial version of Oracle 11g from the following link:
You will have to download either 32bit or 64 bit version of the installation as per your operating system. Usually there are two files, as I have downloaded for 64 bit Windows7. You will also use similar steps on your operating system, does not matter if it is Linux or Solaris.
After downloading above two files, you will need to unzip them in a single directory database and under that you will find following sub-directories:
Now, let's launch Oracle Database Installer using setup file. Following is the first screen. You can provide your email ID and uncheck, check box and click Next button:
You will have the following screen, just uncheck the check box and click continue button to proceed.
Just select first option Create and Configure Database using radio button and click Next button to proceed:
I assume you are installing Oracle just for learning purpose and you will install it on your PC or Laptop. So select Desktop Class option and click Next button to proceed:
Provide a location, where you will install Oracle Server. Just modify Oracle Base and rest of the locations will set automatically. Second, you will have to provide a password, which will be used by system DBA. Once you provide required information, click Next button to proceed:
Just click Next button to proceed:
Now, click Finish button to proceed, this will start actual server installation.
Just wait, until Oracle starts doing required configuration.
Here, Oracle installation will copy required configuration files, so kindly just wait and watch:
Once everything is done, you will have the following dialogue box. Just click OK button and come out.
Once your installation is done, you will have the following final window.
If everything has been done successfully, then it's time to verify your installation. At your command prompt, use the following command if you are using Windows:
sqlplus "/ as sysdba"
If everything is fine, you should have SQL prompt where you will write your PL/SQL commands and scripts:
Running large programs from command prompt may land you in inadvertently losing some of the work. So a better option is to use command files. To use the command files:
Type your code in a text editor, like Notepad, Notepad+, or EditPlus, etc.
Save the file with the .sql extension in the home directory.
Launch SQL*Plus command prompt from the directory where you created your PL/SQL file.
Type @file_name at the SQL*Plus command prompt to execute your program.
If you are not using a file to execute PL/SQL scripts, then simply copy your PL/SQL code and then right click on the black window having SQL prompt and use paste option to paste complete code at the command prompt. Finally, just press enter to execute the code, if it is not already executed.