§ Tables are divided into
columns and rows.
§ Defining datatype for each
column
Creating Table
Syntax
CREATETABLEtable_name(
column1
datatype,
column2
datatype,
column3
datatype,
.....
columnN datatype,
PRIMARYKEY ( one or more columns)
);
§ The unique name or identifier
for the table follows the CREATE TABLE statement.
§ Then in brackets comes the
list defining each column in the table and what sort of data type it is.
Example
CREATETABLE CUSTOMERS(
ID INTNOTNULL,
NAME VARCHAR
(20)NOTNULL,
AGE INTNOTNULL,
ADDRESSCHAR (25),
SALARY DECIMAL (18, 2),
PRIMARYKEY
(ID)
);
Modifying Table
The ALTER TABLE statement is used to add, delete,
or modify columns in an existing table.
Syntax
ALTERTABLEtable_name
ADDcolumn_name
datatype
Syntax for modifying
ALTERTABLEtable_name
ALTERCOLUMNcolumn_name datatype
Syntax for deleting
ALTERTABLEtable_name
DROPCOLUMNcolumn_name
<<Prev Next>>
Comments
Post a Comment