Monday, September 28, 2015

SQL





INTRODUCTION:

SQL is a standard language for accessing databases. It is categorized as below

1.Data Definition Language (DDL)

2.Data Manipulation Language (DML)

3.Data Retrieval Language (DRL)

4.Transaction Control Language (TCL)

5.Data Control Language (DCL)

1.Data Definition Language (DDL):

In DDL, we have  create, alter, drop, truncate, rename.

Create:

Create statement used to create an object in the database.

syntax:
Create table <table_name> (col1 datatype1, col2 datatype2 …coln datatypen);

Ex:
creating a table:

create table student (no number (2), name varchar (10), marks number (3));






Selecting the table after table created.




























Alter:

Alter statement used to add or remove columns in the existing table and to modify the precision of the data types given for the column.

1. Adding column to the existing table:

Syntax:

alter table <table_name> add <col datatype>;

Example:

ALTER TABLE student ADD sdob date;







No comments:

Post a Comment