SlideShare une entreprise Scribd logo
1  sur  5
Anar Godjaev
http://anargodjaev.wordpress.com/

Oracle SQL
Select lastname || „ is a ‟ job_id as “employee details” from employees;
Select lastname from employees where lastname like „_0%‟
Select employee_id , lastname, job_id from employees
where job_id like „%SAL%‟ESCAPE‟_‟;

Character functions:
Case manupilation
Lower
Upper
Initcap
Character manipulation
Concat (a,b)
Substr (a,m,n)
//same as mid function
Length (a)
İnstr (a,b,m,n)
//instr(„Hello World‟ , „w‟)
Lpad (salary, 10, *)
//(*****24000)
Rpad
Trim
Replace (text, search, replace)

Number functions:
Round
Trunc
Mod

//rounds value to the specified decimal
Round (45.926, 2) -> 45.93
//truncates to the specified decimal
Trunc (45.926,2) -> 45.92
//return the remainder of the division

Dates:
Date + number = date
Date – number =date
Date – date = number of days
Select sysdate from dual; -- Default format DD-MON-RR
Anar Godjaev
http://anargodjaev.wordpress.com/

Months_between (date1, date2)
Add_months (date,n)
Next_day (date, „friday‟)
Last_day (date)
Round (date)
Trunc (date)

-- find the next specified day of the week
-- the date of the last day of the month

EX:
Round
Round
Trunc
Trunc

(sysdate,
(sysdate,
(sysdate,
(sysdate,

„MONTH‟)
„YEAR‟)
„MONTH‟)
„YEAR‟)

Select employee_id , concat(fisrt_name, last_name) name, length (lastname) ,
instr(lastname, „a‟) “contains „a‟ ?” from employees where substr(lastname,-1,1) = „n‟;

to_char (number | date, [fmt])
to_number (char, [fmt])
to_date (char, [fmt])
alter session set nls_date_format = „DD-MM-YYY HH24:MI:SS‟
alter session set time_zone = „-8:00‟
select sessiontimezone, dbtimezone, current_timestamp, current_date, sysdate from dual;
select extract (month from hire_date) from employees;
select to_timestamp(„2000-12-01 11:00:00‟ , „YYYY-MM-DD HH:MI:SS‟)

Select employee_id , to_char (hire_date, „MM/YY‟) from employees
where last_name = „higgins‟;
// (YYYY,YEAR, MM, MONTH, MON, DAY, DD, DY, J)
(HH24, MI, SS)

select to_char (hire_Date, „fmDD Month YYYY„);
select to_char (hire_date, „fmDdspth “of” month YYYY fmHH:MI:SS AM‟)
select last_name, hire_date from employees
where hire_Date = TO_DATE(„May 24, 1999‟, „fxMonth DD, YYYY‟)
Anar Godjaev
http://anargodjaev.wordpress.com/

select to_char (salary, „$99,999.00‟)
9 – represents a number
0 – forces a zero to be displayed
$ - forces a floating ddler sign
. – prints a decimal point
, - prints a thousand indicator
nvl (expr1, expr2)
nvl2 (expr1, expr2, expr3)
nullif (expr1, expr2)
coalesce (expr1, expr2, ... , exprn)
case expr

when comparison1 then expr1
when comparison2 then expr2

else expr3
end; alias

decode (col | expr,

search1, result1,
serach2, result2,
default) alias;

decode (job_id ,

„IT_PROG‟ , 1.10*SAL
„SL_CLECK‟, 1.15*SAL
SAL) “REVISED_SAL”;

Joins:
Select table1.column, table2.column from table1 , table2
where table1.column(+)=table2.column;
select table1.column, table2.column from table1
[CROSS join table2]
[NATURAL join table2]
[JOIN table2 USING column_name]
[JOIN table2 ON tbl1.column=tbl2.column]
[LEFT | RIGHT | FULL OUTER join table2 ON tbl1.column ) tbl2.column]

SQLPLUS
define employee_id = 200;
set verify on
set echo on
Anar Godjaev
http://anargodjaev.wordpress.com/

show echo
set heading off | on
show heading
show _variable_name
set arraysize 20
set feedback on | off
set ttitle on | off | text
set btitle on | off | text
set break on | off | text | column
column lastname justify left format $99,990.00
column lastname clear
col colname format a30
break on job_id
noprint
break [on report element]
clear
script file
print
null text
column colname option
Ex:
set feedback off
ttitle „employee | report‟ --top title [text | on | off]
btitle „confidential‟ --bottom title
break on job_id
column job_id heading „job / category‟
column lat_name heading „employee‟
column salary heading „salary‟ format $99,999.99
REM ** insert select statement
Select job_id , last_name salary from employees where salary < 15000
Order by job_id, last_name;
/
REM ** clear all formatting commands
Set feedback on
Column job_id clear
Column last_name clear
Column salary clear
Clear break

Merge into:
Merge into table_name table_alias
Using (table) alias
On (join condition)
Anar Godjaev
http://anargodjaev.wordpress.com/

When matched then update set col1 = val1 , col2 = val2
When not matched then insert (col_list) values (val_list)
EX:
Merge into copy_emp c using employee e
on (c.employee_id = e.employee_id)
When matched then
update set c.firstname = e.firstname
...
when not matched then
insert values (e.emplyee_id ...)

Commit , rollback , savepoint:
Update ..
Savepoint update_done
İnsert
Rollback to update_done
Create table dept80 as select * from employees where department_id = 80;
Alter table table_name add (column_name datatype)
Alter table set unused column col_name
Alter table table_name modify (col_name datatype)
Alter table table_name drop (col_name)
Rename dept to dept_detail;
Truncate table detail_dept;
Select row_num as rank;

Contenu connexe

Tendances

Coq setoid 20110129
Coq setoid 20110129Coq setoid 20110129
Coq setoid 20110129
tmiya
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
hayato
 

Tendances (20)

ProgrammingwithGOLang
ProgrammingwithGOLangProgrammingwithGOLang
ProgrammingwithGOLang
 
C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
 
Array
ArrayArray
Array
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
Program to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderProgram to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical order
 
My favorite slides
My favorite slidesMy favorite slides
My favorite slides
 
Coq setoid 20110129
Coq setoid 20110129Coq setoid 20110129
Coq setoid 20110129
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
Presentation for structure in c
Presentation for  structure in cPresentation for  structure in c
Presentation for structure in c
 
STL
STLSTL
STL
 
10 2 배열 응용
10 2 배열 응용10 2 배열 응용
10 2 배열 응용
 
resume_Alexey_Zaytsev
resume_Alexey_Zaytsevresume_Alexey_Zaytsev
resume_Alexey_Zaytsev
 
pycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslatepycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslate
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
 
Structures
StructuresStructures
Structures
 
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189
 
Document
DocumentDocument
Document
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
Functional programming in Swift
Functional programming in SwiftFunctional programming in Swift
Functional programming in Swift
 
2 d rotation
2 d rotation2 d rotation
2 d rotation
 

Similaire à Oracle SQL

Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handouts
jhe04
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10
Syed Asrarali
 

Similaire à Oracle SQL (20)

Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handouts
 
Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2
 
Les03
Les03Les03
Les03
 
Solucionario de Ejercicios de PL/SQL.pdf
Solucionario de Ejercicios de PL/SQL.pdfSolucionario de Ejercicios de PL/SQL.pdf
Solucionario de Ejercicios de PL/SQL.pdf
 
Single row functions
Single row functionsSingle row functions
Single row functions
 
Functions
FunctionsFunctions
Functions
 
Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)
 
Les03
Les03Les03
Les03
 
Les03
Les03Les03
Les03
 
sql ppt for students who preparing for sql
sql ppt for students who preparing for sqlsql ppt for students who preparing for sql
sql ppt for students who preparing for sql
 
SQL
SQLSQL
SQL
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Les03 Single Row Function
 
SQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question BankSQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question Bank
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10
 
Arrays
ArraysArrays
Arrays
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
inputoutput.pptx
inputoutput.pptxinputoutput.pptx
inputoutput.pptx
 
12. Basic SQL Queries (2).pptx
12. Basic SQL Queries  (2).pptx12. Basic SQL Queries  (2).pptx
12. Basic SQL Queries (2).pptx
 
Sql task answers
Sql task answersSql task answers
Sql task answers
 

Plus de Anar Godjaev

Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from
Anar Godjaev
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
Anar Godjaev
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin Güvenliği
Anar Godjaev
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden Gate
Anar Godjaev
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server Kurulum
Anar Godjaev
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon Export
Anar Godjaev
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇
Anar Godjaev
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇
Anar Godjaev
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını Inceleme
Anar Godjaev
 
Conditional Control
Conditional ControlConditional Control
Conditional Control
Anar Godjaev
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasi
Anar Godjaev
 
Backup and Recovery
Backup and RecoveryBackup and Recovery
Backup and Recovery
Anar Godjaev
 

Plus de Anar Godjaev (20)

Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
 
Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from
 
How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin Güvenliği
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden Gate
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server Kurulum
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon Export
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇
 
Contraints
ContraintsContraints
Contraints
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını Inceleme
 
Conditional Control
Conditional ControlConditional Control
Conditional Control
 
PL/SQL Blocks
PL/SQL BlocksPL/SQL Blocks
PL/SQL Blocks
 
Wait Interface
Wait InterfaceWait Interface
Wait Interface
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasi
 
Tuning SGA
Tuning SGATuning SGA
Tuning SGA
 
Parallel Server
Parallel ServerParallel Server
Parallel Server
 
Table Partitions
Table PartitionsTable Partitions
Table Partitions
 
Backup and Recovery
Backup and RecoveryBackup and Recovery
Backup and Recovery
 

Dernier

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Oracle SQL

  • 1. Anar Godjaev http://anargodjaev.wordpress.com/ Oracle SQL Select lastname || „ is a ‟ job_id as “employee details” from employees; Select lastname from employees where lastname like „_0%‟ Select employee_id , lastname, job_id from employees where job_id like „%SAL%‟ESCAPE‟_‟; Character functions: Case manupilation Lower Upper Initcap Character manipulation Concat (a,b) Substr (a,m,n) //same as mid function Length (a) İnstr (a,b,m,n) //instr(„Hello World‟ , „w‟) Lpad (salary, 10, *) //(*****24000) Rpad Trim Replace (text, search, replace) Number functions: Round Trunc Mod //rounds value to the specified decimal Round (45.926, 2) -> 45.93 //truncates to the specified decimal Trunc (45.926,2) -> 45.92 //return the remainder of the division Dates: Date + number = date Date – number =date Date – date = number of days Select sysdate from dual; -- Default format DD-MON-RR
  • 2. Anar Godjaev http://anargodjaev.wordpress.com/ Months_between (date1, date2) Add_months (date,n) Next_day (date, „friday‟) Last_day (date) Round (date) Trunc (date) -- find the next specified day of the week -- the date of the last day of the month EX: Round Round Trunc Trunc (sysdate, (sysdate, (sysdate, (sysdate, „MONTH‟) „YEAR‟) „MONTH‟) „YEAR‟) Select employee_id , concat(fisrt_name, last_name) name, length (lastname) , instr(lastname, „a‟) “contains „a‟ ?” from employees where substr(lastname,-1,1) = „n‟; to_char (number | date, [fmt]) to_number (char, [fmt]) to_date (char, [fmt]) alter session set nls_date_format = „DD-MM-YYY HH24:MI:SS‟ alter session set time_zone = „-8:00‟ select sessiontimezone, dbtimezone, current_timestamp, current_date, sysdate from dual; select extract (month from hire_date) from employees; select to_timestamp(„2000-12-01 11:00:00‟ , „YYYY-MM-DD HH:MI:SS‟) Select employee_id , to_char (hire_date, „MM/YY‟) from employees where last_name = „higgins‟; // (YYYY,YEAR, MM, MONTH, MON, DAY, DD, DY, J) (HH24, MI, SS) select to_char (hire_Date, „fmDD Month YYYY„); select to_char (hire_date, „fmDdspth “of” month YYYY fmHH:MI:SS AM‟) select last_name, hire_date from employees where hire_Date = TO_DATE(„May 24, 1999‟, „fxMonth DD, YYYY‟)
  • 3. Anar Godjaev http://anargodjaev.wordpress.com/ select to_char (salary, „$99,999.00‟) 9 – represents a number 0 – forces a zero to be displayed $ - forces a floating ddler sign . – prints a decimal point , - prints a thousand indicator nvl (expr1, expr2) nvl2 (expr1, expr2, expr3) nullif (expr1, expr2) coalesce (expr1, expr2, ... , exprn) case expr when comparison1 then expr1 when comparison2 then expr2 else expr3 end; alias decode (col | expr, search1, result1, serach2, result2, default) alias; decode (job_id , „IT_PROG‟ , 1.10*SAL „SL_CLECK‟, 1.15*SAL SAL) “REVISED_SAL”; Joins: Select table1.column, table2.column from table1 , table2 where table1.column(+)=table2.column; select table1.column, table2.column from table1 [CROSS join table2] [NATURAL join table2] [JOIN table2 USING column_name] [JOIN table2 ON tbl1.column=tbl2.column] [LEFT | RIGHT | FULL OUTER join table2 ON tbl1.column ) tbl2.column] SQLPLUS define employee_id = 200; set verify on set echo on
  • 4. Anar Godjaev http://anargodjaev.wordpress.com/ show echo set heading off | on show heading show _variable_name set arraysize 20 set feedback on | off set ttitle on | off | text set btitle on | off | text set break on | off | text | column column lastname justify left format $99,990.00 column lastname clear col colname format a30 break on job_id noprint break [on report element] clear script file print null text column colname option Ex: set feedback off ttitle „employee | report‟ --top title [text | on | off] btitle „confidential‟ --bottom title break on job_id column job_id heading „job / category‟ column lat_name heading „employee‟ column salary heading „salary‟ format $99,999.99 REM ** insert select statement Select job_id , last_name salary from employees where salary < 15000 Order by job_id, last_name; / REM ** clear all formatting commands Set feedback on Column job_id clear Column last_name clear Column salary clear Clear break Merge into: Merge into table_name table_alias Using (table) alias On (join condition)
  • 5. Anar Godjaev http://anargodjaev.wordpress.com/ When matched then update set col1 = val1 , col2 = val2 When not matched then insert (col_list) values (val_list) EX: Merge into copy_emp c using employee e on (c.employee_id = e.employee_id) When matched then update set c.firstname = e.firstname ... when not matched then insert values (e.emplyee_id ...) Commit , rollback , savepoint: Update .. Savepoint update_done İnsert Rollback to update_done Create table dept80 as select * from employees where department_id = 80; Alter table table_name add (column_name datatype) Alter table set unused column col_name Alter table table_name modify (col_name datatype) Alter table table_name drop (col_name) Rename dept to dept_detail; Truncate table detail_dept; Select row_num as rank;