• Tidak ada hasil yang ditemukan

Think Different Basis Data : SQL- QUERY CF124g01

N/A
N/A
Protected

Academic year: 2017

Membagikan "Think Different Basis Data : SQL- QUERY CF124g01"

Copied!
20
0
0

Teks penuh

(1)

© Copyright IBM Corporation 2007

Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 4.0.3

Introduction

(2)

© Copyright IBM Corporation 2006

Unit Objectives

After completing this unit, you should be able to:

ƒ Define the terms

– Database, table, row, column, view

ƒ State the more common DB2 data types

ƒ List the most commonly used SQL statements in the

– Data definition language (DDL)

– Data manipulation language (DML)

– Data control language (DCL)

(3)

© Copyright IBM Corporation 2006

Departments

Employees

Projects

(4)

© Copyright IBM Corporation 2006

FIRSTNME MIDINIT LASTNAME WORKDEPT ... DEPTNAME

..

SPIFFY COMPUTER SERVICE DIV.

PLANNING

INFORMATION CENTER

DEVELOPMENT CENTER

MANUFACTURING SYSTEMS

ADMINISTRATION SYSTEMS

PROJNAME DEPTNO

..

GENERAL ADMIN SYSTEMS

PAYROLL PROGRAMMING

A collection of tables

(5)

© Copyright IBM Corporation 2006

Please give me a list of all employees in

department D11 sorted by name.

000150 ADAMSON BRUCE D11 000200 BROWN DAVID D11

000050 GEYER B JOHN E01 000340 GOUNOT R JASON E21

(6)

© Copyright IBM Corporation 2006

SELECT * FROM EMPLOYEE WHERE WORKDEPT = 'D11' ORDER BY LASTNAME

SELEC

T Statement

EMPNO LASTNAME MID

INIT FIRSTNME WORKDEPT PHONENO

Return a list of employees in department D11 sorted by last name

(7)

© Copyright IBM Corporation 2006

(8)
(9)

© Copyright IBM Corporation 2006

Qualified Table Name USERA.EMPLOYEE

Table owner / Schema Simple Name

USERA EMPLOYEE

(10)

© Copyright IBM Corporation 2006

Data Type Comment

SMALLINT

INTEGER

DECIMAL(m,n)

Whole numbers from -32768 to +32767

Whole numbers from -2,147,483,648 to

+2,147,483,647

Decimal numbers with max. 31 digits

m = total number of digits

(11)

© Copyright IBM Corporation 2006

Data Type Comment

CHAR(n) or

CHARACTER(n)

VARCHAR(n)

STRING (fixed length)

(12)

© Copyright IBM Corporation 2006

Data Type Comment

DATE Display / Input Format

YYYYMMDD USA mm/dd/yyyy

EUR dd.mm.yyyy

ISO yyyy-mm-dd

JIS yyyy-mm-dd

DATE / TIME / TIMESTAMP data type - input verification allows arithmetic sorting

(13)

© Copyright IBM Corporation 2006

Data Type Comment

TIME

HHMMSS

Display / Input Formats

USA hh:mm AM or PM

EUR hh.mm.ss

ISO hh.mm.ss

(14)

© Copyright IBM Corporation 2006

CREATE TABLE EMPLOYEE

( EMPNO CHAR(6) NOT NULL, FIRSTNME VARCHAR(12) NOT NULL, MIDINIT CHAR(1) NOT NULL, LASTNAME VARCHAR(15) NOT NULL,

WORKDEPT CHAR(3) ,

. . .

. . .

BIRTHDATE DATE ,

SALARY DECIMAL(9,2) ,

BONUS DECIMAL(9,2) ,

COMM DECIMAL(9,2) )

(15)

© Copyright IBM Corporation 2006

"nullable" Column can be marked as having an 'unknown value'

NOT NULL Column must always have a value

NOT NULL WITH Column must always have a value

DEFAULT if we do not supply one, a system [(value)] or user defined default value will be supplied

(16)

© Copyright IBM Corporation 2006

DEPARTMENT

EMPLOYEE PROJECT

REVOKE SELECT ON PROJECT FROM SALLY GRANT SELECT ON PROJECT TO SALLY

(17)

© Copyright IBM Corporation 2006

EMPNO FIRSTNME MIDINIT LASTNAME WORKDEPT PHONENO

000150 4510

000200 4501

000050 6789

000340 5698

000010 CHRISTINE T HAAS A00 3978

You only see what you should

z Data security z Simplification

(18)

© Copyright IBM Corporation 2006

Checkpoint

1. True or False? A database is a collection of tables.

2. What are some of the advantages of using date data types?

3. Name the alphanumeric and numeric data types covered in this unit.

(19)

© Copyright IBM Corporation 2006

Checkpoint Solutions

1. True

2. Automatic verification of correctness Date arithmetic

Date, time, timestamp sorting Extraction of components

3. CHAR/CHARACTER (fixed length) VARCHAR (variable length)

SMALLINT INTEGER, INT

DECIMAL(x,y), DEC(x,y)

(20)

© Copyright IBM Corporation 2006

Unit Summary

Having completed this unit, you should be able to:

ƒ Define the terms

– Database, table, row, column, view

ƒ State the more common DB2 data types

ƒ List the most commonly used SQL statements in the

– Data definition language (DDL)

– Data manipulation language (DML)

– Data control language (DCL)

Gambar

Table owner / Schema

Referensi

Dokumen terkait

The extraction of EMG data is to have the reduced vector in the signal features for minimising the signals error than can be implement in classifier.The classification of

Penelitian yang berjudul “Antarmuka Bahasa Indonesia Pengakses Basis Data dengan Pembangkitan Input Query Alternatif Menggunakan Kaidah Sintaksis dan Semantik”

Sebelum membuat index pada sebuah database , harus membuat dan memikirkan strategi yang tepat karena tidak semua data atau harus menggunakan index.. Strategi dalam

Dalam pemrosesan input/output data dibutuhkan teknologi yang real time dalam mewujudkan DBMS ( Database Management System ) yang terintegrasi dan aman pada seluruh siklus manajemen

Dalam pemrosesan input/output data dibutuhkan teknologi yang real time dalam mewujudkan DBMS ( Database Management System ) yang terintegrasi dan aman pada seluruh siklus manajemen

CTE-Input data Choice of day Type Normal index Designation Code index Ta mb Ambient temperature in K TTAMB t Global calculation time in s GGTEMPS RSH Global horizontal

Research Framework INPUT Date and Time Data Heart Rate, and Temperature Data Oxygen Saturation Data PROCESS FINITE STATE AUTOMATA OUTPUT Voice Based Date Information

Kamus Data File survey No Nama Field Type Lebar Des Keterangan 1 id_pasien+id_su rvey Auto number Long integer kode pasien dan kode survey 2 tgl_ambildt Date 8 Tanggal