You are on page 1of 10

Oracle SQL*PLUS

DataBase

SQL
Structur query language

DDLData definition language

create table , alter table , drop table


DMLData manipulation language
insert , update , delete , merge
transaction , DML commit; ,rollback;
select
dcl grant
Oracle
DBMS
Oracle AS
DBA

1sqlplus /

sqlplus /
2show user
connect / --- sqlplus
sqlplus ! shell sqlplus !shell sqlplus
shell
sqlplus shell
3Oracle

DDL DML

1select
select table_name from user_tables;

1select table_name from user_tables;

2sqlplus buffer sql "/" sql

edit sql
l listsqlplus buffer
sqlplus
3desc []
sqlplus sql descript

[] [] desc
4select [ 1],[ 2], ... from ;
select * from ;
5sql
sql ";" sql ";" sql

Oracle

6 select
select [],[...],.... from

7
select [] [""][...] ["..."],.... from
""

8||
select ||" "|| from
Oracle '..'
".."

SQL select * from ...;


...
select * from ;
select 'select * from '||table_name||';' from user_tables;
2
1!oerr ora []
edit ed
sql
(change) c //
Linux
! host shell
2edit sql
3sqlplus
set pause on
set pause off
set pause "..."

set pause on
set head off
set feed off
set echo off
spool .sql
spool off
4sql
sql sqlplus
sql
sqlplus / @sql
@sql
exit shell
5
Oracle
Oracle NVL()

select (salary*12)*(NVL(commission_pct,0)/100+1) salary,first_name from


s_emp;
distinct
select distinct dept_id,title from s_emp;
dept_id title
distinct from
6column --- sqlplus
column
column
column format a..
column last_name heading 'Employee|Name' formAT A15


'|'
column salary justify left format $99,990.00

"#"
column salary justify left format $00,000.00
$00,928.00 , 0
column clear
sqlplus sqlplus

1order by
ASC DESC
order by
select first_name from s_emp order by first_name;
select first_name from s_emp order by first_name desc;

2where
where select ... from ...
where XXX=XXX XXX between X and X
inXXX
like '...'
between ... and ... ,between and

XXX

... <= ... and ... >= ...


!=<>^=& lt;=>==
... in (va1,val2,...)
like '...' '%''_'
like S\_% escape \
... and ...
... or ...
all ...
not .....
not in
... is null
Oracle
1'......' Date '......'

" "
2

1.

lower()

---

upper()
initcap()
concat( 1, 2)
substr(, )
dual
concat(...,....)
substr(...,)
"-"
select substr(first_name,-2,2) sub from s_emp;
select substr(first_name,2,2) sub from s_emp;

2.
round(,)
0-1

select round(15.36,1) from dual;


trunc() 0
select trunc(123.456,1) from dual;
3.


-- dd-mon-rr

alter session set nls_date_format='yyyy mm dd hh24:mi:ss';


sysdate
select sysdate from dual;
select sysdate+1 from dual; 1

months_between(date1,date2)
add_months(date,)

date next_day(date,FriDay)
last_day(date)
trunc(date,'')
select next_day(sysdate,2) from dual;
select trunc(add_months(sysdate,1),'month') from dual;
ROUND('25-MAY-95','MONTH')01-JUN-95
ROUND('25-MAY-95 ','YEAR')01-JAN-95
TRUNC('25-MAY-95 ','MONTH')01-MAY-95
TRUNC('25-MAY-95 ','YEAR')01-JAN-95

select round(last_day(sysdate),'MONTH') from dual;


select add_months(trunc(sysdate,'MONTH'),1);
4.
tochar(date,'')
'yyyy mm dd hh24:mi:ss',
'year'( ),'mm'( ) 'month'( ) 'day'( )
'ddspth' () 'yy mm dd'
select to_char(sysdate,'yyyy mm dd hh24:mi:ss')from dual;
to_number('...')
to_char(number'fmt') fmt
to_date('...','')
select to_char(to_date('2006 11 03','yyyy mm dd'),'dd-month-yy') from
dual
Oracle 10g /

Username

Password

Description

See Also

CTXSYS

CTXSYS

The Oracle Text account Oracle Text


Reference

DBSNMP

DBSNMP

The account used by the Oracle Enterprise


Management Agent
Manager Grid
component of Oracle
Control Installation
Enterprise Manager to and Basic
monitor and manage the Configuration
database

LBACSYS

LBACSYS

The Oracle Label


Security administrator
account

MDDATA

MDDATA

The schema used by


Oracle Spatial
Oracle Spatial for storingUser's Guide and
Geocoder and router
Reference
data

MDSYS

MDSYS

The Oracle Spatial and Oracle Spatial


Oracle interMedia
User's Guide and
Locator administrator
Reference

Oracle Label
Security
Administrator's
Guide

Username

Password

Description

See Also

account
DMSYS

DMSYS

The Oracle Data Mining Oracle Data


account.
Mining
Administrator's
Guide
Oracle Data
Mining Concepts

OLAPSYS

MANAGER

The account used to


Oracle OLAP
create OLAP metadata Application
structures. It owns the Developer's Guide
OLAP Catalog
(CWMLite).

ORDPLUGINS

ORDPLUGINS

The Oracle interMedia Oracle interMedia


user. Plug-ins supplied User's Guide
by Oracle and third party
format plug-ins are
installed in this schema.

ORDSYS

ORDSYS

The Oracle interMedia


administrator account

OUTLN

OUTLN

The account that


Oracle Database
supports plan stability. Performance
Plan stability enables
Tuning Guide
you to maintain the
same execution plans
for the same SQL
statements. OUTLN acts
as a role to centrally
manage metadata
associated with stored
outlines.

Oracle interMedia
User's Guide

SI_INFORMTN_SCHEMA SI_INFORMTN_SCHEMA The account that stores Oracle interMedia


the information views for User's Guide
the SQL/MM Still Image
Standard
SYS

CHANGE_ON_INSTALL The account used to


perform database
administration tasks

Oracle Database
Administrator's
Guide

SYSMAN

CHANGE_ON_INSTALL The account used to


perform Oracle
Enterprise Manager
database administration
tasks. Note that SYS
and SYSTEM can also
perform these tasks.

Oracle Enterprise
Manager Grid
Control Installation
and Basic
Configuration

SYSTEM

MANAGER

Another account used to Oracle Database

Username

Password

Description

See Also

perform database
administration tasks.

Administrator's
Guide

You might also like