SQL COMMANDS

            TYPES OF SQL COMMANDS


                                 There are five types of Structure query language (SQL) commands . They are 
                                                    (1) Data defination language (DDL)
                                                    (2) Data manipulate language (DML)
                                                    (3) Data control language (DCL)  
                                                    (4) Transaction control language (TCL)
                                                    (5) Data quiery language (DQL)





(1) Data defination language :

                                                             This DDL command is use to creating a table , deletingg a table , alterning a table .DDL is consist of followingg commands .
                                                   (i) Create
                                                  (ii) Drop
                                                 (iii) Alter
                                                 (iv) Turncate


(i) Create : 

                      It  is use to creaate a new table in the database .
      
            Syntax :  Create table table name (column 1 datatype , column 2 datatype,..............);
         Example : Create table student (student name  var char(20) , var char(20) , Date of birth Date ) ;

(ii) Drop : 

                   It is use to delete both rows and columns in that table .
    
           Syntax : Drop  table name ;
        Example : Drop student ;

(iii) Alter : 

                   It is use to alter the structure of the database . This changes could be either to modify the charecteristic of existing attribute (or) to add new attribute .

          Syntax :  Alter table name ( ADD  column name database ) ;
       Example : Alter student ( Address  var char (20) ;

(iv) turrncate : 

                This command is  use to delete all the rows from the table .

   Syntax :  Turncate table  table name ;
Example : Turncate table student ;
 

(2) Data manipulate language :

                                          This commands are  use to modify the database . It is responsible for all form of changes in the database . The DML commands are follow insert , update , delete .


(i) Insert :

                  The insert is use to insert a data values into the row off a table .

   Syntax : Insert into table name value (value1 , value2 , .............., value n );
Example : Insert innto student values ( "X" , "BSC" , 17 - dec , bethamcherla , "Y" , "B.COM" , 18 - dec , bethamcherla );

(ii) Update :

                    This command is use to modify the values in the  table .

   Syntax : Update table name set ( column 1 = value 1);
Example : Update student set ( s.name = "Z");
 

(iii) Delete :

                   It is use to remove one (or) more rows from a table .

Syntax : Delete from table name ( where condition );
Example : Delete from student ( where S.name ='Y");


(3) Data control language : 

                                   The DCL commands are use to grant or take back authority from any database users . These command consist of following commands .
                           (i) Grant                       (ii) Revoke


 

 (i) Grant :

                      It is use to give user permissions to access into a database .

(ii) Revoke : 

                      This  command is use to take back permissions from the users .


(4) Transaction control language :

                                    The TCL command is use to save the data permanently and temperarly in he database  . The TCL command consist of commit , roll back , save point .



 (i) Commit :

                     This command is use to save data temperarly .

 (ii) Roll back :

                      This command  is use to undo transaction ( one-step backward ) .

(iii) Save point :

                      This command is  use to without rolling back entire transaction . That is ofter commit the data . The data is permanently save .



(5) Data quiry language :

                       This DQL command is use to select the data from the database . It uses only one command .

(i) Select : 

                       It is use to select the attribute based on that condition .

 Syntax : Select attribute name 
                from table name 
                where condition ;
Example : Select student name
                   from student    
                   where student group = MPC's


do u want read it in a notes given below

SQL COMMANDS : 
                               There are 5 types of SQL commands are there . They are :
(i) Data defination language (DDL)
(ii) Data manipulate language (DML)
(iii) Data control language (DCL)
(iv) Transaction control language (TCL)
(v) Data quiry language (DQL) 


(i) Data defination language (DDL) :
                               This DDL command is use to create a table , delete a table , altering a table .
DDL is consist of the following commands .
(a) create
(b) drop
(c) alter drop
(d) turncate

(a) create :  It is use to create a new table in the database .

Syntax :
             create table   table name (column1 database , column2 database , ..........);

(b) drop : It is use to delete both rows and columns in that table .

Syntax : 
             Drop  table name ;

(c) alter : It is use to alter the structure of the database . This changes could be either to modify the 
charecterecteristic of exiting attibutes (or) to add new attribute .

Syntax :
             Alter  table name ADD (column name , datatype);

(d) Turncate : This command is use to delete all the rows from the table .

Syntax :
             Turncate table  table name ;



(ii) Data manipulate language (DML) :
                                   This command is use to modify the database . It is responcible for all forms of 
changes in the database . The DML command are as follow :
(a) insert
(b) update
(c) delete

(a) insert :  The insert is use to insert a data values into the row of a table.

Syntax :
               Insert into table name values (value1 , value2 , ...... , valuen);

(b) update :  This command is use to modify the values in the table .
 
Syntax : 
             Update tablename set (column1 = value1);

(c) delete : It is use to remove one (or) more rows from the table .

Syntax :
             Delete from table name (where condition);



(iii) Data control language (DCL) :
                                      This command is use to grant or take back authority from any database users .
This command is consist of the following commands .
(a) grant
(b) remove

(a) grant :  This is use to give user permission to access into the database .

(b) remove :  This is use to take back permission from the user .



(iv) Transaction control language (TCL) :
                                         This command is use to save the data permanently or temparorly in the database .
The TCL consist of three commands . They are :
(a) commit
(b) roll back
(c) save point

(a) commit :  This command is use to save dta tempararly .

(b) roll back : This command is use to undo transaction (one step backward) .

(c) save point : This command is use to without comming rollback entire transaction that is ofter commit the
 data . The data is peramanently save .


(v) Data quirey language (DQL) : This DQL is use to select the data from the database . It is uses only one
 command that is "select" .
(a) select 

(a) select : it is use select the attributes based on that conditions .

Syntax :
               Select attribute name 
                from table name
                where condition ;


 TYPES  OF  RELATIONSHIPS  IN  DBMS


RELATIONSHIP :

                                      A Relationship is describes the relation between amonngg the entities . The relationship are denoted by diamond symbol (<>) . There are  four types of relationships are there :
(i) one-one relationship
(ii) one-many relationshiip
(iii) many-one relationship
(iv) many-maany relationship

(i) one-one relationship : 

                                     In this table each record of one table is related to only one record of  another table .

(ii) one-many relationship :

                                    In this relationship eacch record of one table is related to one (or) more than one record of another table .

(iii) many-one relationship :

                                  In this relationship morethan one record of one table can be related to only one record of another table .
 

 (iv) many-many relationship :

                                 In tthis relationship morethan one record of one table can be related to morrethan one record of another table .



 
  

Comments