SlideShare une entreprise Scribd logo
1  sur  34
SQL Structured Query Language
SQL-Create table Create table table_name(column_name1 datatype, column_name2 datatype……) Eg: create table example (id int ,name varchar(10),address varchar(10)) Msg: Command(s) completed successfully.
SQL-Insert Values Insert into table_name(column1,column2,…..)values(values1,values2,…) Eg: insert into example (id,name,address) values(123,'xxxx','yyyyy') Msg: (1 row(s) affected)
SQL-Select Command select *from example Id     name  address 123	xxxxyyyyy 456	jjjjrrrr 456	iiiinnnn 567	eeeeffff
SQL-Alter Command Alter table table_name add or drop column_namedatatype Eg: alter table example add mobilenoint Msg: Command(s) completed successfully. Id     name address  mobileno 123	xxxxyyyyy     NULL 456	jjjjrrrr	      NULL 888	iiiinnnn	      NULL 567	eeeeffff	      NULL
SQL-Update Command Update table_name set column_name=new value where column_name=any value Eg: Update example set id=888 where name='iiii‘ Msg: (1 row(s) affected) Id      name address 123	xxxxyyyyy 456	jjjjrrrr 888	iiiinnnn 567	eeeeffff
SQL-Delete Command Delete  table_name where condition Eg: delete example where id=888 Msg: (1 row(s) affected) Id    name address mobileno 123	xxxxyyyyy     NULL 456	jjjjrrrr         NULL 567	eeeeffff	     NULL
SQL-Drop Command Drop table table_name Eg: drop table example Msg:Command(s) completed successfully.
SQL-Primary Key & Foreign Key  CREATE TABLE table_name (column1 datatype null/not null, column2 datatype null/not null,...CONSTRAINT constraint_namePRIMARY KEY (column1, column2, . column_n)); CREATE TABLE table_name (column1 datatype,  column2 datatype, column3 datatype,  Primary Key (column_any), Foreign Key (Column_any) references Table_any(datatype));
SQL-Primary Key & foreign Key create table example (id intprimary key,namevarchar(10),address varchar(10)) A primary key is used to unique and Not Null identify each row in the table. create table example2 (salary int,expamountint, id int references example(id)) A foreign key is a referential constraint between two tables. 
SQL-Primary Key & Foreign Key  Id     name address     123	rrrrtttt 369	klkliooo 456	iiiihhhh 7889	wswsweww Salary   expamount id 10000	4235	7889 12369	8526	456 12369	865	  456 65894	12589	123 Example (primary Key tale) Example2 (Foreign Key tale)
SQL-DISTINCT select distinct address from ex address ioio klkk yuyu
SQL-Primary Key & Foreign Key  select name,address,salary from example e,example2 e2 where e.id=e2.id O/P Name address    salary wswsweww	10000 iiiihhhh	12369 iiiihhhh 	12369 rrrrtttt	          65894
SQL-BETWEEN & COUNT SELECT "column_name“ FROM "table_name"WHERE "column_name" BETWEEN 'value1' AND 'value2‘ select id from ex where id between 100 and 500 ID 123 456 SELECT COUNT("column_name") FROM "table_name“ select count(id)'No Of Records' from ex No Of Records 4
SQL-Connection String string strcon = "Data Source=172.16.0.1;Initial Catalog=BatchThree;User ID=magnum;Password=Magnum"; SqlConnectionsqlcon = new SqlConnection(strcon); sqlcon.Open(); stringstrsql = "insert into datab values 	('" + txtmarks1.Text + "','" + txtmarks2.Text + "','" + txtmarks3.Text + "','" + txtname.Text + "')"; SqlCommandcmd = new SqlCommand(strsql, sqlcon); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); sqlcon.Close();
SQL-Connection String
SQL-Connection String
SQL-Connection String
SQL-Stored Procedure create procedure proexample(@id int,@namevarchar(10),@address varchar(10)) as insert into example(id,name,address) values (@id,@name,@address) Command(s) completed successfully. exec proexample 666,'hghg','yuyu’ (1 row(s) affected)
SQL-Stored Procedure select *from example Id    name address 123	rrrrtttt 369	klkliooo 456	iiiihhhh 666	hghgyuyu 7889	wswsweww
SQL-JOINS SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables Inner Join Left Join Right Join Full Join
SQL-INNER JOIN The INNER JOIN keyword return rows when there is at least one match in both tables. SELECT column_name(s)FROM table_name1INNER JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL-INNER JOIN select name,address,salary from example inner join example2 on example.id=example2.id order by name Name address   salary iiiihhhh	12369 iiiihhhh	12369 rrrrtttt	          65894 Wswsweww	10000
SQL-LEFT JOIN The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2) SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL_LEFT JOIN select name,address,salary from example left join example2 on example.id=example2.id order by name Name  address   salary hghgyuyu	NULL iiiihhhh	12369 iiiihhhh	12369 klkliooo	           NULL rrrrtttt      	65894 wswsweww         10000
SQL-RIGHT JOIN The RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1) SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL_RIGHT JOIN select name,address,salary from example right join example2 on example.id=example2.id order by name Name address salary iiiihhhh     12369 iiiihhhh     12369 rrrrtttt	       65894 wswsweww   10000
SQL-FULL JOIN The FULL JOIN keyword return rows when there is a match in one of the tables. SELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL-FULL JOIN select name,address,salary from example full join example2 on example.id=example2.id order by name Name address salary hghgyuyu	     NULL iiiihhhh	    12369 iiiihhhh	    12369 klkliooo       NULL rrrrtttt	    65894 wswsweww   10000
SQL-VIEW views can be considered as virtual tables and it physically stores the data. A view also has a set of definitions,and it does not physically store the data. The syntax for creating a view is as follows:  CREATE VIEW "VIEW_NAME" AS "SQL Statement"
SQL-VIEW create view vex as select *from ex select *from vex id    name address 123	pop	yuyu 456	huh	ioio exarere drop view vex
SQL-DISTINCT The SELECT UNIQUE term is an Oracle-only SQL statement. It is equivalent to SELECT DISTINCT.  SyntaX: SELECT DISTINCT "column_name"FROM "table_name“ Eg: select *from ex Id   name address 123	pop	yuyu 456	huh	ioio 856	exaklkk 856	exaklkk
SQL-IN & LIKE SELECT "column_name“ FROM "table_name"WHERE "column_name" IN ('value1', 'value2', ...) select name,address from ex where id in(456) name address huh	ioio SELECT "column_name“ FROM "table_name"WHERE "column_name" LIKE {PATTERN} select name,address from ex where id like(456) name address Huh ioio
End) Prabhu.ftz@gmail.com

Contenu connexe

Tendances

Learning sql from w3schools
Learning sql from w3schoolsLearning sql from w3schools
Learning sql from w3schoolsfarhan516
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinctBishal Ghimire
 
SQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesSQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesgourav kottawar
 
SQL || overview and detailed information about Sql
SQL || overview and detailed information about SqlSQL || overview and detailed information about Sql
SQL || overview and detailed information about Sqlgourav kottawar
 
12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible Columns12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible ColumnsConnor McDonald
 
MySQL partitions tutorial
MySQL partitions tutorialMySQL partitions tutorial
MySQL partitions tutorialGiuseppe Maxia
 
Python data structures
Python data structuresPython data structures
Python data structuresHarry Potter
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and OperatorsMohan Kumar.R
 

Tendances (14)

Sql
SqlSql
Sql
 
Learning sql from w3schools
Learning sql from w3schoolsLearning sql from w3schools
Learning sql from w3schools
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinct
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
SQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesSQL querys in detail || Sql query slides
SQL querys in detail || Sql query slides
 
R for you
R for youR for you
R for you
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
2013 28-03-dak-why-fp
2013 28-03-dak-why-fp2013 28-03-dak-why-fp
2013 28-03-dak-why-fp
 
Writeable CTEs: The Next Big Thing
Writeable CTEs: The Next Big ThingWriteable CTEs: The Next Big Thing
Writeable CTEs: The Next Big Thing
 
SQL || overview and detailed information about Sql
SQL || overview and detailed information about SqlSQL || overview and detailed information about Sql
SQL || overview and detailed information about Sql
 
12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible Columns12c Mini Lesson - Invisible Columns
12c Mini Lesson - Invisible Columns
 
MySQL partitions tutorial
MySQL partitions tutorialMySQL partitions tutorial
MySQL partitions tutorial
 
Python data structures
Python data structuresPython data structures
Python data structures
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 

En vedette

Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Vidyasagar Mundroy
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Languagepandey3045_bit
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands1keydata
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationGuru Ji
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginnersRam Sagar Mourya
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
 

En vedette (14)

Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
RDBMS and SQL
RDBMS and SQLRDBMS and SQL
RDBMS and SQL
 
Sql basics
Sql basicsSql basics
Sql basics
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
RDBMS SQL Basics
RDBMS SQL BasicsRDBMS SQL Basics
RDBMS SQL Basics
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
DBMS Practical File
DBMS Practical FileDBMS Practical File
DBMS Practical File
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL Presentation
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 

Similaire à Sql (20)

Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
Tables And SQL basics
Tables And SQL basicsTables And SQL basics
Tables And SQL basics
 
dbms.pdf
dbms.pdfdbms.pdf
dbms.pdf
 
Sql insert statement
Sql insert statementSql insert statement
Sql insert statement
 
Commands
CommandsCommands
Commands
 
SQL
SQLSQL
SQL
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
 
Introduction sql
Introduction sqlIntroduction sql
Introduction sql
 
Structured query language(sql)
Structured query language(sql)Structured query language(sql)
Structured query language(sql)
 
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
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for Beginners
 
Query
QueryQuery
Query
 
Sql
SqlSql
Sql
 
unit-5 sql notes.docx
unit-5 sql notes.docxunit-5 sql notes.docx
unit-5 sql notes.docx
 
Best sql plsql_material for B.TECH
Best sql plsql_material for B.TECH Best sql plsql_material for B.TECH
Best sql plsql_material for B.TECH
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Sql Tags
Sql TagsSql Tags
Sql Tags
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queries
 

Dernier

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Dernier (20)

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
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
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
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Sql

  • 2. SQL-Create table Create table table_name(column_name1 datatype, column_name2 datatype……) Eg: create table example (id int ,name varchar(10),address varchar(10)) Msg: Command(s) completed successfully.
  • 3. SQL-Insert Values Insert into table_name(column1,column2,…..)values(values1,values2,…) Eg: insert into example (id,name,address) values(123,'xxxx','yyyyy') Msg: (1 row(s) affected)
  • 4. SQL-Select Command select *from example Id name address 123 xxxxyyyyy 456 jjjjrrrr 456 iiiinnnn 567 eeeeffff
  • 5. SQL-Alter Command Alter table table_name add or drop column_namedatatype Eg: alter table example add mobilenoint Msg: Command(s) completed successfully. Id name address mobileno 123 xxxxyyyyy NULL 456 jjjjrrrr NULL 888 iiiinnnn NULL 567 eeeeffff NULL
  • 6. SQL-Update Command Update table_name set column_name=new value where column_name=any value Eg: Update example set id=888 where name='iiii‘ Msg: (1 row(s) affected) Id name address 123 xxxxyyyyy 456 jjjjrrrr 888 iiiinnnn 567 eeeeffff
  • 7. SQL-Delete Command Delete table_name where condition Eg: delete example where id=888 Msg: (1 row(s) affected) Id name address mobileno 123 xxxxyyyyy NULL 456 jjjjrrrr NULL 567 eeeeffff NULL
  • 8. SQL-Drop Command Drop table table_name Eg: drop table example Msg:Command(s) completed successfully.
  • 9. SQL-Primary Key & Foreign Key CREATE TABLE table_name (column1 datatype null/not null, column2 datatype null/not null,...CONSTRAINT constraint_namePRIMARY KEY (column1, column2, . column_n)); CREATE TABLE table_name (column1 datatype,  column2 datatype, column3 datatype,  Primary Key (column_any), Foreign Key (Column_any) references Table_any(datatype));
  • 10. SQL-Primary Key & foreign Key create table example (id intprimary key,namevarchar(10),address varchar(10)) A primary key is used to unique and Not Null identify each row in the table. create table example2 (salary int,expamountint, id int references example(id)) A foreign key is a referential constraint between two tables. 
  • 11. SQL-Primary Key & Foreign Key Id name address 123 rrrrtttt 369 klkliooo 456 iiiihhhh 7889 wswsweww Salary expamount id 10000 4235 7889 12369 8526 456 12369 865 456 65894 12589 123 Example (primary Key tale) Example2 (Foreign Key tale)
  • 12. SQL-DISTINCT select distinct address from ex address ioio klkk yuyu
  • 13. SQL-Primary Key & Foreign Key select name,address,salary from example e,example2 e2 where e.id=e2.id O/P Name address salary wswsweww 10000 iiiihhhh 12369 iiiihhhh 12369 rrrrtttt 65894
  • 14. SQL-BETWEEN & COUNT SELECT "column_name“ FROM "table_name"WHERE "column_name" BETWEEN 'value1' AND 'value2‘ select id from ex where id between 100 and 500 ID 123 456 SELECT COUNT("column_name") FROM "table_name“ select count(id)'No Of Records' from ex No Of Records 4
  • 15. SQL-Connection String string strcon = "Data Source=172.16.0.1;Initial Catalog=BatchThree;User ID=magnum;Password=Magnum"; SqlConnectionsqlcon = new SqlConnection(strcon); sqlcon.Open(); stringstrsql = "insert into datab values ('" + txtmarks1.Text + "','" + txtmarks2.Text + "','" + txtmarks3.Text + "','" + txtname.Text + "')"; SqlCommandcmd = new SqlCommand(strsql, sqlcon); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); sqlcon.Close();
  • 19. SQL-Stored Procedure create procedure proexample(@id int,@namevarchar(10),@address varchar(10)) as insert into example(id,name,address) values (@id,@name,@address) Command(s) completed successfully. exec proexample 666,'hghg','yuyu’ (1 row(s) affected)
  • 20. SQL-Stored Procedure select *from example Id name address 123 rrrrtttt 369 klkliooo 456 iiiihhhh 666 hghgyuyu 7889 wswsweww
  • 21. SQL-JOINS SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables Inner Join Left Join Right Join Full Join
  • 22. SQL-INNER JOIN The INNER JOIN keyword return rows when there is at least one match in both tables. SELECT column_name(s)FROM table_name1INNER JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 23. SQL-INNER JOIN select name,address,salary from example inner join example2 on example.id=example2.id order by name Name address salary iiiihhhh 12369 iiiihhhh 12369 rrrrtttt 65894 Wswsweww 10000
  • 24. SQL-LEFT JOIN The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2) SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 25. SQL_LEFT JOIN select name,address,salary from example left join example2 on example.id=example2.id order by name Name address salary hghgyuyu NULL iiiihhhh 12369 iiiihhhh 12369 klkliooo NULL rrrrtttt 65894 wswsweww 10000
  • 26. SQL-RIGHT JOIN The RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1) SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 27. SQL_RIGHT JOIN select name,address,salary from example right join example2 on example.id=example2.id order by name Name address salary iiiihhhh 12369 iiiihhhh 12369 rrrrtttt 65894 wswsweww 10000
  • 28. SQL-FULL JOIN The FULL JOIN keyword return rows when there is a match in one of the tables. SELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 29. SQL-FULL JOIN select name,address,salary from example full join example2 on example.id=example2.id order by name Name address salary hghgyuyu NULL iiiihhhh 12369 iiiihhhh 12369 klkliooo NULL rrrrtttt 65894 wswsweww 10000
  • 30. SQL-VIEW views can be considered as virtual tables and it physically stores the data. A view also has a set of definitions,and it does not physically store the data. The syntax for creating a view is as follows: CREATE VIEW "VIEW_NAME" AS "SQL Statement"
  • 31. SQL-VIEW create view vex as select *from ex select *from vex id name address 123 pop yuyu 456 huh ioio exarere drop view vex
  • 32. SQL-DISTINCT The SELECT UNIQUE term is an Oracle-only SQL statement. It is equivalent to SELECT DISTINCT.  SyntaX: SELECT DISTINCT "column_name"FROM "table_name“ Eg: select *from ex Id name address 123 pop yuyu 456 huh ioio 856 exaklkk 856 exaklkk
  • 33. SQL-IN & LIKE SELECT "column_name“ FROM "table_name"WHERE "column_name" IN ('value1', 'value2', ...) select name,address from ex where id in(456) name address huh ioio SELECT "column_name“ FROM "table_name"WHERE "column_name" LIKE {PATTERN} select name,address from ex where id like(456) name address Huh ioio