• 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

Hipotesis yang diajukan: ada tingkat dosis Iso p ro p ila mina g lifo sa t yang efektif untuk mengendalikan gulma pada lahan pertanaman karet TBM, ada pengaruh selang

Hal tersebut lebih lanjut ditegaskan dalam Pasal 92 UU No.23 tahun 2014 Tentang Pemerintahan Daerah yang mengatakan bahwa Dalam hal gubernur sebagai wakil Pemerintah

Pada praktikum yang pertama yaitu membahas mengenai penentuan struktur tanah menggunakan metode ayakan yang dimana setiap agregat tanah akan memberi pengaruh terhadap

In all trials, the late-maturity varieties grew con- siderably taller, exhibited higher growth rates, developed larger stem diameters and reached higher LAI values compared to

The microwave assisted carba- mate / phosphate esters obtained at 105°C revealed a slightly higher crystallinity than the industrial product and microwave assisted carbamate /

dimaksud dalam huruf a, perlu menetapkan Peraturan Pemerintah tentang Perubahan Ketujuh Atas Peraturan Pemerintah Nomor 29 Tahun 2001 tentang Peraturan Gaji

bahwa dalam rangka meningkatkan daya guna dan hasil guna serta kesejahteraan Anggota Tentara Nasional Indonesia, perlu mengubah gaji pokok Anggota Tentara Nasional

2) Guru bersama dengan peserta didik mengidentifikasi kelebihan dan kekurangan kegiatan pembelajaran (yaitu kegiatan mengumpulkan informasi dengan cara …, menjawab pertanyaan