Sunday 20 October 2013

sql command set | DDL(Data definition language). | create | Alter | Drop

"Sql command set".
1-> "DDL(Data definition language)".
DDL includes Create ,alter , drop,truncate , comment , rename.
Let's study all there functionality one by one.

i->Create
 Create used  to create new table and object.
or you can create many tables and objects.
examples.
to Create table.
Create table student
(
id int identity primary key,
name varchar(20),
roll_no int
)
ii->Alter
 Used  to modify structure of table and other object..
alter table student alter name varchar(100)
using this query we can change size of column .
alter table student add  fee int.

iii->drop
Drop is used to drop table or column of table or object.
alter table student drop column name.
drop table student.
drop database stud.
we can drop database also by using drop keyword or command.


iv->Truncate 
Truncate use to delete all data present in the table.
But not table structure means , table will be there but it won't show any of record.

Truncate table Table_name
Truncate table student.

v->Comments
to add comments in procedure.

sp_insertrecord --'1','abcval'


vi->Rename
to rename  single table or multiple table in same database.
to rename single or multiple column in same table.

sp_rename 'existtablename' ,'renamedtablename'
SP_RENAME 'student.roll_no' ,'roll'  --to rename column name

SP_RENAME 'student' ,'stud'

Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: