SQL
  Structured Query Language
SQL is language use for creating, accessing and
manipulating database systems. SQL statements are used
to retrieve and update data in a database. SQL works with
database programs like MS Access, DB2, Informix, MS SQL
Server, Oracle, Sybase, etc.

Database is collection of data Stored in table format.
Each table is identified by a name . Tables contain records
(rows) and columns.
Below is an example of a table called “employee":
     Id              Name            Sal
     1               Aditya          25000
     2               Vaidehi         17000
For Performing Operations on the data stored in
tables different commands are available in sql.
SQL commands are categorized in different groups

DDL : Data Definition Language
DML: Data Manipulation Language
TCL : Transaction Control Language
DATA DEFINITION LANGUAGE(DDL)
DDL include three commands

•CREATE - Creates a new database table or object.
• ALTER - Alters (changes) a database table or Object
          We can Add ,Modify and Drop column
• DROP - Deletes a database table or Object
Create
Syntax:
Create table table_name( column1 datatype(size),
                         column2 datatype(size),
                          .
                          .
                        columnn datatype(size));

Example:
Create table Employee(id number(3),
                       name varchar2(10),
                       salary number(10));
EFFECT OF CREATE COMMAND
     Id        Name        salary
Alter
Syntax:
          Alter table table_name
          ADD/MODIFY/DROP (column specification);



Example
 Alter table employee Add (Address varchar2(10));
 Alter table employee modify(Address varchar2(12));
 Alter table employee Drop(Adress );
EFFECT OF ALTER COMMAND
      ID                NAME             SALARY




   Alter table employee Add (Address varchar2(10));
     ID          NAME          SALARY      ADDRESS



   Alter table employee Drop(Address );

     ID              NAME               SALARY
Drop
Syntax:
Drop table table_name;

Example:
Drop table employee;
DATA MANIPULATION LANGUAGE (DML)

 Data Manipulation Language (DML) include
select,update,delete,insert:

   •SELECT - Use for retrieving data from a database table
   •UPDATE – Use for updating data in a database table
   •DELETE – Use for deletes data from a database table
   •INSERT - Use for inserts new data into a database table
SELECT STATMENT

Syntax

Select * or column1,column2..column n from table_name
[where condition];


Example
Select * from employee;

Select name from employee;
INSERT STATMENT
Syntax
INSERT INTO table_name[(column1,column2,…)]
                       VALUES (value1, value2,....) ;


Example;
Insert into emp(id,name,salary)values(101,’Aditya’,100000);

           Id             Name            Sal
           1              Aditya          100000
           2              Vaidehi         17000
UPDATE STATMENT
Syntax
         UPDATE table_name
         SET column_name = new_value
         WHERE column_name = some_value;
Example:
  update emp
   set salary=50000
  where id=101;
     Id               Name        Sal
     101              Aditya      50000
     102              Vaidehi     17000
DELETE STATMENT


Syntax
         DELETE FROM table_name
         [WHERE column_name = some_value ]
Example:
  delete from employee
 where id=101;

     Id              Name          Sal
     102             Vaidehi       17000
Thank you!

Sqlbysandeep

  • 1.
    SQL StructuredQuery Language
  • 2.
    SQL is languageuse for creating, accessing and manipulating database systems. SQL statements are used to retrieve and update data in a database. SQL works with database programs like MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase, etc. Database is collection of data Stored in table format. Each table is identified by a name . Tables contain records (rows) and columns. Below is an example of a table called “employee": Id Name Sal 1 Aditya 25000 2 Vaidehi 17000
  • 3.
    For Performing Operationson the data stored in tables different commands are available in sql. SQL commands are categorized in different groups DDL : Data Definition Language DML: Data Manipulation Language TCL : Transaction Control Language
  • 4.
    DATA DEFINITION LANGUAGE(DDL) DDLinclude three commands •CREATE - Creates a new database table or object. • ALTER - Alters (changes) a database table or Object We can Add ,Modify and Drop column • DROP - Deletes a database table or Object
  • 5.
    Create Syntax: Create table table_name(column1 datatype(size), column2 datatype(size), . . columnn datatype(size)); Example: Create table Employee(id number(3), name varchar2(10), salary number(10));
  • 6.
    EFFECT OF CREATECOMMAND Id Name salary
  • 7.
    Alter Syntax: Alter table table_name ADD/MODIFY/DROP (column specification); Example Alter table employee Add (Address varchar2(10)); Alter table employee modify(Address varchar2(12)); Alter table employee Drop(Adress );
  • 8.
    EFFECT OF ALTERCOMMAND ID NAME SALARY Alter table employee Add (Address varchar2(10)); ID NAME SALARY ADDRESS Alter table employee Drop(Address ); ID NAME SALARY
  • 9.
  • 10.
    DATA MANIPULATION LANGUAGE(DML) Data Manipulation Language (DML) include select,update,delete,insert: •SELECT - Use for retrieving data from a database table •UPDATE – Use for updating data in a database table •DELETE – Use for deletes data from a database table •INSERT - Use for inserts new data into a database table
  • 11.
    SELECT STATMENT Syntax Select *or column1,column2..column n from table_name [where condition]; Example Select * from employee; Select name from employee;
  • 12.
    INSERT STATMENT Syntax INSERT INTOtable_name[(column1,column2,…)] VALUES (value1, value2,....) ; Example; Insert into emp(id,name,salary)values(101,’Aditya’,100000); Id Name Sal 1 Aditya 100000 2 Vaidehi 17000
  • 13.
    UPDATE STATMENT Syntax UPDATE table_name SET column_name = new_value WHERE column_name = some_value; Example: update emp set salary=50000 where id=101; Id Name Sal 101 Aditya 50000 102 Vaidehi 17000
  • 14.
    DELETE STATMENT Syntax DELETE FROM table_name [WHERE column_name = some_value ] Example: delete from employee where id=101; Id Name Sal 102 Vaidehi 17000
  • 15.