DB2 Commands

Show Databases

db2
list active databases

Show schemas

select schemaname from syscat.schema

Show Tables (in your Schema)

list tables

Schemas

DB2 SELECT SCHEMANAME FROM SYSCAT.SCHEMATA -- list all schemas
DB2 VALUES CURRENT SCHEMA -- gets the current schema
DB2 SET SCHEMA ALEXSCHEMA -- set schema

Export a Table to CSV

EXPORT TO result.csv OF DEL MODIFIED BY NOCHARDEL SELECT col1, col2, coln FROM testtable;


export to /usr/data/dir/file.csv OF DEF MODIFIED BY NOCHARDEL select * from tim_table

Get first n Rows

This seems more complex than needs to be

SELECT LASTNAME, FIRSTNAME, EMPNO, SALARY
  FROM EMP
  ORDER BY SALARY DESC
  FETCH FIRST 20 ROWS ONLY;