SlideShare una empresa de Scribd logo
1 de 6
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];

Más contenido relacionado

La actualidad más candente

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 deleteAl-Mamun Sarkar
 
Avinash database
Avinash databaseAvinash database
Avinash databaseavibmas
 
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 databaseHemant 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
 
Oracle SQL DML Statements
Oracle SQL DML StatementsOracle SQL DML Statements
Oracle SQL DML StatementsA Data Guru
 
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 CommandsShrija Madhu
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries LectureFelipe Costa
 

La actualidad más candente (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 a COMPUTERS SQL

STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESarithaDhanapal
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptDrRShaliniVISTAS
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleSteve Johnson
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxEliasPetros
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxEliasPetros
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar 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
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languagesDivyaKS12
 
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
 

Similar a 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
 

Más de Rc Os

Dove
DoveDove
DoveRc Os
 
CLASS IV ENGLISH
CLASS IV ENGLISHCLASS IV ENGLISH
CLASS IV ENGLISHRc Os
 
CLASS 4 MATHS
CLASS 4 MATHSCLASS 4 MATHS
CLASS 4 MATHSRc Os
 
CLASS 4 MATHS
CLASS 4 MATHSCLASS 4 MATHS
CLASS 4 MATHSRc 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 MATHSRc Os
 
Changing times.
Changing times.Changing times.
Changing times.Rc Os
 
3 class english
3 class english3 class english
3 class englishRc 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
RainbowRc Os
 
NUMBERS 1 TO 20
NUMBERS 1 TO 20NUMBERS 1 TO 20
NUMBERS 1 TO 20Rc Os
 
TIME
TIMETIME
TIMERc Os
 
MEASUREMENTS
MEASUREMENTSMEASUREMENTS
MEASUREMENTSRc Os
 
DATA HANDLING
DATA HANDLINGDATA HANDLING
DATA HANDLINGRc Os
 
patterns
 patterns patterns
patternsRc Os
 
Who is heavier
Who is heavierWho is heavier
Who is heavierRc Os
 
Sundari
SundariSundari
SundariRc Os
 
The tiger and the mosquitoe
The tiger and the mosquitoeThe tiger and the mosquitoe
The tiger and the mosquitoeRc Os
 
Photoshop
PhotoshopPhotoshop
PhotoshopRc Os
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database Rc Os
 

Más de 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
 

Último

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Último (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

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];