SlideShare a Scribd company logo
www.srinimf.com
 to start type
db2start
 To stop
db2stop
 db2 => connect to sample
 db2 => bind sample.bnd
Help command:
Db2 => ?
Db2 => ? CATALOG DATABASE - It gives more
info on particular command
Quit Commnad:
Db2 => quit
db2 => db2start This takes some time (maybe 30 seconds)
DB20000I The DB2START command completed successfully.
db2 => ?
ACTIVATE DATABASE GET CONTACTGROUPS RECONCILE
ADD CONTACT GET CONTACTS RECOVER
ADD CONTACTGROUP GET/UPDATE DB CFG REDISTRIBUTE DB PARTITION
ADD DATALINKS MANAGER GET/UPDATE DBM CFG REFRESH LDAP
ADD DBPARTITIONNUM GET DBM MONITOR SWITCHES REGISTER LDAP
ADD XMLSCHEMA GET DESCRIPTION FOR HEALTH REGISTER XMLSCHEMA
ARCHIVE LOG GET NOTIFICATION LIST REGISTER XSROBJECT
ATTACH GET HEALTH SNAPSHOT REORG INDEXES/TABLE
AUTOCONFIGURE GET INSTANCE REORGCHK
BACKUP DATABASE GET MONITOR SWITCHES RESET ADMIN CFG
BIND GET RECOMMENDATIONS RESET ALERT CFG
CATALOG APPC NODE GET ROUTINE RESET DB CFG
CATALOG APPN NODE GET SNAPSHOT RESET DBM CFG
CATALOG DATABASE HELP RESET MONITOR
CATALOG DCS DATABASE HISTORY RESTART DATABASE
CATALOG LDAP DATABASE IMPORT RESTORE DATABASE
CATALOG LDAP NODE INITIALIZE TAPE REWIND TAPE
CATALOG LOCAL NODE INSPECT ROLLFORWARD DATABASE
CATALOG NPIPE NODE LIST ACTIVE DATABASES RUNCMD
CATALOG NETBIOS NODE LIST APPLICATIONS RUNSTATS
CATALOG ODBC DATA SOURCE LIST COMMAND OPTIONS SET CLIENT
CATALOG TCPIP NODE LIST DATABASE DIRECTORY SET RUNTIME DEGREE
CHANGE DATABASE COMMENT LIST DB PARTITION GROUPS SET TABLESPACE CONTAINERS
CHANGE ISOLATION LEVEL LIST DATALINKS MANAGERS SET TAPE POSITION
COMPLETE XMLSCHEMA LIST DBPARTITIONNUMS SET UTIL_IMPACT_PRIORITY
CREATE DATABASE LIST DCS APPLICATIONS SET WRITE
 CREATE TOOLS CATALOG LIST DCS DIRECTORY START DATABASE MANAGER
 DEACTIVATE DATABASE LIST DRDA INDOUBT START HADR
 DECOMPOSE XML DOCUMENT LIST HISTORY STOP DATABASE MANAGER
 DECOMPOSE XML DOCUMENTS LIST INDOUBT TRANSACTIONS STOP HADR
 DEREGISTER LIST NODE DIRECTORY TAKEOVER HADR
 DESCRIBE LIST ODBC DATA SOURCES TERMINATE
 DETACH LIST PACKAGES/TABLES UNCATALOG DATABASE
 DROP CONTACT LIST TABLESPACE CONTAINERS UNCATALOG DCS DATABASE
 DROP CONTACTGROUP LIST TABLESPACES UNCATALOG LDAP DATABASE
 DROP DATABASE LIST UTILITIES UNCATALOG LDAP NODE
 DROP DATALINKS MANAGER LOAD UNCATALOG NODE
 DROP DBPARTITIONNUM LOAD QUERY UNCATALOG ODBC DATA
 DROP TOOLS CATALOG MIGRATE DATABASE UNQUIESCE DATABASE
 ECHO PING UNQUIESCE INSTANCE
 EDIT PREP/PRECOMPILE UPDATE ALERT CFG
 EXPORT PRUNE HISTORY/LOGFILE UPDATE COMMAND OPTIONS
 FORCE APPLICATION PUT ROUTINE UPDATE CONTACT
 GET/UPDATE ADMIN CFG QUERY CLIENT UPDATE CONTACTGROUP
 GET ALERT CFG QUIESCE DATABASE UPDATE NOTIFICATION LIST
 GET AUTHORIZATIONS QUIESCE INSTANCE UPDATE HISTORY
 GET/UPDATE CLI CFG QUIESCE TABLESPACES UPDATE LDAP NODE
 GET CONNECTION STATE QUIT UPDATE MONITOR SWITCHES
 GET CONTACTGROUP REBIND XQUERY
 Note: Some commands are operating system specific and may not be available.
 For further help:
 ? db2-command - help for specified command
 ? OPTIONS - help for all command options
 ? HELP - help for reading help screens
 The preceding three options can be run as db2 <option> from an OS prompt.
 !db2ic - DB2 Information Center (Windows only)
 This command can also be run as db2ic from an OS prompt.
 db2 => create database slo
 DB20000I The CREATE DATABASE command
completed successfully.
 db2 => connect to slo
 Database Connection Information
 Database server = DB2/SUN64
9.7.0
 SQL authorization ID = DB90 <-
my db2 account
 Local database alias = SLO
db2 => create table EMPLOYEE 
db2 (cont.) => (SSN varchar(9) not
null, 
db2 (cont.) => LastNam
db2 (cont.) => e varchar(20), 
db2 (cont.) => Firs
db2 (cont.) => tName varchar(10), 
db2 (cont.) => Sex varchar(1), 
db2 (cont.) => DeptNo char(3), 
db2 (cont.) => primary key(SSN))
DB20000I The SQL command completed
successfully.
 db2 => insert into DEPARTMENT
values('SG7','Safety
Department','Springy')
DB20000I The SQL command
completed successfully.
 db2 => select LastName, DeptName from
Employee as e, Department as d 
db2 (cont.) => where e.deptno = d.deptno
LASTNAME DEPTNAME
-------------------- --------------------
Simpson Safety Department
Green Safety Department
Bing Accounting
Flanders Personnel
Geller Personnel
5 record(s) selected.
db2 => select Lastname, projectname 
db2 (cont.) => from employee e, department d, project p 
db2 (cont.) => where e.deptno = d.deptno and d.deptno =
p.deptno
LASTNAME PROJECTNAME
-------------------- --------------------
Simpson New Pay
Green New Pay
Flanders GetThings
Geller GetThings
Simpson Alpha
Green Alpha
Simpson Omega
Green Omega
Bing Delta
Simpson Pi
Green Pi
11 record(s) selected.
db2 => select lastname from employee as e, department as d 
db2 (cont.) => where e.deptno = d.deptno and deptname = 'Safety
Department' (line wrapped by powerpoint)
LASTNAME
--------------------
Simpson
Green
2 record(s) selected.
db2 => select lastname from employee where deptno in 
db2 (cont.) => (select deptno from department 
db2 (cont.) => where deptname = 'Safety Department')
LASTNAME
--------------------
Simpson
Green
2 record(s) selected.
db2 => select * from employee, department
SSN LASTNAME FIRSTNAME SEX DEPTNO DEPTNO DEPTNAME LOCATION
--------- -------------------- ---------- --- ------ ------ -------------------- ----------
245 Simpson Homer M SG7 SG7 Safety Department Springy
245 Simpson Homer M SG7 S8P Accounting London
245 Simpson Homer M SG7 G6H Personnel London
245 Simpson Homer M SG7 K9J InfoTech Toronto
34 Flanders Ned M G6H SG7 Safety Department Springy
34 Flanders Ned M G6H S8P Accounting London
34 Flanders Ned M G6H G6H Personnel London
34 Flanders Ned M G6H K9J InfoTech Toronto
222 Green Rachel F SG7 SG7 Safety Department Springy
222 Green Rachel F SG7 S8P Accounting London
222 Green Rachel F SG7 G6H Personnel London
222 Green Rachel F SG7 K9J InfoTech Toronto
333 Bing Changler M S8P SG7 Safety Department Springy
333 Bing Changler M S8P S8P Accounting London
333 Bing Changler M S8P G6H Personnel London
333 Bing Changler M S8P K9J InfoTech Toronto
111 Geller Monica F G6H SG7 Safety Department Springy
111 Geller Monica F G6H S8P Accounting London
111 Geller Monica F G6H G6H Personnel London
111 Geller Monica F G6H K9J InfoTech Toronto
20 record(s) selected.
db2 => select location from department
union 
db2 (cont.) => (select projectlocation
from project)
1
----------
Hong Kong
London
Springy
Toronto
4 record(s) selected.
db2 => create view deptlocations as
select distinct location from
department
DB20000I The SQL command completed
successfully.
db2 => select * from deptlocations
LOCATION
----------
London
Springy
Toronto
3 record(s) selected.
db2 => select * from projlocations except (select * from
deptlocations)
1
----------
Hong Kong
1 record(s) selected.
db2 => select * from projlocations union select * from
deptlocations
1
----------
Hong Kong
London
Springy
Toronto
4 record(s) selected.
db2 => select SSN as SIN from
employee
SIN
---------
111
222
245
333
34
5 record(s) selected.
db2 => select * from projlocations intersect
select * from deptlocations
1
----------
London
Springy
Toronto
3 record(s) selected.
db2 => select * from employee where firstname like
'N%'
SSN LASTNAME FIRSTNAME SEX DEPTNO
--------- -------------------- ---------- --- ------
34 Flanders Ned M G6H
1 record(s) selected.
db2 => select count(*) from projemp
1
-----------
6
1 record(s) selected.
db2 => select count(*) as numberpergroup,
projectid from projemp group by projectid
NUMBERPERGROUP PROJECTID
-------------- ---------
2 P13
3 P35
1 P43
3 record(s) selected.
db2 => update employee set firstname = 'Bozo' where
firstname = 'Ned'
DB20000I The SQL command completed successfully.
db2 => select * from employee
SSN LASTNAME FIRSTNAME SEX DEPTNO
--------- -------------------- ---------- --- ------
245 Simpson Homer M SG7
34 Flanders Bozo M G6H
222 Green Rachel F SG7
333 Bing Changler M S8P
111 Geller Monica F G6H
5 record(s) selected.
db2 => delete from employee where lastname like 'G%'
DB20000I The SQL command completed successfully.
db2 => select * from employee
SSN LASTNAME FIRSTNAME SEX DEPTNO
--------- -------------------- ---------- --- ------
245 Simpson Homer M SG7
34 Flanders Bozo M G6H
333 Bing Changler M S8P
3 record(s) selected.
db2 => create table junk (firstattr integer,
secondattr decimal(10,2))
DB20000I The SQL command completed successfully.
db2 => select * from junk
FIRSTATTR SECONDATTR
----------- ------------
0 record(s) selected.
db2 => alter table junk add third varchar(20)
DB20000I The SQL command completed successfully.
db2 => select * from junk
FIRSTATTR SECONDATTR THIRD
----------- ------------ --------------------
0 record(s) selected.
db2 => list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
DEPARTMENT SYLVIA T 2004-06-21-15.38.51.804343
DEPTLOCATIONS SYLVIA V 2004-06-21-16.05.12.051085
EMPLOYEE SYLVIA T 2004-06-21-15.38.35.567546
JUNK SYLVIA T 2004-06-21-16.26.20.210302
PROJECT SYLVIA T 2004-06-21-15.39.42.940604
PROJEMP SYLVIA T 2004-06-21-15.40.05.233869
PROJLOCATIONS SYLVIA V 2004-06-21-16.06.37.274142
7 record(s) selected.
db2 => drop table junk
DB20000I The SQL command completed successfully.
db2 => list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
DEPARTMENT SYLVIA T 2004-06-21-15.38.51.804343
DEPTLOCATIONS SYLVIA V 2004-06-21-16.05.12.051085
EMPLOYEE SYLVIA T 2004-06-21-15.38.35.567546
PROJECT SYLVIA T 2004-06-21-15.39.42.940604
PROJEMP SYLVIA T 2004-06-21-15.40.05.233869
PROJLOCATIONS SYLVIA V 2004-06-21-16.06.37.274142
6 record(s) selected.
db2 => terminate
DB20000I The TERMINATE command completed
successfully.
obelix[33]% db2stop
10/01/2009 14:16:06 0 0 SQL1064N
DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
ThankYou
www.srinimf.com
Ad

More Related Content

What's hot (20)

IBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration BasicsIBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration Basics
IBM
 
DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
imranasayed
 
Smpe
SmpeSmpe
Smpe
Thousif "[email protected]"
 
Db2 performance tuning for dummies
Db2 performance tuning for dummiesDb2 performance tuning for dummies
Db2 performance tuning for dummies
Angel Dueñas Neyra
 
Db2 tutorial
Db2 tutorialDb2 tutorial
Db2 tutorial
The Vision and Insight Corner
 
DB2 utilities
DB2 utilitiesDB2 utilities
DB2 utilities
Udayakumar Suseendran
 
SKILLWISE-DB2 DBA
SKILLWISE-DB2 DBASKILLWISE-DB2 DBA
SKILLWISE-DB2 DBA
Skillwise Group
 
Tso and ispf
Tso and ispfTso and ispf
Tso and ispf
satish090909
 
DB2 DOCUMENT
DB2 DOCUMENTDB2 DOCUMENT
DB2 DOCUMENT
Nirmal Pati
 
Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)
Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)
Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)
Florence Dubois
 
DB2 on Mainframe
DB2 on MainframeDB2 on Mainframe
DB2 on Mainframe
Skillwise Group
 
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docxKeepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
NeoClova
 
IBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guruIBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guru
Ravikumar Nandigam
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recovery
Yogiji Creations
 
Ipl process
Ipl processIpl process
Ipl process
Thousif "[email protected]"
 
ALL ABOUT DB2 DSNZPARM
ALL ABOUT DB2 DSNZPARMALL ABOUT DB2 DSNZPARM
ALL ABOUT DB2 DSNZPARM
IBM
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning Concept
Chien Chung Shen
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
Simon Huang
 
Understanding DB2 Optimizer
Understanding DB2 OptimizerUnderstanding DB2 Optimizer
Understanding DB2 Optimizer
terraborealis
 
DB2 for z/OS Architecture in Nutshell
DB2 for z/OS Architecture in NutshellDB2 for z/OS Architecture in Nutshell
DB2 for z/OS Architecture in Nutshell
Cuneyt Goksu
 
IBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration BasicsIBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration Basics
IBM
 
DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
imranasayed
 
Db2 performance tuning for dummies
Db2 performance tuning for dummiesDb2 performance tuning for dummies
Db2 performance tuning for dummies
Angel Dueñas Neyra
 
Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)
Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)
Db2 for z/OS and FlashCopy - Practical use cases (June 2019 Edition)
Florence Dubois
 
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docxKeepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
NeoClova
 
IBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guruIBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guru
Ravikumar Nandigam
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recovery
Yogiji Creations
 
ALL ABOUT DB2 DSNZPARM
ALL ABOUT DB2 DSNZPARMALL ABOUT DB2 DSNZPARM
ALL ABOUT DB2 DSNZPARM
IBM
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning Concept
Chien Chung Shen
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
Simon Huang
 
Understanding DB2 Optimizer
Understanding DB2 OptimizerUnderstanding DB2 Optimizer
Understanding DB2 Optimizer
terraborealis
 
DB2 for z/OS Architecture in Nutshell
DB2 for z/OS Architecture in NutshellDB2 for z/OS Architecture in Nutshell
DB2 for z/OS Architecture in Nutshell
Cuneyt Goksu
 

Similar to DB2 Basic Commands - UDB (20)

Database Management System
Database Management SystemDatabase Management System
Database Management System
Hitesh Mohapatra
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
Leandro Santos
 
Data Purge Algorithm
Data Purge AlgorithmData Purge Algorithm
Data Purge Algorithm
Saurabh S Agrawal
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
Connor McDonald
 
How to create a pluggable database by cloning an existing local pdb
How to create a pluggable database by cloning an existing local pdbHow to create a pluggable database by cloning an existing local pdb
How to create a pluggable database by cloning an existing local pdb
Marco Vigelini
 
Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
Connor McDonald
 
Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.
Keshav Murthy
 
Oracle data guard configuration in 12c
Oracle data guard configuration in 12cOracle data guard configuration in 12c
Oracle data guard configuration in 12c
uzzal basak
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
Keshav Murthy
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
Karam Abuataya
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
fcamachob
 
SQL WORKSHOP::Lecture 9
SQL WORKSHOP::Lecture 9SQL WORKSHOP::Lecture 9
SQL WORKSHOP::Lecture 9
Umair Amjad
 
12c for Developers - Feb 2014
12c for Developers - Feb 201412c for Developers - Feb 2014
12c for Developers - Feb 2014
Connor McDonald
 
MDI Training DB2 Course
MDI Training DB2 CourseMDI Training DB2 Course
MDI Training DB2 Course
Marcus Davage
 
Dbmsmanual
DbmsmanualDbmsmanual
Dbmsmanual
Sadhana Sreekanth
 
Les09 Manipulating Data
Les09 Manipulating DataLes09 Manipulating Data
Les09 Manipulating Data
NETsolutions Asia: NSA – Thailand, Sripatum University: SPU
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
Connor McDonald
 
Les 11 Fb Queries
Les 11 Fb QueriesLes 11 Fb Queries
Les 11 Fb Queries
vivaankumar
 
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Marco Tusa
 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developers
InSync Conference
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
Hitesh Mohapatra
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
Leandro Santos
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
Connor McDonald
 
How to create a pluggable database by cloning an existing local pdb
How to create a pluggable database by cloning an existing local pdbHow to create a pluggable database by cloning an existing local pdb
How to create a pluggable database by cloning an existing local pdb
Marco Vigelini
 
Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.
Keshav Murthy
 
Oracle data guard configuration in 12c
Oracle data guard configuration in 12cOracle data guard configuration in 12c
Oracle data guard configuration in 12c
uzzal basak
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
Keshav Murthy
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
Karam Abuataya
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
fcamachob
 
SQL WORKSHOP::Lecture 9
SQL WORKSHOP::Lecture 9SQL WORKSHOP::Lecture 9
SQL WORKSHOP::Lecture 9
Umair Amjad
 
12c for Developers - Feb 2014
12c for Developers - Feb 201412c for Developers - Feb 2014
12c for Developers - Feb 2014
Connor McDonald
 
MDI Training DB2 Course
MDI Training DB2 CourseMDI Training DB2 Course
MDI Training DB2 Course
Marcus Davage
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
Connor McDonald
 
Les 11 Fb Queries
Les 11 Fb QueriesLes 11 Fb Queries
Les 11 Fb Queries
vivaankumar
 
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Marco Tusa
 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developers
InSync Conference
 
Ad

More from Srinimf-Slides (20)

software-life-cycle.pptx
software-life-cycle.pptxsoftware-life-cycle.pptx
software-life-cycle.pptx
Srinimf-Slides
 
Python Tutorial Questions part-1
Python Tutorial Questions part-1Python Tutorial Questions part-1
Python Tutorial Questions part-1
Srinimf-Slides
 
Cics testing and debugging-session 7
Cics testing and debugging-session 7Cics testing and debugging-session 7
Cics testing and debugging-session 7
Srinimf-Slides
 
CICS error and exception handling-recovery and restart-session 6
CICS error and exception handling-recovery and restart-session 6CICS error and exception handling-recovery and restart-session 6
CICS error and exception handling-recovery and restart-session 6
Srinimf-Slides
 
Cics program, interval and task control commands-session 5
Cics program, interval and task control commands-session 5Cics program, interval and task control commands-session 5
Cics program, interval and task control commands-session 5
Srinimf-Slides
 
Cics data access-session 4
Cics data access-session 4Cics data access-session 4
Cics data access-session 4
Srinimf-Slides
 
CICS basic mapping support - session 3
CICS basic mapping support - session 3CICS basic mapping support - session 3
CICS basic mapping support - session 3
Srinimf-Slides
 
Cics application programming - session 2
Cics   application programming - session 2Cics   application programming - session 2
Cics application programming - session 2
Srinimf-Slides
 
CICS basics overview session-1
CICS basics overview session-1CICS basics overview session-1
CICS basics overview session-1
Srinimf-Slides
 
100 sql queries
100 sql queries100 sql queries
100 sql queries
Srinimf-Slides
 
The best Teradata RDBMS introduction a quick refresher
The best Teradata RDBMS introduction a quick refresherThe best Teradata RDBMS introduction a quick refresher
The best Teradata RDBMS introduction a quick refresher
Srinimf-Slides
 
The best ETL questions in a nut shell
The best ETL questions in a nut shellThe best ETL questions in a nut shell
The best ETL questions in a nut shell
Srinimf-Slides
 
IMS DC Self Study Complete Tutorial
IMS DC Self Study Complete TutorialIMS DC Self Study Complete Tutorial
IMS DC Self Study Complete Tutorial
Srinimf-Slides
 
How To Master PACBASE For Mainframe In Only Seven Days
How To Master PACBASE For Mainframe In Only Seven DaysHow To Master PACBASE For Mainframe In Only Seven Days
How To Master PACBASE For Mainframe In Only Seven Days
Srinimf-Slides
 
Assembler Language Tutorial for Mainframe Programmers
Assembler Language Tutorial for Mainframe ProgrammersAssembler Language Tutorial for Mainframe Programmers
Assembler Language Tutorial for Mainframe Programmers
Srinimf-Slides
 
The Easytrieve Presention by Srinimf
The Easytrieve Presention by SrinimfThe Easytrieve Presention by Srinimf
The Easytrieve Presention by Srinimf
Srinimf-Slides
 
Writing command macro in stratus cobol
Writing command macro in stratus cobolWriting command macro in stratus cobol
Writing command macro in stratus cobol
Srinimf-Slides
 
PLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe ProgrammersPLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe Programmers
Srinimf-Slides
 
PL/SQL Interview Questions
PL/SQL Interview QuestionsPL/SQL Interview Questions
PL/SQL Interview Questions
Srinimf-Slides
 
Macro teradata
Macro teradataMacro teradata
Macro teradata
Srinimf-Slides
 
software-life-cycle.pptx
software-life-cycle.pptxsoftware-life-cycle.pptx
software-life-cycle.pptx
Srinimf-Slides
 
Python Tutorial Questions part-1
Python Tutorial Questions part-1Python Tutorial Questions part-1
Python Tutorial Questions part-1
Srinimf-Slides
 
Cics testing and debugging-session 7
Cics testing and debugging-session 7Cics testing and debugging-session 7
Cics testing and debugging-session 7
Srinimf-Slides
 
CICS error and exception handling-recovery and restart-session 6
CICS error and exception handling-recovery and restart-session 6CICS error and exception handling-recovery and restart-session 6
CICS error and exception handling-recovery and restart-session 6
Srinimf-Slides
 
Cics program, interval and task control commands-session 5
Cics program, interval and task control commands-session 5Cics program, interval and task control commands-session 5
Cics program, interval and task control commands-session 5
Srinimf-Slides
 
Cics data access-session 4
Cics data access-session 4Cics data access-session 4
Cics data access-session 4
Srinimf-Slides
 
CICS basic mapping support - session 3
CICS basic mapping support - session 3CICS basic mapping support - session 3
CICS basic mapping support - session 3
Srinimf-Slides
 
Cics application programming - session 2
Cics   application programming - session 2Cics   application programming - session 2
Cics application programming - session 2
Srinimf-Slides
 
CICS basics overview session-1
CICS basics overview session-1CICS basics overview session-1
CICS basics overview session-1
Srinimf-Slides
 
The best Teradata RDBMS introduction a quick refresher
The best Teradata RDBMS introduction a quick refresherThe best Teradata RDBMS introduction a quick refresher
The best Teradata RDBMS introduction a quick refresher
Srinimf-Slides
 
The best ETL questions in a nut shell
The best ETL questions in a nut shellThe best ETL questions in a nut shell
The best ETL questions in a nut shell
Srinimf-Slides
 
IMS DC Self Study Complete Tutorial
IMS DC Self Study Complete TutorialIMS DC Self Study Complete Tutorial
IMS DC Self Study Complete Tutorial
Srinimf-Slides
 
How To Master PACBASE For Mainframe In Only Seven Days
How To Master PACBASE For Mainframe In Only Seven DaysHow To Master PACBASE For Mainframe In Only Seven Days
How To Master PACBASE For Mainframe In Only Seven Days
Srinimf-Slides
 
Assembler Language Tutorial for Mainframe Programmers
Assembler Language Tutorial for Mainframe ProgrammersAssembler Language Tutorial for Mainframe Programmers
Assembler Language Tutorial for Mainframe Programmers
Srinimf-Slides
 
The Easytrieve Presention by Srinimf
The Easytrieve Presention by SrinimfThe Easytrieve Presention by Srinimf
The Easytrieve Presention by Srinimf
Srinimf-Slides
 
Writing command macro in stratus cobol
Writing command macro in stratus cobolWriting command macro in stratus cobol
Writing command macro in stratus cobol
Srinimf-Slides
 
PLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe ProgrammersPLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe Programmers
Srinimf-Slides
 
PL/SQL Interview Questions
PL/SQL Interview QuestionsPL/SQL Interview Questions
PL/SQL Interview Questions
Srinimf-Slides
 
Ad

Recently uploaded (20)

YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 

DB2 Basic Commands - UDB

  • 2.  to start type db2start  To stop db2stop
  • 3.  db2 => connect to sample  db2 => bind sample.bnd Help command: Db2 => ? Db2 => ? CATALOG DATABASE - It gives more info on particular command Quit Commnad: Db2 => quit
  • 4. db2 => db2start This takes some time (maybe 30 seconds) DB20000I The DB2START command completed successfully. db2 => ? ACTIVATE DATABASE GET CONTACTGROUPS RECONCILE ADD CONTACT GET CONTACTS RECOVER ADD CONTACTGROUP GET/UPDATE DB CFG REDISTRIBUTE DB PARTITION ADD DATALINKS MANAGER GET/UPDATE DBM CFG REFRESH LDAP ADD DBPARTITIONNUM GET DBM MONITOR SWITCHES REGISTER LDAP ADD XMLSCHEMA GET DESCRIPTION FOR HEALTH REGISTER XMLSCHEMA ARCHIVE LOG GET NOTIFICATION LIST REGISTER XSROBJECT ATTACH GET HEALTH SNAPSHOT REORG INDEXES/TABLE AUTOCONFIGURE GET INSTANCE REORGCHK BACKUP DATABASE GET MONITOR SWITCHES RESET ADMIN CFG BIND GET RECOMMENDATIONS RESET ALERT CFG CATALOG APPC NODE GET ROUTINE RESET DB CFG CATALOG APPN NODE GET SNAPSHOT RESET DBM CFG CATALOG DATABASE HELP RESET MONITOR CATALOG DCS DATABASE HISTORY RESTART DATABASE CATALOG LDAP DATABASE IMPORT RESTORE DATABASE CATALOG LDAP NODE INITIALIZE TAPE REWIND TAPE CATALOG LOCAL NODE INSPECT ROLLFORWARD DATABASE CATALOG NPIPE NODE LIST ACTIVE DATABASES RUNCMD CATALOG NETBIOS NODE LIST APPLICATIONS RUNSTATS CATALOG ODBC DATA SOURCE LIST COMMAND OPTIONS SET CLIENT CATALOG TCPIP NODE LIST DATABASE DIRECTORY SET RUNTIME DEGREE CHANGE DATABASE COMMENT LIST DB PARTITION GROUPS SET TABLESPACE CONTAINERS CHANGE ISOLATION LEVEL LIST DATALINKS MANAGERS SET TAPE POSITION COMPLETE XMLSCHEMA LIST DBPARTITIONNUMS SET UTIL_IMPACT_PRIORITY CREATE DATABASE LIST DCS APPLICATIONS SET WRITE
  • 5.  CREATE TOOLS CATALOG LIST DCS DIRECTORY START DATABASE MANAGER  DEACTIVATE DATABASE LIST DRDA INDOUBT START HADR  DECOMPOSE XML DOCUMENT LIST HISTORY STOP DATABASE MANAGER  DECOMPOSE XML DOCUMENTS LIST INDOUBT TRANSACTIONS STOP HADR  DEREGISTER LIST NODE DIRECTORY TAKEOVER HADR  DESCRIBE LIST ODBC DATA SOURCES TERMINATE  DETACH LIST PACKAGES/TABLES UNCATALOG DATABASE  DROP CONTACT LIST TABLESPACE CONTAINERS UNCATALOG DCS DATABASE  DROP CONTACTGROUP LIST TABLESPACES UNCATALOG LDAP DATABASE  DROP DATABASE LIST UTILITIES UNCATALOG LDAP NODE  DROP DATALINKS MANAGER LOAD UNCATALOG NODE  DROP DBPARTITIONNUM LOAD QUERY UNCATALOG ODBC DATA  DROP TOOLS CATALOG MIGRATE DATABASE UNQUIESCE DATABASE  ECHO PING UNQUIESCE INSTANCE  EDIT PREP/PRECOMPILE UPDATE ALERT CFG  EXPORT PRUNE HISTORY/LOGFILE UPDATE COMMAND OPTIONS  FORCE APPLICATION PUT ROUTINE UPDATE CONTACT  GET/UPDATE ADMIN CFG QUERY CLIENT UPDATE CONTACTGROUP  GET ALERT CFG QUIESCE DATABASE UPDATE NOTIFICATION LIST  GET AUTHORIZATIONS QUIESCE INSTANCE UPDATE HISTORY  GET/UPDATE CLI CFG QUIESCE TABLESPACES UPDATE LDAP NODE  GET CONNECTION STATE QUIT UPDATE MONITOR SWITCHES  GET CONTACTGROUP REBIND XQUERY  Note: Some commands are operating system specific and may not be available.  For further help:  ? db2-command - help for specified command  ? OPTIONS - help for all command options  ? HELP - help for reading help screens  The preceding three options can be run as db2 <option> from an OS prompt.  !db2ic - DB2 Information Center (Windows only)  This command can also be run as db2ic from an OS prompt.
  • 6.  db2 => create database slo  DB20000I The CREATE DATABASE command completed successfully.  db2 => connect to slo  Database Connection Information  Database server = DB2/SUN64 9.7.0  SQL authorization ID = DB90 <- my db2 account  Local database alias = SLO
  • 7. db2 => create table EMPLOYEE db2 (cont.) => (SSN varchar(9) not null, db2 (cont.) => LastNam db2 (cont.) => e varchar(20), db2 (cont.) => Firs db2 (cont.) => tName varchar(10), db2 (cont.) => Sex varchar(1), db2 (cont.) => DeptNo char(3), db2 (cont.) => primary key(SSN)) DB20000I The SQL command completed successfully.
  • 8.  db2 => insert into DEPARTMENT values('SG7','Safety Department','Springy') DB20000I The SQL command completed successfully.
  • 9.  db2 => select LastName, DeptName from Employee as e, Department as d db2 (cont.) => where e.deptno = d.deptno LASTNAME DEPTNAME -------------------- -------------------- Simpson Safety Department Green Safety Department Bing Accounting Flanders Personnel Geller Personnel 5 record(s) selected.
  • 10. db2 => select Lastname, projectname db2 (cont.) => from employee e, department d, project p db2 (cont.) => where e.deptno = d.deptno and d.deptno = p.deptno LASTNAME PROJECTNAME -------------------- -------------------- Simpson New Pay Green New Pay Flanders GetThings Geller GetThings Simpson Alpha Green Alpha Simpson Omega Green Omega Bing Delta Simpson Pi Green Pi 11 record(s) selected.
  • 11. db2 => select lastname from employee as e, department as d db2 (cont.) => where e.deptno = d.deptno and deptname = 'Safety Department' (line wrapped by powerpoint) LASTNAME -------------------- Simpson Green 2 record(s) selected. db2 => select lastname from employee where deptno in db2 (cont.) => (select deptno from department db2 (cont.) => where deptname = 'Safety Department') LASTNAME -------------------- Simpson Green 2 record(s) selected.
  • 12. db2 => select * from employee, department SSN LASTNAME FIRSTNAME SEX DEPTNO DEPTNO DEPTNAME LOCATION --------- -------------------- ---------- --- ------ ------ -------------------- ---------- 245 Simpson Homer M SG7 SG7 Safety Department Springy 245 Simpson Homer M SG7 S8P Accounting London 245 Simpson Homer M SG7 G6H Personnel London 245 Simpson Homer M SG7 K9J InfoTech Toronto 34 Flanders Ned M G6H SG7 Safety Department Springy 34 Flanders Ned M G6H S8P Accounting London 34 Flanders Ned M G6H G6H Personnel London 34 Flanders Ned M G6H K9J InfoTech Toronto 222 Green Rachel F SG7 SG7 Safety Department Springy 222 Green Rachel F SG7 S8P Accounting London 222 Green Rachel F SG7 G6H Personnel London 222 Green Rachel F SG7 K9J InfoTech Toronto 333 Bing Changler M S8P SG7 Safety Department Springy 333 Bing Changler M S8P S8P Accounting London 333 Bing Changler M S8P G6H Personnel London 333 Bing Changler M S8P K9J InfoTech Toronto 111 Geller Monica F G6H SG7 Safety Department Springy 111 Geller Monica F G6H S8P Accounting London 111 Geller Monica F G6H G6H Personnel London 111 Geller Monica F G6H K9J InfoTech Toronto 20 record(s) selected.
  • 13. db2 => select location from department union db2 (cont.) => (select projectlocation from project) 1 ---------- Hong Kong London Springy Toronto 4 record(s) selected.
  • 14. db2 => create view deptlocations as select distinct location from department DB20000I The SQL command completed successfully. db2 => select * from deptlocations LOCATION ---------- London Springy Toronto 3 record(s) selected.
  • 15. db2 => select * from projlocations except (select * from deptlocations) 1 ---------- Hong Kong 1 record(s) selected. db2 => select * from projlocations union select * from deptlocations 1 ---------- Hong Kong London Springy Toronto 4 record(s) selected.
  • 16. db2 => select SSN as SIN from employee SIN --------- 111 222 245 333 34 5 record(s) selected.
  • 17. db2 => select * from projlocations intersect select * from deptlocations 1 ---------- London Springy Toronto 3 record(s) selected.
  • 18. db2 => select * from employee where firstname like 'N%' SSN LASTNAME FIRSTNAME SEX DEPTNO --------- -------------------- ---------- --- ------ 34 Flanders Ned M G6H 1 record(s) selected.
  • 19. db2 => select count(*) from projemp 1 ----------- 6 1 record(s) selected.
  • 20. db2 => select count(*) as numberpergroup, projectid from projemp group by projectid NUMBERPERGROUP PROJECTID -------------- --------- 2 P13 3 P35 1 P43 3 record(s) selected.
  • 21. db2 => update employee set firstname = 'Bozo' where firstname = 'Ned' DB20000I The SQL command completed successfully. db2 => select * from employee SSN LASTNAME FIRSTNAME SEX DEPTNO --------- -------------------- ---------- --- ------ 245 Simpson Homer M SG7 34 Flanders Bozo M G6H 222 Green Rachel F SG7 333 Bing Changler M S8P 111 Geller Monica F G6H 5 record(s) selected.
  • 22. db2 => delete from employee where lastname like 'G%' DB20000I The SQL command completed successfully. db2 => select * from employee SSN LASTNAME FIRSTNAME SEX DEPTNO --------- -------------------- ---------- --- ------ 245 Simpson Homer M SG7 34 Flanders Bozo M G6H 333 Bing Changler M S8P 3 record(s) selected.
  • 23. db2 => create table junk (firstattr integer, secondattr decimal(10,2)) DB20000I The SQL command completed successfully. db2 => select * from junk FIRSTATTR SECONDATTR ----------- ------------ 0 record(s) selected. db2 => alter table junk add third varchar(20) DB20000I The SQL command completed successfully. db2 => select * from junk FIRSTATTR SECONDATTR THIRD ----------- ------------ -------------------- 0 record(s) selected.
  • 24. db2 => list tables Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- DEPARTMENT SYLVIA T 2004-06-21-15.38.51.804343 DEPTLOCATIONS SYLVIA V 2004-06-21-16.05.12.051085 EMPLOYEE SYLVIA T 2004-06-21-15.38.35.567546 JUNK SYLVIA T 2004-06-21-16.26.20.210302 PROJECT SYLVIA T 2004-06-21-15.39.42.940604 PROJEMP SYLVIA T 2004-06-21-15.40.05.233869 PROJLOCATIONS SYLVIA V 2004-06-21-16.06.37.274142 7 record(s) selected. db2 => drop table junk DB20000I The SQL command completed successfully. db2 => list tables Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- DEPARTMENT SYLVIA T 2004-06-21-15.38.51.804343 DEPTLOCATIONS SYLVIA V 2004-06-21-16.05.12.051085 EMPLOYEE SYLVIA T 2004-06-21-15.38.35.567546 PROJECT SYLVIA T 2004-06-21-15.39.42.940604 PROJEMP SYLVIA T 2004-06-21-15.40.05.233869 PROJLOCATIONS SYLVIA V 2004-06-21-16.06.37.274142 6 record(s) selected.
  • 25. db2 => terminate DB20000I The TERMINATE command completed successfully. obelix[33]% db2stop 10/01/2009 14:16:06 0 0 SQL1064N DB2STOP processing was successful. SQL1064N DB2STOP processing was successful.