Introduction of SQL

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

INTRODUCTION OF

SQL
What is SQL?
 SQL stands for Structured Query Language

 SQL lets you access and manipulate databases

 SQL became a standard of the American National Standards


Institute (ANSI) in 1986, and of the International
Organization for Standardization (ISO) in 1987

What Can SQL do?


 SQL can execute queries against a database

 SQL can retrieve data from a database

 SQL can insert records in a database

 SQL can update records in a database

 SQL can delete records from a database

 SQL can create new databases

 SQL can create new tables in a database

 SQL can create stored procedures in a database

 SQL can create views in a database

 SQL can set permissions on tables, procedures, and views


SQL is a Standard - BUT....
Although SQL is an ANSI/ISO standard, there are different
versions of the SQL language.

However, to be compliant with the ANSI standard, they all


support at least the major commands (such as SELECT, UPDATE,
DELETE, INSERT, WHERE) in a similar manner.

RDBMS
RDBMS stands for Relational Database Management System.

RDBMS is the basis for SQL, and for all modern database systems
such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft
Access.

The data in RDBMS is stored in database objects called tables. A


table is a collection of related data entries and it consists of
columns and rows.

SQL STATEMENT

DDL DML

DDL: - DDL refers to "Data Definition Language", a subset of SQL


statements that change the structure of the database schema in some way,
typically by creating, deleting, or modifying schema objects such as
databases, tables, and views. Most Impala DDL statements start with the
keywords CREATE, DROP, or ALTER.

DDL
CREATE ALTER

DROP

 CREATE TABLE :- The CREATE TABLE command creates a new table


in the database.

 CREATE TABLE SYNTAX

Create table table_name (column_name1, column_name2 ,…);

 EXAMPLE OF CREATE TABLE :-


CREATE TABLE STUDENT (NAME varchar(20),ROLL_NO int ,student_ID
varchar(20),CLASS varchar(20),FATHER_NAME varchar(20),PH_NO int);
 DROP TABLE:- The DROP TABLE statement is used to drop an existing
table in a database.

 DROP TABLE SYNTAX


Alter table table_name
Drop column_name;

 EXAMPLE OF DROP TABLE :- ALTER TABLE student


DROP section;
 ALTER TABLE :- The ALTER TABLE statement is used to add, delete,
or modify columns in an existing table.

The ALTER TABLE statement is also used to add and drop various
constraints on an existing table.

 ALTER TABLE SYNTAX

Alter table table_name add (column_name);

 EXAMPLE OF ALTER TABLE:- ALTER TABLE student ADD


(section char(10));
DML: - DML stands for Data Manipulation Language. The SQL
statements that are in the DML class are INSERT, UPDATE , SELECT and
DELETE. ... Data Definition Languages (DDL) is used to define the
database structure. Any CREATE, DROP and ALTER commands are
examples of DDL SQL statements.

DML
INSERT DELETE

UPDATE SELECT

 INSERT TABLE :- It is possible to write the INSERT INTO statement in


two ways.

The first way specifies both the column names and the values to be
inserted.

 INSERT TABLE SYNTAX

Insert into table_name values (value1,value2….);

 EXAMPLE OF INSERT TABLE :-

INSERT INTO STUDENT


VALUES (“Sarita”,19367,1102,”second_year”,”mr_Tekram”,12345);
 UPDATE TABLE :- The UPDATE statement is used to modify the
existing records in a table.

 UPDATE TABLE SYNTAX

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

 EXAMPLE OF INSERT TABLE :- UPDATE Student


SET Section = “A”, WHERE ROLL_NO=19368;
 SELECT TABLE:- The SELECT statement is used to select data from a
database.

The data returned is stored in a result table, called the result-set.

 SELECT TABLE SYNTAX


SELECT column1, column2, ...
FROM table_name;

 EXAMPLE OF SELECT TABLE :- SELECT name


FROM Student ;

 DELETE TABLE:- The DELETE statement is used to delete existing


records in a table.

 DELETE TABLE SYNTAX

DELETE FROM table_name WHERE condition;

 EXAMPLE OF DELETE TABLE :-


DELETE FROM Student WHERE name='Sheetal';

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy