Languages And Data Types Used In SQL Server

Languages And Data Types / Logical Operators Used In SQL Server
\\ If you have any query or questions on my post, then please comment below //


Languages to be used:

                          

    DDL (Data Definition language)      DML (Data Manipulation Language)
              
            1.    ALTER                                                 1.    INSERT
            2.    DROP                                                  2.   SELECT
            3.   TRUNCATE                                            3.   UPDATE
                                                                               4.   DELETE
DDL (Data Definition Language): It is used to create or destroy the database objects. These commands will be used by database during the setup and removal phases of a database project. 
 

.1ALTER : After creating a table if we want to modify the table, we use ALTER command.

Ex.  Create database demo1                  // create a database

       create table EmpDetail                   // create table

      (

       EmpId int identity(1,1),                   // identity is auto generated

       EmpName varchar(50),

       EmpDept varchar(50),

       EmpSal float

      )

Increasing the width of a column                          

Syntax - ALTER table EmpDetail ALTER cloumn EmpName varchar(100)   

Decreasing the width of a column :

Syntax – ALTER table EmpDetail ALTER column EmpName varchar(50)


Adding / Removing (Not Null / Null) constraint :

Syntax – ALTER table EmpDetail ALTER column EmpName varchar(50) Not Null

Adding new column :

Syntax – ALTER table EmpDetail ADD EmpPost varchar(50)


Dropping an existing column :

Syntax – ALTER table EmpDetail DROP column EmpPost


Adding constraint to any column :

Syntax – ALTER table EmpDetail ADD constraint EmpId_pk      //primary key
Dropping an existing constraint :

Syntax – ALTER table EmpDetail DROP constraint EmpId_pk



.2DROP : If we want to destroy the existing tables present in the database we use the DROP command.

Dropping the table :                     //Remove table

Syntax – DROP table EmpDetail



3.TRUNCATE : Removes all rows from table. It is same as DELETE  statement with no “where” clause.


Truncating the table :                   // Move table

Syntax – TRUNCATE table EmpDetail

DML (Data Manipulating Language) : Making changes in data that already exists.

                                                                          

1.   INSERT : To INSERT the values in the column of the table.

Syntax – INSERT into EmpDetail(EmpName,EmpDept,EmpSal) values(Martin,EEE,10000)              // if the EmpId is auto generated then no   

                                                                       need to generate it

 2.  SELECT : To display the result or table as output we use SELECT command.

Syntax – SELECT * from EmpDetail 



3.UPDATE : If we want to the data existing in the table we use UPDATE statement.

Syntax – UPDATE EmpDetail Set EmpName=Mike 



4DELETE : If we want to delete rows of data present in the table we use DELETE  statement.

Syntax – DELETE from EmpDetail where EmpName=Mike
 
Data Types And Logical Operators
 
Data Types Used :

1.Int                                           12.  DateTime                           23.   TimeStamp

2.Bingint                                    13.  SmallDateTime                 24.   Xml

3.Smallint                                  14.  Char                                   25.   Cursor

4.Tinyint                                    15.  Varchar

5.Big                                           16.  Text

6.Decimal                                   17.  Nchar

7.Numeric                                  18.  Nvarchar

8.Money                                     19.  Ntext

9.Float                                        20.  Binary

10.Real                                         21.  Varbinary

11.Date                                        22.  Image


Logic Operators Used :

1.ALL                                          6.  IN

2.AND                                         7.  LIKE

3.ANY                                         8.  NOT

4.BETWEEN                              9.  OR

5.EXISTS                                   10.  SOME
                                                             


 Enter Your Email Id To Get Our Programming, Web Development, Video Tutorial, Job Updates In Mail :

Labels: