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

PPTX
SQL(DDL & DML)
PDF
Sql commands
PPTX
SQL Queries Information
PPTX
SQL - DML and DDL Commands
PPTX
SQL commands
PPTX
Aggregate function
SQL(DDL & DML)
Sql commands
SQL Queries Information
SQL - DML and DDL Commands
SQL commands
Aggregate function

What's hot (20)

PPTX
Triggers
PPT
SQL subquery
PPTX
Sql Constraints
PPTX
5. stored procedure and functions
PPTX
introdution to SQL and SQL functions
PPTX
Lab2 ddl commands
PDF
PL/SQL TRIGGERS
PPT
1 - Introduction to PL/SQL
PPT
04 Handling Exceptions
PPT
Aggregate functions
PPT
SQL.ppt
PDF
SQL Overview
PPTX
Sql subquery
PPT
SQL Tutorial - Basic Commands
PPTX
Basic SQL and History
PPTX
database language ppt.pptx
PPTX
Structure of dbms
PPT
Sql basics and DDL statements
PPT
SQL Queries
Triggers
SQL subquery
Sql Constraints
5. stored procedure and functions
introdution to SQL and SQL functions
Lab2 ddl commands
PL/SQL TRIGGERS
1 - Introduction to PL/SQL
04 Handling Exceptions
Aggregate functions
SQL.ppt
SQL Overview
Sql subquery
SQL Tutorial - Basic Commands
Basic SQL and History
database language ppt.pptx
Structure of dbms
Sql basics and DDL statements
SQL Queries
Ad

Viewers also liked (20)

PPTX
Running SQL Queries on the Moodle Database
PDF
Sql wksht-7
PDF
Sql create table statement
PDF
Part 15 triggerr
PDF
Sql update statement
PDF
Sql delete, truncate, drop statements
PPT
Oracle Database Trigger
PPTX
Moodle external database enrolment
ODP
Extending Moodle Reporting
PPTX
Sql query performance analysis
PPTX
Sql server ___________session_19(triggers)
PPTX
6. triggers
PDF
Sql insert statement
PDF
[Www.pkbulk.blogspot.com]dbms11
PPTX
SAP HANA - Manually to insert_data_table
PPT
Sql – Structured Query Language
PPT
Introduction to-sql
RTF
Triggers-Sequences-SQL
PPT
Lecture 4. MS SQL. DML Triggers
PPT
SQL Tutorial - How To Create, Drop, and Truncate Table
Running SQL Queries on the Moodle Database
Sql wksht-7
Sql create table statement
Part 15 triggerr
Sql update statement
Sql delete, truncate, drop statements
Oracle Database Trigger
Moodle external database enrolment
Extending Moodle Reporting
Sql query performance analysis
Sql server ___________session_19(triggers)
6. triggers
Sql insert statement
[Www.pkbulk.blogspot.com]dbms11
SAP HANA - Manually to insert_data_table
Sql – Structured Query Language
Introduction to-sql
Triggers-Sequences-SQL
Lecture 4. MS SQL. DML Triggers
SQL Tutorial - How To Create, Drop, and Truncate Table
Ad

Similar to Sql commands (20)

PDF
Sql basics v2
PPTX
PPTX
Avinash database
PPT
Sql Tutorials
PPTX
SQL : Structured Query Language
PPTX
Introduction to sql new
PDF
Intruduction to SQL.Structured Query Language(SQL}
PDF
SQL Fundamentals - Lecture 2
PDF
SQL-Notes.pdf mba students database note
PPTX
PPT
Lec 1 = introduction to structured query language (sql)
PPT
15925 structured query
ODP
Sqlharshal
PDF
PDF
Structure query language, database course
PPT
Introduction to Structured Query Language (SQL).ppt
PPT
SQL. It education ppt for reference sql process coding
PPT
Introduction to Structured Query Language (SQL) (1).ppt
PPTX
Sql basics
Sql basics v2
Avinash database
Sql Tutorials
SQL : Structured Query Language
Introduction to sql new
Intruduction to SQL.Structured Query Language(SQL}
SQL Fundamentals - Lecture 2
SQL-Notes.pdf mba students database note
Lec 1 = introduction to structured query language (sql)
15925 structured query
Sqlharshal
Structure query language, database course
Introduction to Structured Query Language (SQL).ppt
SQL. It education ppt for reference sql process coding
Introduction to Structured Query Language (SQL) (1).ppt
Sql basics

More from Balakumaran Arunachalam (10)

PPT
PPT
visible surface detection
PPT
Greenhouse effect
PPT
Career path non technical
ODP
Installing and configuring apache
ODP
ODP
Sql installation
ODP
Linux commands
visible surface detection
Greenhouse effect
Career path non technical
Installing and configuring apache
Sql installation
Linux commands

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Classroom Observation Tools for Teachers
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Insiders guide to clinical Medicine.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
VCE English Exam - Section C Student Revision Booklet
01-Introduction-to-Information-Management.pdf
Institutional Correction lecture only . . .
Microbial diseases, their pathogenesis and prophylaxis
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Complications of Minimal Access Surgery at WLH
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Anesthesia in Laparoscopic Surgery in India
Classroom Observation Tools for Teachers
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Insiders guide to clinical Medicine.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx

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)