Create Tablecreate table statement
is used to create a new table. Here is the syntax:
create table tablename
(
column1 data type(size),
column2 data type(size),
column3 data type(size)
);
For example:
create table members
(
userId varchar(25),
user varchar(20),
pass varchar(20),
page varchar(50)
);
Data types specify what the type of data can be for that particular column.
Here are the most common Data types:
char(size) ---------Fixed-length character string. Size is specified in parenthesis.
Max 255 bytes.
varchar(size) ------Variable-length character string. Max size is specified
in parenthesis.
number(size) ------Number value with a max number of column digits specified
in parenthesis.
date --------------Date value
number(size,d) ---Number value with a maximum number of digits of "size" total,
with a maximum number of "d" digits to the right of the decimal.
Alter Table
We can add a column to a table by using the key words alter table and
add:
alter table members add logoLink(50);
This statement add a column named logoLink to the members table.
Drop Table
To delete a table, we use the key words drop table:
drop table members;
If you execute this statement, the table named members will be permanently
removed.
|