Home

Introduction to Oracle

 

Server Connection

 

Starting SQL Plus

To start Oracle, click Start -> (All) Programs -> Oracle OraDb11g -> Application Development -> SQL Plus. You will be asked to log:

Homepage

Enter the user name as system and press Enter. Enter the password you specified during the installation (while you are entering the password, its characters would not appear) and press Enter:

Home

As an alternative, to login, you could type the username, followed by /, followed by the password, and press Enter.

Connecting to a Server

To connect to the server, you can type CONNECT (or connect or Connect) and press Enter. A message would ask you to enter a username:

Command Line

After entering a user name, press Enter. You would then be asked to enter a password. After entering the password, press Enter. You would then receive a message telling you that you have been connected:

Command Line

 
 
 
 

You can also provide both the username and password at the same time when connecting. To do this, at the command prompt, type CONNECT, followed by a space, followed by the username, followed by a forward slash "/", followed by the password. After typing the information, press Enter.

After using the window, to close it, type exit and press Enter.

The Structured Query Language

 

Introduction

After logging in, you can take actions. You do this using a language named SQL.

The Structured Query Language, known as SQL, is a universal language used on various computer systems to create and manage databases.

Author Note SQL can be pronounced Sequel or S. Q. L. In our lessons, we will consider the Sequel pronunciation. For this reason, the abbreviation will always be considered as a word, which would result in “A SQL statement” instead of "An SQL statement". Also, we will regularly write, “The SQL” instead of “The SQL language, as the L already represents Language.

Like other non-platform specific languages such as C/C++, Pascal, or Java, the SQL you learn can be applied to various database systems. To adapt the SQL to Oracle, the company developed PL/SQL. PL/SQL is the language used internally by Oracle. Although it highly adheres to the SQL standards, it has some internal details that may not be applied to other database systems.

The SQL Interpreter

As a computer language, PL/SQL is used to give instructions to an internal program called an interpreter. As we will learn in various sections, you must make sure you give precise instructions.

SQL is not case-sensitive. This means that CREATE, create, and Create mean the same thing. It is a tradition to write SQL's own words in uppercase. This helps to distinguish SQL instructions with the words you use for your database.

As we will learn in this and the other remaining lessons, you use PL/SQL by writing statements. To help you with this, we saw that you can use a DOS window or the Home page.

Creating Comments in SQL Code Writing

A comment is text that the SQL interpreter would not consider as code. As such, a comment is written any way you like. What ever it is made of would not be read. PL/SQL supports two types of comments. The style of comment that starts with /* and ends with */ can be used. To apply it, start a line with /*, include any kind of text you like, on as many lines as you want. To close the commented section, type */. Here is an example of a line of comment:

/* First find out if the database we want to create exists already */

A comment can also be spread on more than one line, like a paragraph. Here is an example:

/* First find out if the MotorVehicleDivision database we 
   want to create exists already.
   If that database exists, we don't want it anymore. So,
   delete it from the system. */

PL/SQL also supports the double-dash comment. This comment applies to only one line of text. To use it, start the line with --. Anything on the right side of -- is part of a comment and would not be considered as code. Here is an example:

-- =============================================
-- Database: MotorVehicleDivision
-- =============================================

/* First find out if the MotorVehicleDivision database we 
   want to create exists already.
   If that database exists, we don't want it anymore. So,
   delete it from the system. */


-- Now that the database is not in the system, create it

The End of a Statement

In SQL, after writing a statement, you can end it with a semi-colon. In fact, if you plan to use many statements in one block, you should end each with a semi-colon. When many statements are used, some of them must come after others.

 
 
   
 

Previous Copyright © 2009-2010 FunctionX, Inc. Next