0% found this document useful (0 votes)
12 views13 pages

Introduction To SQL

SQL

Uploaded by

kvmducs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views13 pages

Introduction To SQL

SQL

Uploaded by

kvmducs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

INTRODUCTION TO

SQL
SQL- Structured Query Language

 SQL is standard a language for creating and manipulating databases.


 It can retrieve data from a database through query processing.
 It can insert records in a database.
 It can update records in a database.
 It can create new databases and tables and modify existing ones.
 It allows modifying the security settings of the system.
 Advantages of SQL
 Ease of use.
 No coding required.
 SQL is not a case sensitive language.
 SQL can be linked to most of the other high level languages.
Classification of SQL Statements

SQL
COMMA
NDS

DDL DML DQL

Create
Insert
Alter Select
Update
Truncate
Delete
Drop
Data Definition Language (DDL)
Commands
 Permits database tables to be created or deleted.
 Defines keys, specifies links between tables and impose constraints
on the table.
DDL COMMANDS

DDL

CREATE ALTER SHOW


DROP USE

CREATE DROP DATABASE


DATABASE ADD
DROP TABLE
CREATE TABLE MODIFY
DROP
CHANGE
Examples of DDL Commands

 CREATE DATABASE : creates a new database.


 USE command: to select and open an existing database.
 SHOW command : to display all tables in an existing database.
 CREATE TABLE : creates a new table in an existing database.
 ALTER TABLE : modifies the structure of a table.
 DROP TABLE /DATABASE: deletes a table/database.
Data Manipulation Language (DML)
commands
Helps user to manipulates data. Several DML commands available are :
1. INSERT INTO command : To insert new data(record) into a table.
2. UPDATE command : To insert or change the data ( tuple) in a table ( not
modifying the data type of a column).
3. DELETE command : To delete data(tuple) from a table( not deleting a
column).
Data Query Language(DQL)
commands

 A query is a command given to get a desired result from the database


table.
 The SELECT command is used to query or retrieve data from a table
in the database.
 It is used to retrieve a subset of records from one or more tables.
 Syntax of SELECT command :
SELECT < column-list> from < table-name>;
Column list includes one or more columns from which data is retrieved.
SQL DATATYPES
Each column is assigned a data type which convey the kind of value that will be stored in the column.

INT
Numeric
FLOAT

MySQL CHAR
Data Types Non-numeric or VARCHA
String R

DATE

Date and Time TIME


Numeric Data types
INT : It stores positive whole numbers upto 11 digits and negative whole numbers upto 10
digits. The range of integer is from -2,147,483,648 to 1,147,483,647.
BIGINT : To store large integers.
FLOAT : Holds numbers with decimal point.

Non numeric (String) data types


CHAR(x) :
Fixed length string.
Stores ‘x’ number of characters in the string which has a fixed length.
A maximum 254 characters can be stored in a string.
The value of CHAR data type has to be enclosed in single quotes or double quotes.
VARCHAR(x):
Variable length string.
For example, address of a student can be declared as VARCHAR(25) to store the address up to 25
characters long.
VARCHAR will not leave unused spaces.
The value of CHAR data type has to be enclosed in single quotes or double quotes.
Date and Time

DATE :
Store date in ‘yyyy/mm/dd’ format or ‘yyyy-mm-dd’ format.
Stores year, month and date values.
Date values to be entered are to be enclosed in quotes.
TIME :
Store time in hh:mm:ss format.
Stores hour,minute and second values.
For example, time 12:30:45 where 12 means hours, 30 means minutes and
45 refers to seconds.
Slip Test

1. Write the full form of SQL.


2. Categorize the following into DDL and DML commands.
CREATE TABLE, UPDATE, INSERT, ALTER TABLE
3. What does DML stands for?
4. To store date of birth of a student, which data type will you select for
the column?
Home work

 Differentiate char and varchar data types.


 Differenetiate DDL and DML.

You might also like