Amazon

Monday, June 8, 2009

DB2 Basic Essentails

Listing the details(metadata) of a table.
SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = ‘MYTABLE’ AND TBCREATOR = ‘MYSCHEMA’ ORDER BY COLNO
where TBNAME is table name and TBCREATOR is schema name

Listing column name, column type, size, tablename of column of a table
SELECT name, coltype, length, tbname FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = ‘MYTABLE’ AND TBCREATOR = ‘MYSCHEMA’ ORDER BY name

Selecting current date and current time
SELECT CURRENT DATE, CURRENT TIME FROM MYSCHEMA.MYTABLE

Using current date, current time in insert query
INSERT INTO MYSCHEMA.MYTABLE(MYDATE, MYTIME) VALUES (CURRENT TIME, CURRENT DATE)

No comments:

Post a Comment

Amazon Best Sellors

TOGAF 9.2 - STUDY [ The Open Group Architecture Framework ] - Chap 01 - Introduction

100 Feet View of TOGAF  What is Enterprise? Collection of Organization that has common set of Goals. Enterprise has People - organized by co...