Home     SQL Basic     Contact Us     Site Map    

SQL BASIC

SQL SELECT

SQL WHERE

SQL DISTINCT

SQL AND

SQL OR

SQL NOT

SQL ORDER BY

SQL IN

SQL BETWEEN

SQL LIKE

SQL ALIAS

SQL AGGREGATE

>SQL COUNT

>SQL SUM

>SQL MAX

>SQL MIN

>SQL AVG

SQL GROUP BY

SQL HAVING

SQL INSERT

SQL UPDATE

SQL DELETE

SQL SELECT INTO

SQL CREATE DATABASE

SQL CREATE TABLE

SQL DROP TABLE

SQL DROP DATABASE

SQL CREATE INDEX

SQL PRIMARY KEY

SQL FOREIGN KEY

SQL ALTER TABLE

SQL TRUNCATE TABLE

SQL JOIN

SQL INNER JOIN

SQL OUTER JOIN

SQL CROSS JOIN

SQL UNION

SQL UNION ALL

SQL INTERSECT



SQL ALTER TABLE

The UPDATE, INSERT, DELETE Statements are used to change the contents of a table. SQL also offers ways of changing the structure of a table. Table Structure can be change by using ALTER TABLE command. It usually is use for adding column into the table and dropping column as well.

SQL syntax will be like this:

ALTER TABLE [TABLE NAME]
[TABLE ALTERING]

OR

[TABLE ALTERING] :=
ADD [COLUMN NAME] [DATATYPE] |
DROP COLUMN [COLUMN NAME]


EXAMPLE :

1. Add a new column name player_firstname into table GamesScores.

SQL Statement:

ALTER TABLE GameScores
ADD player_firstname CHAR(40)

2. Drop a column player_firstname from the table name GameScores.

SQL Statement:

ALTER TABLE GameScores
DROP COLUMN player_firstname