Module 2-4
Module 2-4
MySQL/DB2: CREATE TABLE table_name (col1 CREATE TABLE statement is to create the table.
CREATE datatype optional keyword, col2 datatype Each column in the table is specified with its MySQL/DB2: CREATE TABLE employee (
optional keyword,col3 datatype optional employee_id char(2) PRIMARY KEY, first_name
TABLE keyword,..., coln datatype optional
name, data type and an optional keyword which varchar(30) NOT NULL, mobile int);
keyword) could be PRIMARY KEY, NOT NULL, etc.,
MySQL/DB2:
MySQL/DB2
Option 1. ALTER TABLE table_name ADD
ALTER column_name_1 datatype....ADD COLUMN Option 1. ALTER TABLE employee ADD income
TABLE - column_name_n datatype; ALTER TABLE statement is used to add the bigint;
ADD columns to a table.
COLUMN
Option 2. ALTER TABLE table_name ADD COLUMN Option 2. ALTER TABLE employee ADD COLUMN
column_name_1 datatype....ADD COLUMN income bigint;
column_name_n datatype;
ALTER
TABLE - MySQL/DB2: ALTER TABLE table_name DROP ALTER TABLE DROP COLUMN statement is used to MySQL/DB2:
DROP COLUMN column_name_1 ; remove columns from a table. ALTER TABLE employee DROP COLUMN mobile ;
COLUMN
Author(s)
Himanshu Birla
Niveditha Pandith TS
about:blank 1/1