SlideShare a Scribd company logo
3
Most read
5
Most read
9
Most read
SQL QUERIES 1.CREATE TABLE STATEMENT:  The create table statement is used to create the Database and also the tables in the database.The tables are divided into rows and columns.The columns consist of the attributes of the database and the rows consist of the values for these attributes. SYNTAX: CREATE TABLE "table_name" ("column 1" "data_type_for_column_1", "column 2" "data_type_for_column_2", ... )
2.ALTER TABLE STATEMENT Once a table is created in the database, there are many occasions where one may wish to change the structure of the table. For this purpose, the alter table statement is used. SYNTAX: ALTER TABLE "table_name" [alter specification]  3.THE INSERT STATEMENT The Sql insert into clause facilitates the process of inserting data into a SQL table. SYNTAX: 1.For inserting into one row
INSERT INTO "table_name" ("column1", "column2", ...) VALUES ("value1", "value2", ...) 2.For inserting into specified rows: INSERT INTO "table1" ("column1", "column2", ...) SELECT "column3", "column4", ... 4. THE SELECT STATEMENT The SQL select clause selects data from one or more database tables and/or views SYNTAX: SELECT "column_name" FROM "table_name"  5.THE WHERE CLAUSE  The SQL WHERE clause works in conjunction with other SQL clauses like SELECT, INSERT and UPDATE to specify a search condition for these statements.
SYNTAX: SELECT "column_name" FROM "table_name" WHERE "condition" 5.THE DISTINCT STATEMENT If we only want to select each DISTINCT element then this is easy to accomplish in SQL. All we need to do is to add DISTINCT after SELECT.  SYNTAX: SELECT DISTINCT "column_name" FROM "table_name" 6.THE UPDATE STATEMENT The SQL UPDATE clause serves to update data in database table.
SYNTAX: UPDATE Table1 SET Column1 = Value1, Column2 = Value2, … 7.THE DELETE STATEMENT The SQL DELETE clause is used to delete data from a database table. SYNTAX: DELETE FROM Table1 8.THE TRUNCATE STATEMENT The SQL TRUNCATE TABLE clause deletes all rows from a database table.  SYNTAX:
TRUNCATE TABLE table name 9.THE ORDERBY CLAUSE The SQL ORDER BY clause defines in what order to return a data set retrieved with a SQL SELECT statement. SYNTAX: SELECT "column_name" FROM "table_name" [WHERE "condition"] ORDER BY "column_name" [ASC, DESC] 10.SQL AGGREGATE FUNC TIONS SQL aggregate functions are used to sum, count, get the average, get the minimum and get the maximum values from a column or from a sub-set of column values.
11.SQL COUNT This allows us to COUNT up the number of row in a certain table. SYNTAX: SELECT COUNT("column_name") FROM "table_name" 12.SQL AVERAGE SQL uses the AVG() function to calculate the average of a column.  SYNTAX: SELECT AVG("column_name") FROM "table_name" 13.SQL MINIMUM SQL uses the MIN function to find the maximum value in a column. SYNTAX: SELECT MIN("column_name") FROM "table_name"
14.SQL MAXIMUM SQL uses the MAX function to find the maximum value in a column.  SYNTAX: SELECT MAX("column_name") FROM "table_name" 15.SQL SUM The SUM function is used to calculate the total for a column.  SYNTAX: SELECT SUM("column_name") FROM "table_name" 16.SQL Group BY STATEMENT The SQL GROUP BY clause is used along with the SQL aggregate functions and specifies the groups where selected rows are placed. WHEN one or more aggregate functions are presented in the SQL SELECT column list, the SQL GROUP BY clause calculates a summary value for each group.
SYNTAX: SELECT "column_name1", SUM("column_name2") FROM "table_name" GROUP BY "column_name1" 17.SQL HAVING STATEMENT The SQL HAVING keyword provides a search condition for a group or aggregate. The SQL HAVING clause works together with the SQL SELECT clause. The SQL HAVING clause is somewhat similar to the SQL WHERE clause, because it specifies a search condition. SYNTAX: SELECT "column_name1", SUM("column_name2") FROM "table_name" GROUP BY "column_name1" HAVING (arithmetic function condition)
18.SQL JOIN STATEMENT The SQL JOIN clause selects data from two or more tables tied together by matching table columns. SYNTAX: SELECT column1 from table1 join table2 on Condition 19.SQL UNION The SQL UNION clause merges the results of two or more SELECT SQL queries into one result set. When using SQL UNION, all the SQL expressions participating in the UNION must have the same structure 20.SQL TRIM The TRIM function in SQL is used to remove specified prefix or suffix from a string. The most common pattern being removed is white spaces. This function is called differently in different databases:
SYNTAX: TRIM([[LOCATION] [remstr] FROM ] str) 21.SQL LENGTH The Length function in SQL is used to get the length of a string. This function is called differently for the different databases:  SYNTAX: Length(str)

More Related Content

What's hot (20)

PPT
SQL Queries
Nilt1234
 
PPTX
SQL Basics
Hammad Rasheed
 
PPTX
Sql fundamentals
Ravinder Kamboj
 
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PDF
Sql tutorial
Rumman Ansari
 
PPT
Joins in SQL
Vigneshwaran Sankaran
 
PPTX
Basic SQL and History
SomeshwarMoholkar
 
PPTX
SQL Commands
Sachidananda M H
 
PPT
Sql operators & functions 3
Dr. C.V. Suresh Babu
 
PPT
Introduction to sql
VARSHAKUMARI49
 
PPTX
Sql commands
Pooja Dixit
 
PPT
Sql ppt
Anuja Lad
 
PDF
Sql commands
Prof. Dr. K. Adisesha
 
PPTX
Advanced SQL
Sabiha M
 
PPTX
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
PPTX
Joins And Its Types
Wings Interactive
 
PPTX
Sql queries presentation
NITISH KUMAR
 
PPTX
SQL Functions
ammarbrohi
 
SQL Queries
Nilt1234
 
SQL Basics
Hammad Rasheed
 
Sql fundamentals
Ravinder Kamboj
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Sql tutorial
Rumman Ansari
 
Joins in SQL
Vigneshwaran Sankaran
 
Basic SQL and History
SomeshwarMoholkar
 
SQL Commands
Sachidananda M H
 
Sql operators & functions 3
Dr. C.V. Suresh Babu
 
Introduction to sql
VARSHAKUMARI49
 
Sql commands
Pooja Dixit
 
Sql ppt
Anuja Lad
 
Sql commands
Prof. Dr. K. Adisesha
 
Advanced SQL
Sabiha M
 
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
Joins And Its Types
Wings Interactive
 
Sql queries presentation
NITISH KUMAR
 
SQL Functions
ammarbrohi
 

Viewers also liked (20)

PPTX
Running SQL Queries on the Moodle Database
College Development Network
 
PDF
Sql wksht-7
Mukesh Tekwani
 
PDF
Sql create table statement
Vivek Singh
 
PDF
Part 15 triggerr
Denny Yahya
 
PDF
Sql update statement
Vivek Singh
 
PDF
Sql delete, truncate, drop statements
Vivek Singh
 
PPT
Oracle Database Trigger
Eryk Budi Pratama
 
PPTX
Moodle external database enrolment
Yong Liu
 
ODP
Extending Moodle Reporting
moorejon
 
PPTX
Sql query performance analysis
Riteshkiit
 
PPTX
Sql server ___________session_19(triggers)
Ehtisham Ali
 
PPTX
6. triggers
Amrit Kaur
 
PDF
Sql insert statement
Vivek Singh
 
PDF
[Www.pkbulk.blogspot.com]dbms11
AnusAhmad
 
PPTX
SAP HANA - Manually to insert_data_table
Yasmin Ashraf
 
PPT
Sql – Structured Query Language
pandey3045_bit
 
PPT
Introduction to-sql
BG Java EE Course
 
RTF
Triggers-Sequences-SQL
Patrick Seery
 
PPT
Lecture 4. MS SQL. DML Triggers
Alexey Furmanov
 
PPT
SQL Tutorial - How To Create, Drop, and Truncate Table
1keydata
 
Running SQL Queries on the Moodle Database
College Development Network
 
Sql wksht-7
Mukesh Tekwani
 
Sql create table statement
Vivek Singh
 
Part 15 triggerr
Denny Yahya
 
Sql update statement
Vivek Singh
 
Sql delete, truncate, drop statements
Vivek Singh
 
Oracle Database Trigger
Eryk Budi Pratama
 
Moodle external database enrolment
Yong Liu
 
Extending Moodle Reporting
moorejon
 
Sql query performance analysis
Riteshkiit
 
Sql server ___________session_19(triggers)
Ehtisham Ali
 
6. triggers
Amrit Kaur
 
Sql insert statement
Vivek Singh
 
[Www.pkbulk.blogspot.com]dbms11
AnusAhmad
 
SAP HANA - Manually to insert_data_table
Yasmin Ashraf
 
Sql – Structured Query Language
pandey3045_bit
 
Introduction to-sql
BG Java EE Course
 
Triggers-Sequences-SQL
Patrick Seery
 
Lecture 4. MS SQL. DML Triggers
Alexey Furmanov
 
SQL Tutorial - How To Create, Drop, and Truncate Table
1keydata
 
Ad

Similar to Sql commands (20)

PDF
Sql basics v2
Yousuf Akhtar Sultan
 
PPTX
SQL
Shyam Khant
 
PPTX
Avinash database
avibmas
 
PPT
Sql Tutorials
Priyabrat Kar
 
PPTX
SQL : Structured Query Language
Abhishek Gautam
 
PPTX
Introduction to sql new
SANTOSH RATH
 
PDF
Intruduction to SQL.Structured Query Language(SQL}
IlgarKarimov3
 
PDF
SQL Fundamentals - Lecture 2
MuhammadWaheed44
 
PDF
SQL-Notes.pdf mba students database note
MrSushilMaurya
 
PPTX
Sql
Aman Lalpuria
 
PPT
15925 structured query
Universitas Bina Darma Palembang
 
PPT
Lec 1 = introduction to structured query language (sql)
Faisal Anwar
 
ODP
Sqlharshal
ashvinkokate
 
PDF
SQL Notes
JitendraYadav351971
 
PDF
Structure query language, database course
yunussufyan2024
 
PPT
Introduction to Structured Query Language (SQL).ppt
JohnnySebastian4
 
PPT
SQL. It education ppt for reference sql process coding
aditipandey498628
 
PPT
Introduction to Structured Query Language (SQL) (1).ppt
ComputerScienceDepar6
 
PPTX
Sql basics
Genesis Omo
 
Sql basics v2
Yousuf Akhtar Sultan
 
Avinash database
avibmas
 
Sql Tutorials
Priyabrat Kar
 
SQL : Structured Query Language
Abhishek Gautam
 
Introduction to sql new
SANTOSH RATH
 
Intruduction to SQL.Structured Query Language(SQL}
IlgarKarimov3
 
SQL Fundamentals - Lecture 2
MuhammadWaheed44
 
SQL-Notes.pdf mba students database note
MrSushilMaurya
 
15925 structured query
Universitas Bina Darma Palembang
 
Lec 1 = introduction to structured query language (sql)
Faisal Anwar
 
Sqlharshal
ashvinkokate
 
Structure query language, database course
yunussufyan2024
 
Introduction to Structured Query Language (SQL).ppt
JohnnySebastian4
 
SQL. It education ppt for reference sql process coding
aditipandey498628
 
Introduction to Structured Query Language (SQL) (1).ppt
ComputerScienceDepar6
 
Sql basics
Genesis Omo
 
Ad

More from Balakumaran Arunachalam (10)

PPT
Campus deck
Balakumaran Arunachalam
 
PPT
visible surface detection
Balakumaran Arunachalam
 
PPT
Greenhouse effect
Balakumaran Arunachalam
 
PPT
Career path non technical
Balakumaran Arunachalam
 
ODP
Installing and configuring apache
Balakumaran Arunachalam
 
ODP
Tags in html
Balakumaran Arunachalam
 
ODP
Sql installation
Balakumaran Arunachalam
 
ODP
Linux commands
Balakumaran Arunachalam
 
visible surface detection
Balakumaran Arunachalam
 
Greenhouse effect
Balakumaran Arunachalam
 
Career path non technical
Balakumaran Arunachalam
 
Installing and configuring apache
Balakumaran Arunachalam
 
Sql installation
Balakumaran Arunachalam
 
Linux commands
Balakumaran Arunachalam
 

Recently uploaded (20)

PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Difference between write and update in odoo 18
Celine George
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Controller Request and Response in Odoo18
Celine George
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 

Sql commands

  • 1. SQL QUERIES 1.CREATE TABLE STATEMENT: The create table statement is used to create the Database and also the tables in the database.The tables are divided into rows and columns.The columns consist of the attributes of the database and the rows consist of the values for these attributes. SYNTAX: CREATE TABLE "table_name" ("column 1" "data_type_for_column_1", "column 2" "data_type_for_column_2", ... )
  • 2. 2.ALTER TABLE STATEMENT Once a table is created in the database, there are many occasions where one may wish to change the structure of the table. For this purpose, the alter table statement is used. SYNTAX: ALTER TABLE "table_name" [alter specification] 3.THE INSERT STATEMENT The Sql insert into clause facilitates the process of inserting data into a SQL table. SYNTAX: 1.For inserting into one row
  • 3. INSERT INTO "table_name" ("column1", "column2", ...) VALUES ("value1", "value2", ...) 2.For inserting into specified rows: INSERT INTO "table1" ("column1", "column2", ...) SELECT "column3", "column4", ... 4. THE SELECT STATEMENT The SQL select clause selects data from one or more database tables and/or views SYNTAX: SELECT "column_name" FROM "table_name" 5.THE WHERE CLAUSE The SQL WHERE clause works in conjunction with other SQL clauses like SELECT, INSERT and UPDATE to specify a search condition for these statements.
  • 4. SYNTAX: SELECT "column_name" FROM "table_name" WHERE "condition" 5.THE DISTINCT STATEMENT If we only want to select each DISTINCT element then this is easy to accomplish in SQL. All we need to do is to add DISTINCT after SELECT. SYNTAX: SELECT DISTINCT "column_name" FROM "table_name" 6.THE UPDATE STATEMENT The SQL UPDATE clause serves to update data in database table.
  • 5. SYNTAX: UPDATE Table1 SET Column1 = Value1, Column2 = Value2, … 7.THE DELETE STATEMENT The SQL DELETE clause is used to delete data from a database table. SYNTAX: DELETE FROM Table1 8.THE TRUNCATE STATEMENT The SQL TRUNCATE TABLE clause deletes all rows from a database table. SYNTAX:
  • 6. TRUNCATE TABLE table name 9.THE ORDERBY CLAUSE The SQL ORDER BY clause defines in what order to return a data set retrieved with a SQL SELECT statement. SYNTAX: SELECT "column_name" FROM "table_name" [WHERE "condition"] ORDER BY "column_name" [ASC, DESC] 10.SQL AGGREGATE FUNC TIONS SQL aggregate functions are used to sum, count, get the average, get the minimum and get the maximum values from a column or from a sub-set of column values.
  • 7. 11.SQL COUNT This allows us to COUNT up the number of row in a certain table. SYNTAX: SELECT COUNT("column_name") FROM "table_name" 12.SQL AVERAGE SQL uses the AVG() function to calculate the average of a column. SYNTAX: SELECT AVG("column_name") FROM "table_name" 13.SQL MINIMUM SQL uses the MIN function to find the maximum value in a column. SYNTAX: SELECT MIN("column_name") FROM "table_name"
  • 8. 14.SQL MAXIMUM SQL uses the MAX function to find the maximum value in a column. SYNTAX: SELECT MAX("column_name") FROM "table_name" 15.SQL SUM The SUM function is used to calculate the total for a column. SYNTAX: SELECT SUM("column_name") FROM "table_name" 16.SQL Group BY STATEMENT The SQL GROUP BY clause is used along with the SQL aggregate functions and specifies the groups where selected rows are placed. WHEN one or more aggregate functions are presented in the SQL SELECT column list, the SQL GROUP BY clause calculates a summary value for each group.
  • 9. SYNTAX: SELECT "column_name1", SUM("column_name2") FROM "table_name" GROUP BY "column_name1" 17.SQL HAVING STATEMENT The SQL HAVING keyword provides a search condition for a group or aggregate. The SQL HAVING clause works together with the SQL SELECT clause. The SQL HAVING clause is somewhat similar to the SQL WHERE clause, because it specifies a search condition. SYNTAX: SELECT "column_name1", SUM("column_name2") FROM "table_name" GROUP BY "column_name1" HAVING (arithmetic function condition)
  • 10. 18.SQL JOIN STATEMENT The SQL JOIN clause selects data from two or more tables tied together by matching table columns. SYNTAX: SELECT column1 from table1 join table2 on Condition 19.SQL UNION The SQL UNION clause merges the results of two or more SELECT SQL queries into one result set. When using SQL UNION, all the SQL expressions participating in the UNION must have the same structure 20.SQL TRIM The TRIM function in SQL is used to remove specified prefix or suffix from a string. The most common pattern being removed is white spaces. This function is called differently in different databases:
  • 11. SYNTAX: TRIM([[LOCATION] [remstr] FROM ] str) 21.SQL LENGTH The Length function in SQL is used to get the length of a string. This function is called differently for the different databases: SYNTAX: Length(str)