DBAS 20146
Software Installation
Basic SQL
Current password
• sqlplus s9_yourlogin/yourstudentid@aces
Typical hardware environment
Typical hardware environment
Option 1:
A user would be working from a laptop.
All work would be done through Linux (a text-based environment).
Linux must be accessed through a terminal so a terminal emulation software (like SSH or
PuTTY) must be installed on a Windows laptop, but Mac or Linux laptops could use a
standard terminal window
Typical software:
- Terminal emulation (SSH, PuTTY) to connect to the Linux server
- SQL plus (typically running on the Linux server)
- Oracle database
- Edit Plus or Notepad++
Option 2:
User could use Oracle SQL Developer and connect directly to the database server.
SSH/PuTTY setup
When working from the Linux server atlas, all work will be done through Linux (a text-based
environment), so you will have a chance to refresh some of your Linux skills. Linux must be accessed
through a terminal so you must turn your laptop into a terminal by running terminal emulation
software. Secure Shell (SSH) will be used to do this. It should already be installed on your laptop. If
not, go to Access Sheridan and install it now. Alternatively, you may use PuTTY (google PuTTY
download). Any MAC or Linux laptops, just use a standard terminal window.
Follow these steps to set up SSH to access your account on atlas. This is the same SHERIDAN account
which you have always used.
Start up SSH
Click on the Edit menu and choose Settings. On the left, select Connection and set Terninal
Answerback to VT220. Select Keyboard and click on Backspace Sends Delete. Click on OK.
Click Quick Connect.
Set Host Name to: atlas.sheridanc.on.ca (Be sure there are three periods and no @ signs)
Set User Name to: your user login name
Set Port Number to: 22
Set Authentication Method to: Password
Click Connect. The very first time you connect, you will will prompted for a Yes/No response. Always
say Yes. Later, when you exit SSH, you should be prompted to save your settings. Say yes.
You will be prompted to enter your password. Log into atlas using your usual login name and
password. The linux prompt should come up.
Type the following command: mkdir sql
Minimize the window for now. It will stay connected.
If you wish to do your assignments from your home computer and have an internet connection, you
may connect to atlas remotely.
Linux Command Help
All Linux commands are case sensitive.
COMMAND DESCRIPTION
PERMISSIONS
LOGGING IN chmod o+r <filename> Give read permission to others
Login chmod go+r <filename> Give read permission to group and others
passwd Change password chmod o+rwx <filename> Etc.
whoami chmod o-x <filename>
MOVING IN LINUX
cd .. Go up a directory EDITOR
cd Change directory to your HOME directory pico <filename>
cd $HOME As above vi
cd / Change directory to the root : Enter editor command
ESC Change to view mode
cd <directory> Change directory to a specified location (e.g., cd /usr/bin :w <filename> Write to a file
:wq Write to current file and quit
pwd Path of Working Directory – where you currently are. :q! Quit without saving changes
a Enter append mode
LOGGING OUT I Enter insert mode
logout Logout of the session U Undo
CTRL+D As above O Open following line for inserting
Y Yank a line (copy)
exit As above W Move one word to the right
HELP c or r Change current character
help dw Delete word
man Online manual dd Delete line
man –k Online manual (all libraries)
man man How to use man COMMUNICATION
man printf Manual for printf command who Who is currently logged on
DIRECTORY LISTINGS who | more
who | more | sort
Ls
talk <user>
ls –l Long listing including:
write <user>
Mode
same as Links
MISC.
Owner
cat <filename> Displays the contents of filename
l Group
more file1
Size
more file1 file2
Last modified
mv file1 file2 Renames file1 as file2.
Filename
NOTE: file2 data is overwritten.
file1 will not exist afterwards
Mode:
cp file3 file4 Copies file3 to file4
Trwxrwxrwx
NOTE: file4 data is overwritten
rm file3 Removes file3 (delete)
where t is of type:
rmdir
d – directory
mkdir
-- ordinary file
rm –r <directory> Removes recursively directory and all subdirectories. Dangerous. Make
other types are b, c, p, or l
sure you know what you are deleting.
next 9 chars are in groups of three representing: wc <filename> Word count for filename
user(u), group(g), others (o) ps Current status of your processes. Good idea to issue this to keep track
of what you are running.
env Current environment settings.
groups What group(s) do you belong to?
chsh Change your default shell
ORACLE Command Help
• Pause for SQL Output
Display SQL output one screen at a time:
SQL>SET PAU[se] ‘more…’
SQL>SET PAU[se] ON
SQL will pause with the prompt “more…” at the end of each screen of output.
The very first screen will be preceded by the prompt.
• Capturing an SQL session
Capture your SQL session in a text file by:
SQL>SPOOL <filename>
A copy of the session will be stored in <filename>.lst in your current directory.
Turn the capture off and close the spool file with:
SQL>SPOOL OFF
• What privileges do you have?
See the privileges associated with your account:
SELECT * FROM Session_Privs;
ORACLE Command Help
• Environment Settings: Some SET Options
Change the SQL prompt with:
SET SQLPROMPT ‘<new prompt>’
e.g., SET SQLPROMPT ‘What do you want?’
Set the number of lines per screen display:
SET PAGESIZE <number of lines> 255 = infinity
Set page width by limiting the number of characters per line:
SET LINESIZE <number of characters per line> 255 = infinity
• LOGIN.SQL
When SQLPLUS starts it looks for a file called login.sql in your current directory and executes any commands it finds there. You can customize your own environment through this file. For
example, you could use pico, vi, (or any other editor), to create a login.sql file in your home directory containing the following:
prompt Executing LOGIN.SQL
set sqlprompt ‘Talk to me>’
set pause ‘more…’
set pagesize 22
set linesize 80
• Table Descriptions
Get a quick description of any table with the DESCRIBE command:
DESCRIBE <tablename> or DESC <tablename>
• See What Tables You Own:
SELECT * FROM USER_TABLES;
• DUAL – A Dummy Table
ORACLE provides a dummy table, DUAL, that you can use for on-the-fly computations. Look at its description with the DESCRIBE command.
What is today’s date?
SELECT sysdate FROM Dual;
What is 5 times 6?
SELECT 5*6 FROM Dual;
Editing Commands in SQL*Plus
COMMAND ABBREVIATION PURPOSE
RUN R Executes the current statement in the SQL buffer
/ Same as above
APPEND text A text Adds text to the end of the current line
CHANGE C/old/new Changes old text to new text
CHANGE C/text/ Deletes text from the current line
CLEAR BUFFER CL BUFF Deletes all lines from the SQL buffer
DEL Deletes the current line
INPUT I Adds an indefinite number of lines after the current line
LIST L Lists all the lines currently in the buffer
; Same as above
LIST n Ln Lists line number n
LIST n m Lnm Lists lines n through m
EXIT Exits the SQL*Plus session
QUIT As above
SAVE <filename> Saves the buffer to filename
GET <filename> Loads the filename into the SQL buffer
START <filename> @ Executes the commands in the filename
ED <filename> Uses the system’s default editor (defined in .login in UNIX) to edit
filename
DESCRIBE DESC Displays the database object structures, such as tables
! Shell out of sql*plus environment. Remember to type ‘exit’ to come
back to your sql*plus session.
Starting SqlPlus
Now you should be ready to access oracle. Oracle and the database are running on the
server boba. You will access it by running the program: SqlPlus on the server Atlas. There
are three ways to get started. You may use any one of the three.
1.It is very important to be sure that sql is the current directory before starting. Type the
following commands:
◦cd $HOME/sql
◦sqlplus
◦When prompted, enter your oracle user name. When prompted enter the password
currentpassword@aces. The @aces must follow the password with no spaces between.
2.It is very important to be sure that sql is the current directory before starting. Type the
following commands:
◦cd $HOME/sql
◦sqlplus your_oracle_name/ currentpassword @aces This line starts the program, gives
the account name and password and tells it to connect to the aces database on a server
other than the current one (atlas).
3.This uses the alias set up in your .login. It accomplishes everything in one simple step.
However, be sure you know methods 1. and 2. as well. Type the following command:
◦sql
You should now see the prompt:
SQL>
If not, go back and be sure everything is set up properly.
The SQLPlus Environment
SqlPlus has a command driven interface.
SQL statements can be entered and executed directly or they can be put into a script (a
file) and then execute the script.
All SQL statements are free form. That is, a single statement can be spread over many
lines.
Every SQL statement must be terminated with a semicolon (;).
If the prompt changes to a number, it means that SqlPlus is waiting for the part of the
command.
A common error is to forget the semicolon. If you have finished the command and a
number pops up, simply type the semicolon and press ENTER.
SqlPlus itself has many commands. These are one line commands and do not need a
semicolon at the end. However, a semicolon does not generate an error. It is simply
ignored.
The most common commands are contained in the file SqlPlus.pdf. Print it out and have it
available when you are doing your work.
Installing Oracle SQL Developer
BEFORE you follow the instructions on this page, make SURE THAT YOU DO
NOT HAVE SQL Developer INSTALLED!
WINDOWS USERS, download the correct SQL developer zip file for Windows
from SLATE.
• Extract (unzip) the file to a folder of your choice.
• Go to the folder you just created and find the file sqldeveloper.exe, and
either pin it to the taskbar or create a desktop link that you can use for the
remainder of the course.
• Use the newly created link (or taskbar icon) to start SQL developer.
• A window may appear to Confirm Import Preferences - you may choose to
import preferences if you had SQL developer previously installed,
otherwise select NO.
• Another window may appear about automatic tracking information being
sent to Oracle - clear the checkmark and continue.
• Close SQL developer.
Installing Oracle SQL Developer
• Start SQL developer so that you can access the SQL server database.
– Click on the green plus sign to Add a Connection.
– Select the Oracle tab.
– Fill in your assigned username and password from the list posted on
SLATE.
– Under no circumstances use the username in the image below. Don't
use S5 - use S9
– Change the connection name to match your username - e.g. DBAS-
S9_yourstudentlogin
– Fill in the other details to match the image below.
– Click the Test button - you should receive a Status: Success - if not,
check your settings and try again.
– When you have Status: Success - Save the connection and Cancel the
window.
Installing Oracle SQL Developer
• Finally, access Oracle server and make sure
that you can access the S9 database as
follows:
– Expand your SQLserver connection in the left
pane.
– In the Query Builder frame, key in the command:
SELECT * FROM s9.car;
and click the green right arrow to execute it. You
will receive output that should match the
following image.
Optional settings
Tailoring SQL developer - Tools > Preferences > Database (set NLS for date/time formats)
(set Navigation Filters to simplify your left pane)
You are now ready to use SQL developer for the remaining modules.