SlideShare a Scribd company logo
Structured Query Language
Introduction
The Structured Query Language (SQL) is a non-procedural programming
language used for storing, manipulatingand retrieving the data in a databases.
SQL was the first commercial language introduced for E.F
Codd's Relational model.
Data Definition Language
It is used to define the structure of tables in the database.
CREATE, ALTER, USE, DROP, TRUNCATE COMMAND
Data Manipulation Language
It is used for managing data in database.
SELECT, UPDATE, DELETE, INSERT COMMAND
Data Control Language
It is used to control user access in a database.
GRANT, REVOKE COMMAND
Grant: Gives user access privileges to database.
Revoke: Take back permissions from user.
It is used to manage transactions in database.
COMMIT, ROLLBACK, SAVEPOINT COMMAND
The COMMIT command is the transactional command used to save changes
invoked by a transaction to the database.
The ROLLBACK command is the transactional command used to undo
transactions that have not already been saved to the database.
The SAVEPOINT command is used to temporarily save a transaction so that
you can rollback to that point whenever necessary.
SQL – CREATE DATABASE:
Syntax:
SQL> CREATE DATABASE database_name;
Example:
SQL> CREATE DATABASE STUDENT_DB;
SQL> SHOW DATABASES;
SQL – SELECT DATABASE:
The SQL USE statement is used to select any existing database in the SQL
schema.
SQL> USE database_name;
SQL – DROP DATABASE:
This statement is used to drop an existing SQL Database.
Syntax:
SQL> DROP DATABASE database_name;
Example:
SQL> DROP DATABASE STUDENT_DB;
SQL – CREATE TABLE:
Syntax:
SQL> CREATE TABLE table_name(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size)
);
Example:
SQL> CREATE TABLE student(
Student_ID int,
Student_namevarchar (255),
City varchar (255),
Marks int
);
SQL – ALTER TABLE:
TO ADD COLUMN
Syntax:
ALTER TABLE table_name ADDcolumn_name datatype;
TO DROP COLUMN
Syntax:
ALTER TABLE table_name DROP COLUMNcolumn_name;
TO ADD NOT NULL
Syntax:
ALTER TABLE table_name MODIFYcolumn_name datatype NOT NULL;
TO ADD PRIMARY KEY
Syntax:
ALTER TABLE table_name ADDPRIMARYKEY(column);
How to check whether a table exists & the property or description of a table?
Syntax:
SQL> DESC table_name;
Example:
SQL> DESC student;
SQL – DROP TABLE:
This statementis used to drop an existing table in database.
SQL DROP statement is used to delete or remove indexes from a table in the
database.
Syntax:
SQL> DROP TABLE table_name;
Example:
SQL> DROP TABLE student;
SQL – TRUNCATE TABLE:
The SQL TRUNCATE TABLE command is used to delete complete data from an
existing table.
You can also use DROP TABLE command to delete complete table but it would
remove complete table structure from the database and you would need to re-
create this table once again if you wish you store some data.
Syntax:
TRUNCATE TABLE table_name;
SQL – SELECT TABLE:
This statementis used to select data from a database.
Syntax:
SELECT column-name1,column-name2,column-name(s)from table_name;
Example:
SELECT studentid,studentnamefrom student;
A special character asterisk * is used to address all the data (belonging to all
columns) in a query.
Syntax:
SELECT * from table_name;
Example:
SELECT * from student;
SQL – INSERT TABLE:
Syntax:
INSERT INTO table_name (column-names)
VALUES (values);
SQL – DELETE TABLE:
Syntax:
DELETE FROM table_name
WHERE [condition];
The statement SQL DELETE ALL ROWS is used to delete all rows from the
table.
Syntax:
DELETE FROM table_name;
SQL – UPDATE TABLE:
Syntax:
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
CONSTRAINT
NOT NULL CONSTRAINT
Syntax:
CREATE TABLE table_name(
column_name1 data_type(size) NOT NULL,
column_name2 data_type(size) NOT NULL,
column_name3 data_type(size)
);
PRIMARY KEY CONSTRAINT
Syntax:
CREATE TABLE table_name(
column_name1 data_type(size) PRIMARY KEY,
column_name2 data_type(size) NOT NULL,
column_name3 data_type(size)
);
UNIQUE CONSTRAINT
Syntax:
CREATE TABLE table_name(
column_name1 data_type(size) NOT NULL UNIQUE,
column_name2 data_type(size) NOT NULL,
column_name3 data_type(size)
);
CHECK CONSTRAINT
Syntax:
CREATE TABLE table_name(
column_name1 INTEGER AUTOINCREMENT,
column_name2 data_type(size),
column_name3 data_type(size) DEFAULT value,
CHECK column_name1 condition
);
DEFAULT CONSTRAINT
Syntax:
CREATE TABLE table_name(
column_name1 INTEGER AUTOINCREMENT,
column_name2 data_type(size),
column_name3 data_type(size) DEFAULT value
);
CLAUSE
WHERE CLAUSE
Syntax:
SELECT column_name1, column_name2
FROM table_name
WHERE [condition];
ORDER BY CLAUSE
Syntax;
SELECT column_name1, column_name2
FROM table_name
ORDER BY column_name1,
column_name2, ASC;
SELECT column_name1,
column_name2
FROM table_name
ORDER BY column_name1,
column_name2, DESC;
GROUP BY CLAUSE
Syntax;
SELECT column_name, function (column_name)
FROM table_name
WHERE condition
GROUP BY column_name;
LIKE CLAUSE
Syntax:
SELECT column_name1, column_name2
FROM table_name
WHERE column_name1 LIKE ‘A%’;
Syntax:
SELECT column_name1, column_name2
FROM table_name
WHERE column_name1 LIKE ‘A_’;
AND/OR OPERATOR
Syntax:
SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] AND [condition2]...AND [conditionN];
SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] OR [condition2]...OR [conditionN];

More Related Content

What's hot

DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
Abdul Rehman
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
Avinash database
Avinash databaseAvinash database
Avinash databaseavibmas
 
8. sql
8. sql8. sql
8. sql
khoahuy82
 
Sql commands
Sql commandsSql commands
Sql commands
Mohd Tousif
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
Sharad Dubey
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
Vikas Gupta
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in database
Hemant Suthar
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
Sql basics
Sql basicsSql basics
Sql basics
Aman Lalpuria
 
Oracle SQL DML Statements
Oracle SQL DML StatementsOracle SQL DML Statements
Oracle SQL DML Statements
A Data Guru
 
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commandsBelle Wx
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsAshwin Dinoriya
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
Felipe Costa
 

What's hot (20)

DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Avinash database
Avinash databaseAvinash database
Avinash database
 
8. sql
8. sql8. sql
8. sql
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in database
 
Ddl commands
Ddl commandsDdl commands
Ddl commands
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
 
Sql basics
Sql basicsSql basics
Sql basics
 
Oracle SQL DML Statements
Oracle SQL DML StatementsOracle SQL DML Statements
Oracle SQL DML Statements
 
Sql DML
Sql DMLSql DML
Sql DML
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
Sql commands
Sql commandsSql commands
Sql commands
 

Similar to COMPUTERS SQL

STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
SarithaDhanapal
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
SQL
SQLSQL
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
Steve Johnson
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
sql.pptx
sql.pptxsql.pptx
sql.pptx
slavskrillex
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
EliasPetros
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
EliasPetros
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
Abrar ali
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
To Sum It Up
 
Sql12
Sql12Sql12
Sql12
tacex1
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
DivyaKS12
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinhwebhostingguy
 
Creating a database
Creating a databaseCreating a database
Creating a databaseRahul Gupta
 
Module 3
Module 3Module 3
Module 3
cs19club
 

Similar to COMPUTERS SQL (20)

STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL
SQLSQL
SQL
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
sql.pptx
sql.pptxsql.pptx
sql.pptx
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
Sql12
Sql12Sql12
Sql12
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
Creating a database
Creating a databaseCreating a database
Creating a database
 
Module 3
Module 3Module 3
Module 3
 

More from Rc Os

Dove
DoveDove
Dove
Rc Os
 
CLASS IV ENGLISH
CLASS IV ENGLISHCLASS IV ENGLISH
CLASS IV ENGLISH
Rc Os
 
CLASS 4 MATHS
CLASS 4 MATHSCLASS 4 MATHS
CLASS 4 MATHS
Rc Os
 
CLASS 4 MATHS
CLASS 4 MATHSCLASS 4 MATHS
CLASS 4 MATHS
Rc Os
 
CLASS III MATHS
CLASS III MATHS CLASS III MATHS
CLASS III MATHS
Rc Os
 
CLASS III MATHS
CLASS III MATHSCLASS III MATHS
CLASS III MATHS
Rc Os
 
Changing times.
Changing times.Changing times.
Changing times.
Rc Os
 
3 class english
3 class english3 class english
3 class english
Rc Os
 
Clss ii english-the mouse---
Clss ii  english-the mouse---Clss ii  english-the mouse---
Clss ii english-the mouse---
Rc Os
 
Rainbow
RainbowRainbow
Rainbow
Rc Os
 
NUMBERS 1 TO 20
NUMBERS 1 TO 20NUMBERS 1 TO 20
NUMBERS 1 TO 20
Rc Os
 
TIME
TIMETIME
TIME
Rc Os
 
MEASUREMENTS
MEASUREMENTSMEASUREMENTS
MEASUREMENTS
Rc Os
 
DATA HANDLING
DATA HANDLINGDATA HANDLING
DATA HANDLING
Rc Os
 
patterns
 patterns patterns
patterns
Rc Os
 
Who is heavier
Who is heavierWho is heavier
Who is heavier
Rc Os
 
Sundari
SundariSundari
Sundari
Rc Os
 
The tiger and the mosquitoe
The tiger and the mosquitoeThe tiger and the mosquitoe
The tiger and the mosquitoe
Rc Os
 
Photoshop
PhotoshopPhotoshop
Photoshop
Rc Os
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
Rc Os
 

More from Rc Os (20)

Dove
DoveDove
Dove
 
CLASS IV ENGLISH
CLASS IV ENGLISHCLASS IV ENGLISH
CLASS IV ENGLISH
 
CLASS 4 MATHS
CLASS 4 MATHSCLASS 4 MATHS
CLASS 4 MATHS
 
CLASS 4 MATHS
CLASS 4 MATHSCLASS 4 MATHS
CLASS 4 MATHS
 
CLASS III MATHS
CLASS III MATHS CLASS III MATHS
CLASS III MATHS
 
CLASS III MATHS
CLASS III MATHSCLASS III MATHS
CLASS III MATHS
 
Changing times.
Changing times.Changing times.
Changing times.
 
3 class english
3 class english3 class english
3 class english
 
Clss ii english-the mouse---
Clss ii  english-the mouse---Clss ii  english-the mouse---
Clss ii english-the mouse---
 
Rainbow
RainbowRainbow
Rainbow
 
NUMBERS 1 TO 20
NUMBERS 1 TO 20NUMBERS 1 TO 20
NUMBERS 1 TO 20
 
TIME
TIMETIME
TIME
 
MEASUREMENTS
MEASUREMENTSMEASUREMENTS
MEASUREMENTS
 
DATA HANDLING
DATA HANDLINGDATA HANDLING
DATA HANDLING
 
patterns
 patterns patterns
patterns
 
Who is heavier
Who is heavierWho is heavier
Who is heavier
 
Sundari
SundariSundari
Sundari
 
The tiger and the mosquitoe
The tiger and the mosquitoeThe tiger and the mosquitoe
The tiger and the mosquitoe
 
Photoshop
PhotoshopPhotoshop
Photoshop
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 

COMPUTERS SQL

  • 1. Structured Query Language Introduction The Structured Query Language (SQL) is a non-procedural programming language used for storing, manipulatingand retrieving the data in a databases. SQL was the first commercial language introduced for E.F Codd's Relational model. Data Definition Language It is used to define the structure of tables in the database. CREATE, ALTER, USE, DROP, TRUNCATE COMMAND Data Manipulation Language It is used for managing data in database. SELECT, UPDATE, DELETE, INSERT COMMAND Data Control Language It is used to control user access in a database. GRANT, REVOKE COMMAND Grant: Gives user access privileges to database. Revoke: Take back permissions from user. It is used to manage transactions in database. COMMIT, ROLLBACK, SAVEPOINT COMMAND The COMMIT command is the transactional command used to save changes invoked by a transaction to the database. The ROLLBACK command is the transactional command used to undo transactions that have not already been saved to the database. The SAVEPOINT command is used to temporarily save a transaction so that you can rollback to that point whenever necessary. SQL – CREATE DATABASE: Syntax: SQL> CREATE DATABASE database_name; Example: SQL> CREATE DATABASE STUDENT_DB; SQL> SHOW DATABASES;
  • 2. SQL – SELECT DATABASE: The SQL USE statement is used to select any existing database in the SQL schema. SQL> USE database_name; SQL – DROP DATABASE: This statement is used to drop an existing SQL Database. Syntax: SQL> DROP DATABASE database_name; Example: SQL> DROP DATABASE STUDENT_DB; SQL – CREATE TABLE: Syntax: SQL> CREATE TABLE table_name( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size) ); Example: SQL> CREATE TABLE student( Student_ID int, Student_namevarchar (255), City varchar (255), Marks int ); SQL – ALTER TABLE: TO ADD COLUMN Syntax: ALTER TABLE table_name ADDcolumn_name datatype; TO DROP COLUMN
  • 3. Syntax: ALTER TABLE table_name DROP COLUMNcolumn_name; TO ADD NOT NULL Syntax: ALTER TABLE table_name MODIFYcolumn_name datatype NOT NULL; TO ADD PRIMARY KEY Syntax: ALTER TABLE table_name ADDPRIMARYKEY(column); How to check whether a table exists & the property or description of a table? Syntax: SQL> DESC table_name; Example: SQL> DESC student; SQL – DROP TABLE: This statementis used to drop an existing table in database. SQL DROP statement is used to delete or remove indexes from a table in the database. Syntax: SQL> DROP TABLE table_name; Example: SQL> DROP TABLE student; SQL – TRUNCATE TABLE: The SQL TRUNCATE TABLE command is used to delete complete data from an existing table. You can also use DROP TABLE command to delete complete table but it would remove complete table structure from the database and you would need to re- create this table once again if you wish you store some data. Syntax: TRUNCATE TABLE table_name; SQL – SELECT TABLE: This statementis used to select data from a database. Syntax: SELECT column-name1,column-name2,column-name(s)from table_name; Example:
  • 4. SELECT studentid,studentnamefrom student; A special character asterisk * is used to address all the data (belonging to all columns) in a query. Syntax: SELECT * from table_name; Example: SELECT * from student; SQL – INSERT TABLE: Syntax: INSERT INTO table_name (column-names) VALUES (values); SQL – DELETE TABLE: Syntax: DELETE FROM table_name WHERE [condition]; The statement SQL DELETE ALL ROWS is used to delete all rows from the table. Syntax: DELETE FROM table_name; SQL – UPDATE TABLE: Syntax: UPDATE table_name SET column1 = value1, column2 = value2...., columnN = valueN WHERE [condition]; CONSTRAINT NOT NULL CONSTRAINT Syntax: CREATE TABLE table_name( column_name1 data_type(size) NOT NULL, column_name2 data_type(size) NOT NULL, column_name3 data_type(size) ); PRIMARY KEY CONSTRAINT Syntax: CREATE TABLE table_name( column_name1 data_type(size) PRIMARY KEY, column_name2 data_type(size) NOT NULL,
  • 5. column_name3 data_type(size) ); UNIQUE CONSTRAINT Syntax: CREATE TABLE table_name( column_name1 data_type(size) NOT NULL UNIQUE, column_name2 data_type(size) NOT NULL, column_name3 data_type(size) ); CHECK CONSTRAINT Syntax: CREATE TABLE table_name( column_name1 INTEGER AUTOINCREMENT, column_name2 data_type(size), column_name3 data_type(size) DEFAULT value, CHECK column_name1 condition ); DEFAULT CONSTRAINT Syntax: CREATE TABLE table_name( column_name1 INTEGER AUTOINCREMENT, column_name2 data_type(size), column_name3 data_type(size) DEFAULT value ); CLAUSE WHERE CLAUSE Syntax: SELECT column_name1, column_name2 FROM table_name WHERE [condition]; ORDER BY CLAUSE Syntax; SELECT column_name1, column_name2 FROM table_name ORDER BY column_name1, column_name2, ASC; SELECT column_name1, column_name2 FROM table_name
  • 6. ORDER BY column_name1, column_name2, DESC; GROUP BY CLAUSE Syntax; SELECT column_name, function (column_name) FROM table_name WHERE condition GROUP BY column_name; LIKE CLAUSE Syntax: SELECT column_name1, column_name2 FROM table_name WHERE column_name1 LIKE ‘A%’; Syntax: SELECT column_name1, column_name2 FROM table_name WHERE column_name1 LIKE ‘A_’; AND/OR OPERATOR Syntax: SELECT column1, column2, columnN FROM table_name WHERE [condition1] AND [condition2]...AND [conditionN]; SELECT column1, column2, columnN FROM table_name WHERE [condition1] OR [condition2]...OR [conditionN];