Short Introduction to Oracle Database Rui Li (Natural Computing Group)
Short Introduction to Oracle Database
Rui Li (Natural Computing Group)
February 19, 2008
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
Oracle Database in Liacs
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
Version: Oracle 8 Enterprise Edition Platform: Unix/Linux Operating System Oracle account: It will be arranged based on your liacs account
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
SQL *Plus
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
SQL*Plus provides an interactive command line interface to Oracle. With it you can manipulate your data. It is equivalent to ”sql” in Ingres, ”isql” in Sybase and SQLServer, ”db2” in IBM DB2, ”psql” in PostgresQL, and ”mysql” in MySQL.
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
How to start Oracle
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
1
Add Oracle:
Open ∼ /.tcshrc Search for “wi packages”: set wi packages = (newtex netscape oracle)
2
Launch Oracle:
sqlplus username@ONW Your password is your username by default. To change your password: alter user username identified by newpassword;
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
Some Basic commands
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
1
Create table
CREATE TABLE BranchOffice (id CHAR(20), address CHAR(20) );
2
Insert tuples into a table
INSERT INTO BranchOffice VALUES ( 10, ’Niels Bohrweg 1’);
3
View the contents of a table
SELECT * FROM BranchOffice;
4
Some useful tips
Oracle command is not case sensitive, SELECT == select. Oracle command can be distributed over multiple lines,
select * from BranchOffice;
The query must end with a semicolon (;)
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
Some Basic commands (cont.)
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
1
Manage tables, get an overview of all the tables which you created.
SELECT * FROM tab; (“tab” is a special predefined table which stores all table names)
2
Remove tables
DROP TABLE BranchOffice;
3
Quit Oracle system
EXIT
4
Execute several commands by using a script file
store commands in a script file, createtable.sql for example, take care of .sql suffix, type @createtable in the command line to run this file,
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
Variable Types
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
varchar2(n), variable length string up to n with maximum 2000 characters. date, holds a date. By default they are specified as day-month-year as in “12-DEC-1990” number, integer or real value up to 40 decimal digitals number(n), up to n digits number(n, d), up to n digits with d after the decimal point.
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
Some Useful Links
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
SQL*Plus Documentation (Oracle)
http://www.oracle.com/technology/tech/sql plus/index.html
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
Some Useful Links
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
SQL*Plus Documentation (Oracle)
http://www.oracle.com/technology/tech/sql plus/index.html
A guide on how to get started with Oracle
http://pages.cs.wisc.edu/∼dbbook/openAccess/thirdEdition/Oracle/user guide/oracle guide.html
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database
Some Useful Links
Short Introduction to Oracle Database Rui Li (Natural Computing Group)
SQL*Plus Documentation (Oracle)
http://www.oracle.com/technology/tech/sql plus/index.html
A guide on how to get started with Oracle
http://pages.cs.wisc.edu/∼dbbook/openAccess/thirdEdition/Oracle/user guide/oracle guide.html
Quick reference cards (Unix/Linux, Sql and etc.)
http://www.digilife.be/quickreferences/quickrefs.htm
Rui Li(Natural Computing Group)
Short Introduction to Oracle Database