Monday, August 16, 2010

Create and alter Tables

Create and alter Tables:


A table is a repository for data, with items of data grouped in one or more columns. Tables contain zero or more rows of information.

Eg: Creating tables
CREATE TABLE Student
(
rollNo INT,
name VARCHAR(50),
mark1 INT,
mark2 INT
)
 
Altering tables:


If we need to change the definition of a table after creating it, we can use the ALTER TABLE statement.
We can use ALTER TABLE to add additional columns to a table, remove columns from the table, add and remove constraints, disable and enable constraints and disable and enable triggers.

Eg:
ALTER TABLE Student

ADD Total INT

ALTER TABLE Student
DROP COLUMN Total

No comments: