DDL Command in SQL-Server.

Data Definition Language (DDL) 

    • DDL stands for Data Definition Language.
    • DDL statements are used to define the database structure or schema.
    • It is used to create and modify the structure of database objects in database.
    •  Examples

      CREATE, ALTER, DROP statements

      1. CREATE
        - For creating databases & database objects.

      Syntax for creating database:
      CREATE DATABASE DataBaseName

Create DataBase Students

               Syntax for creating Table:

CREATE TABLE StudentsMst
(
StudentId int,|
StudentName varchar(50),
StudentCity varchar(50),
)

2. ALTER
- For altering/modifying the exsisting tables.

Syntax for Altering/Adding columns:

Alter Table TableName Add Column1 datatype,Column2 datatype,…..

     Example

Alter Table StudentsMst Add DateOfBirth datetime,SchoolName varchar(300)

   Syntax for changing column datatype:

Alter Table TableName Alter Column ColumnName NewDataType

Example

Alter Table StudentsMst Alter Column StudentPincode BigInt

3. DROP
-
For delete objects from the database

Drop Table table1,table2,…

Example

Drop DataBase Students

Leave a Reply

Your email address will not be published. Required fields are marked *

4 + 3 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">