Saturday, 13 February 2016

SQL SERVER -- DDL Commands -- Part-3

SQL SERVER -- DDL Commands -- Part-3

DDL Commands:-
                                               DDL Stands for Data Definition language and these commands are used to CREATE, ALTER and DELETE database Objects.

CREATE – This command is used to create database objects
                   Like Database and Table.

-- How to Create New DataBase
CREATE DATABASE SQLSERVER
GO

-- How to go inside to the Database
USE SQLSERVER
GO

-- CREATE
-- How to Create New Table
CREATE TABLE EMP
(
       EMPID INT
      ,EMPNAME VARCHAR(50)
      ,SAL MONEY
      ,DOJ DATE
      ,LOC VARCHAR(50)
      ,GENDER CHAR(6)
      ,MagrID INT
      ,DEPTNO INT
)

ALTER – This command is used to Alters database objects
              Like adding new column to the table        

-- ALTER
-- How to Add New Column to the Table
ALTER TABLE EMP
ADD COUNTRY CHAR(100)

-- How to Drop the Column the Table
ALTER TABLE EMP
DROP COLUMN COUNTRY


TRUNCATE – This command is used to delete all records from a table and resets table identity to initial value.


DROP – This command is used to delete objects of the database

-- How to Drop the Table from the Database
DROP TABLE EMP

-- How to Drop the Column the Table
ALTER TABLE EMP

DROP COLUMN COUNTRY




2 comments:

  1. Hi,
    SSRS 2005 had two separate services. SSRS 2008 is easier to configure, deploy and manage without losing any functionality. SSRS Shares internal components with SQL Server. It enables better memory management capabilities. It has Supports single instance, multi instance and Scale Out. thanks for sharing of valuable information.

    ReplyDelete
  2. what is difference between truncate and delete

    ReplyDelete