SQL Basics Part 1 – DDL and DML statements

Hellow Friends….
This article is for those who think that they wanted to get starting with SQL.
Prerequisites Any One RDBMS Installed on your machine (like MS SQL, My SQL, Oracle, DB2, PostGRE etc.).

First of all, let’s know what is SQL is (Structured Query Language) all about. SQL used for performing operations on RDBMS (Relational Database Managment System like MS SQL, My SQL, Oracle, DB2, PostGRE etc.). (Hope you all know about RDBMS)

Now let us see how we do it.

With the help of commands, we perform operations on RDBMS those commands are called queries.
It is very simple to understand SQL, Total SQL runs with 2 types of commands

  • DDL Statements (Data Definition Language): It is used to retrieve, store, modify, delete, insert and update data in database most commonly used DDL Statements are.
    • CREATE: Is used to get the data from database tables with or with out condition in the query.( data type is an attribute that specifies the type of data that the object can hold: integer data, character data, monetary data, date and time data example employee ids are integer type names are string type, we have different data types supported in different RDBMS)
      Syntax: create table [tablename] as ([column1] [Datatype length] [constraint], [column2] [Datatype length] [constraint])
      Eg:       create table employee as (employeeId int not null, firstName varchar(25) not null, lastName varchar(10) not null)
    • ALTER: Alter is used to modifying the schema of data table
      Syntax:
      alter table  [tablename] [add | delete | alter] [ColumnName] [datatype] [constraint]
      Eg:      
      alter table employee alter column employeeId bigint not null) (changed from int to bigint)
    • DROP: Is used to delete any object from the database.
      Syntax
      drop table  [tablename]
      Eg:      
      drop table employee
  • DML Statements (Data Manipulation Language): It is used to create and modify the structure of database objects in database
    • SELECT: Is used to get the data from database tables with or with out condition in the query.
      Syntax : select [column1],[column2]…. from [tablename] [where condition]
      Eg:          select * from employee (* Represents all columns in the table)
    • INSERT: Us used to insert the data in database tables
      Syntax : insert into [tablename] (column1,column2,column3…) values (value1,value2,value3…)
      Eg:          insert into employee (employeeid,firstName,lastName) values (1,’ktbrain’,’blog’)
    • UPDATE: Is used to modify any data present in the database table. Using this we can update one more more no of column values
      Syntax : update [tablename] set column1=value1,column2=value2,column3=value3
      Eg:          update employee set employeeid = 2,firstName = ‘Some’,lastName=’thing’

That’s so simple to understand if you are familiar with these 2 type of statements then you there.. In the next article we try to work with clouses in RDBMS like where, group by, order by etc.

One thought on “SQL Basics Part 1 – DDL and DML statements

  • July 14, 2019 at 9:37 am
    Permalink

    This is a topic that’s near to my heart… Cheers! Exactly where are your contact details though?|

    Reply

Leave a Reply

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