SlideShare une entreprise Scribd logo
1  sur  20
SQL QUERIES
CREATING TABLE The SQL syntax for  CREATE TABLE  is CREATE TABLE "table_name" ("column 1" "data_type_for_column_1", "column 2" "data_type_for_column_2", ... )
ALTER TABLE ,[object Object]
The synatx is: ALTER TABLE[ owner_name ] table_name [ADD column_name datatype attributes] [MODIFY{column_name datatype |  column_constraint}]  ,[object Object],ALTER TABLE STUDENT ADD(PERCENTAGE NUMBER(5,2));
INSERT The  SQL INSERT INTO  clause facilitates the process of inserting data into a SQL table. Here is how you can insert a new row into the Weather table, using  SQL INSERT INTO: Insert into tablename (  fieldname, fieldname, fieldname )  values (  value, value, value );
SELECT The  SQL SELECT  clause selects data from one or more database tables and/or views. In its basic form the  SQL SELECT syntax looks like this: SELECT ColumnName1, ColumnName2, … FROM Table1
WHERE The  SQL WHERE  clause works in conjunction with other SQL clauses like SELECT, INSERT and UPDATE to specify a search condition for these statements. We are going to give an example of the SQL WHERE clause used along with the  SQL SELECT clause: SELECT AverageTemperature  FROM Weather WHERE City = 'New York'
DISTINCT The  SQL DISTINCT  clause works in conjunction with the SQL SELECT clause and selects only distinct (unique) data from a database table(s). Here is an example of SQL DISTINCT clause SELECT DISTINCT Column1 FROM Table1
UPDATE The  SQL UPDATE clause serves to update data in database table. The SQL UPDATE clause basic syntax looks like this: UPDATE Table1 SET Column1 = Value1, Column2 = Value2, …
DELETE The SQL DELETE   clause is used to delete data from a database table. The simplest  SQL DELETE syntax looks like this: DELETE FROM Table1
TRUNCATE The SQL TRUNCATE TABLE clause deletes all rows from a database table. Here is the  SQL TRUNCATE TABLE syntax: TRUNCATE TABLE Weather
ORDER BY The SQL ORDERBY clause defines in what order to return a data set retrieved with a SQL SELECT statement. Here is an example of using SQL ORDER BY to order the rows : Select  */fieldname<mask> ...   from  tablename   order by  fieldname ;
SQL AVERAGE To get the average temperature for the Weather table use the AVG SQL   aggregate function: SELECT AVG(AverageTemperature) FROM Weather
SQL MINIMUM To get the minimum value from a numeric table column, use the  SQL MIN  aggregate function: SELECT MIN(AverageTemperature) FROM Weather
SQL MAXIMUM To get the maximum value from a numeric table column, use  the SQL MAX  aggregate function: SELECT MAX(AverageTemperature) FROM Weather
SQL GROUP BY The SQL GROUP BY CITY 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 EX:Our task is to calculate the average temperature for each of the cities in the Weather table. Here is how to accomplish that using the SQL GROUP BY clause: SELECT City, AVG(AverageTemperature) FROM Weather GROUP BY City
SQL JOIN The SQL JOIN clause selects data from two or more tables tied together by matching table columns SELECT Weather.City, Weather.AverageTemperature, Weather.Date, State.State FROM Weather JOIN State ON Weather.City = State.City
AND/OR The Syntax for  AND/OR SELECT &quot;column_name&quot; FROM &quot;table_name&quot; WHERE &quot;simple condition&quot; {[AND|OR] &quot;simple condition&quot;}+
IN The Syntax for  IN  statement in SQL is SELECT &quot;column_name&quot; FROM &quot;table_name&quot; WHERE &quot;column_name&quot; IN ('value1', 'value2', ...)
BETWEEN The Syntax for  BETWEEN  statement in SQL is SELECT &quot;column_name&quot; FROM &quot;table_name&quot; WHERE &quot;column_name&quot; BETWEEN 'value1' AND 'value2'

Contenu connexe

Tendances

Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statements
Vivek Singh
 
MYSQL
MYSQLMYSQL
MYSQL
ARJUN
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sql
Sushil Mishra
 
7a advanced tsql
7a   advanced tsql7a   advanced tsql
7a advanced tsql
Nauman R
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
Reka
 

Tendances (19)

Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
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
 
Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statements
 
Sql
SqlSql
Sql
 
Les10
Les10Les10
Les10
 
MYSQL
MYSQLMYSQL
MYSQL
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
Les13
Les13Les13
Les13
 
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)
 
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
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sql
 
7a advanced tsql
7a   advanced tsql7a   advanced tsql
7a advanced tsql
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
My sql command line client
My sql command line clientMy sql command line client
My sql command line client
 
Les09
Les09Les09
Les09
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
Oracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |ThrissurOracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |Thrissur
 

En vedette

Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in Java
Jin Castor
 
Complete Sql Server querries
Complete Sql Server querriesComplete Sql Server querries
Complete Sql Server querries
Ibrahim Jutt
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
Achmad Solichin
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
Vikas Gupta
 

En vedette (20)

Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...
 
Sql
SqlSql
Sql
 
Daffodil International University. Object oriented programming JAVA if else s...
Daffodil International University. Object oriented programming JAVA if else s...Daffodil International University. Object oriented programming JAVA if else s...
Daffodil International University. Object oriented programming JAVA if else s...
 
Database - SQL Joins
Database - SQL JoinsDatabase - SQL Joins
Database - SQL Joins
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
Switch statement
Switch statementSwitch statement
Switch statement
 
Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)
 
The Switch Statement in java
The Switch Statement in javaThe Switch Statement in java
The Switch Statement in java
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in Java
 
Complete Sql Server querries
Complete Sql Server querriesComplete Sql Server querries
Complete Sql Server querries
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
Database - Normalization
Database - NormalizationDatabase - Normalization
Database - Normalization
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 
Dml and ddl
Dml and ddlDml and ddl
Dml and ddl
 
DML Commands
DML CommandsDML Commands
DML Commands
 
SQL Data Manipulation
SQL Data ManipulationSQL Data Manipulation
SQL Data Manipulation
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes
 
MySQL
MySQLMySQL
MySQL
 

Similaire à Prabu's sql quries

Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
Belle Wx
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
sagaroceanic11
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 

Similaire à Prabu's sql quries (20)

Babitha2 Mysql
Babitha2 MysqlBabitha2 Mysql
Babitha2 Mysql
 
Sql commands
Sql commandsSql commands
Sql commands
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
SQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint PresentationSQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint Presentation
 
Query
QueryQuery
Query
 
SQL
SQLSQL
SQL
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL Fundamentals
 
MySQL-commands.pdf
MySQL-commands.pdfMySQL-commands.pdf
MySQL-commands.pdf
 
SQL Query
SQL QuerySQL Query
SQL Query
 
SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for Beginners
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
1670595076250.pdf
1670595076250.pdf1670595076250.pdf
1670595076250.pdf
 
Cheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understandingCheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understanding
 
SQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdfSQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdf
 
SQL learning notes and all code.pdf
SQL learning notes and all code.pdfSQL learning notes and all code.pdf
SQL learning notes and all code.pdf
 
Sql basics v2
Sql basics v2Sql basics v2
Sql basics v2
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
SQL report
SQL reportSQL report
SQL report
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Prabu's sql quries

  • 2. CREATING TABLE The SQL syntax for CREATE TABLE is CREATE TABLE &quot;table_name&quot; (&quot;column 1&quot; &quot;data_type_for_column_1&quot;, &quot;column 2&quot; &quot;data_type_for_column_2&quot;, ... )
  • 3.
  • 4.
  • 5. INSERT The SQL INSERT INTO clause facilitates the process of inserting data into a SQL table. Here is how you can insert a new row into the Weather table, using SQL INSERT INTO: Insert into tablename ( fieldname, fieldname, fieldname ) values ( value, value, value );
  • 6. SELECT The SQL SELECT clause selects data from one or more database tables and/or views. In its basic form the SQL SELECT syntax looks like this: SELECT ColumnName1, ColumnName2, … FROM Table1
  • 7. WHERE The SQL WHERE clause works in conjunction with other SQL clauses like SELECT, INSERT and UPDATE to specify a search condition for these statements. We are going to give an example of the SQL WHERE clause used along with the SQL SELECT clause: SELECT AverageTemperature FROM Weather WHERE City = 'New York'
  • 8. DISTINCT The SQL DISTINCT clause works in conjunction with the SQL SELECT clause and selects only distinct (unique) data from a database table(s). Here is an example of SQL DISTINCT clause SELECT DISTINCT Column1 FROM Table1
  • 9. UPDATE The SQL UPDATE clause serves to update data in database table. The SQL UPDATE clause basic syntax looks like this: UPDATE Table1 SET Column1 = Value1, Column2 = Value2, …
  • 10. DELETE The SQL DELETE clause is used to delete data from a database table. The simplest SQL DELETE syntax looks like this: DELETE FROM Table1
  • 11. TRUNCATE The SQL TRUNCATE TABLE clause deletes all rows from a database table. Here is the SQL TRUNCATE TABLE syntax: TRUNCATE TABLE Weather
  • 12. ORDER BY The SQL ORDERBY clause defines in what order to return a data set retrieved with a SQL SELECT statement. Here is an example of using SQL ORDER BY to order the rows : Select */fieldname<mask> ... from tablename order by fieldname ;
  • 13. SQL AVERAGE To get the average temperature for the Weather table use the AVG SQL aggregate function: SELECT AVG(AverageTemperature) FROM Weather
  • 14. SQL MINIMUM To get the minimum value from a numeric table column, use the SQL MIN aggregate function: SELECT MIN(AverageTemperature) FROM Weather
  • 15. SQL MAXIMUM To get the maximum value from a numeric table column, use the SQL MAX aggregate function: SELECT MAX(AverageTemperature) FROM Weather
  • 16. SQL GROUP BY The SQL GROUP BY CITY 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 EX:Our task is to calculate the average temperature for each of the cities in the Weather table. Here is how to accomplish that using the SQL GROUP BY clause: SELECT City, AVG(AverageTemperature) FROM Weather GROUP BY City
  • 17. SQL JOIN The SQL JOIN clause selects data from two or more tables tied together by matching table columns SELECT Weather.City, Weather.AverageTemperature, Weather.Date, State.State FROM Weather JOIN State ON Weather.City = State.City
  • 18. AND/OR The Syntax for AND/OR SELECT &quot;column_name&quot; FROM &quot;table_name&quot; WHERE &quot;simple condition&quot; {[AND|OR] &quot;simple condition&quot;}+
  • 19. IN The Syntax for IN statement in SQL is SELECT &quot;column_name&quot; FROM &quot;table_name&quot; WHERE &quot;column_name&quot; IN ('value1', 'value2', ...)
  • 20. BETWEEN The Syntax for BETWEEN statement in SQL is SELECT &quot;column_name&quot; FROM &quot;table_name&quot; WHERE &quot;column_name&quot; BETWEEN 'value1' AND 'value2'
  • 21. DROP The Syntax for DROP statement in SQL is DROP TABLE &quot;table_name&quot;