Db2 Training Class 002
Db2 Training Class 002
Db2 Training Class 002
Language
Introduction to SQL
Database Tables
ANIL
HYD
A0002
SRINU
PUNE
A0003
SUNIL
BANG
DDL
DDL is abbreviation of Data Definition Language. It is
DML
DML is abbreviation of Data Manipulation Language.
TCL
TCL is abbreviation of Transactional Control
DCL
DCL is abbreviation of Data Control Language. It is
DDL Statements
The most important DDL statements in SQL are:
CREATE Statement
CREATE TABLE PROJECT
(PROJNO
CHAR(6) NOT NULL,
PROJNAME
VARCHAR(10) NOT NULL,
DEPTNO
SMALLINT,
BUDGET
DECIMAL(6,2),
STARTDATE
DATE,
ENDDATE
DATE) IN FSS197DB.FSS197TS;
CREATE TABLE EMPMAST
(EMPID SAMLLINT NOT NULL,
EFNAME CHAR(15) NOT NULL,
ELNAME VARCHAR(15) NOT NULL,
EMPDOB DATE NOT NULL,
EMPSAL DECIMAL(7,2),
EMPDEPT CHAR(5) NOT NULL,
PRIMARY KEY(EMPID)) IN FSS197DB.FSS197TS;
COBOL
CHAR(n)
VARCHAR(n)
10 FIELD-A
49 FIELD-A-LENGTH PIC S9(4)COMP
49 FIELD-A-TEXT
PIC X(n)
SMALLINT
INTEGER
DECIMAL(p , q )
DATE-YYYY-MM-DD
TIME - HH:MM:SS
TIME STAMP
Understanding Constraints
CONSTRAINTs
ALTER SYNTAX:
ALTER TABLE TABLENAME ADD COLUMN NAME
DATA TYPE CONSTRAINT;
DROP SYNTAX:
DROP TABLE TABLENAME;
DML
INSERT
It is used to insert rows in the table.
INSERT SYNTAX:
UPDATE SYNTAX:
UPDATE TABLE NAME SET COLUMN NAME = NEW VALUE
[WHERE CONDITION];
DELETE SYNTAX:
DELETE FROM TABLE NAME WHERE CONDITION;
SELECT
COMMIT;
SYNTAX :
ROLLBACK;
GRANT SYNTAX:
GRANT SELECT, INSERT, DELETE ON TABLENAME FOR
RACFID;
REVOKE SYNTAX:
REVOKE INSERT, DELETE ON TABLENAME FROM RACFID;
Thank you
www.mainframes-online-training.weebly.com