SlideShare a Scribd company logo
SQL	Commands	With	Examples		
Jagriti	Goswami
Outline	
§  SQL	Overview	 §  Copy	Rows	From	One	Table	Into	another	 §  Ordering	Results	
§  Installation	And	Setup	 §  			Using	Aliases	 §  Grouping	Data	
§  Creating	A	Database	 §  The	NULL	Value	 §  			Conditional	Expressions	
§  Creating	A	Table	 §  NOT	NULL	Constraint	 §  Accessing	Related	Tables	
§  Inserting	Values	 §  DEFAULT	Constraint	 §  Join	Multiple	Tables	
§  Retrieving	All	Rows	And	Columns	 §  UNIQUE	Constraint	 §  String	Functions	
§  Retrieving	Subset	Of	Rows	 §  Primary	Key	Constraint	 §  Numeric	Functions	
§  Retrieving	Top	N	number	Rows	 §  Foreign	Key	Constraint	 §  Date	And	Time	Functions	
§  			Retrieving	Top	X	percent	Rows	 §  Changing	A	Schema	 §  Aggregating	Data	
§  Retrieving	Subset	Of		Columns	 §  Import	Files		 §  Concatenating	Column	Data	
§  Counting	Rows	 §  Saving	Query	Results	 §  Searching	For	Patterns	
§  Updating	Data	 §  Filtering	Data:	WHERE	Clause	 §  UNION	Operator	
§  Deleting	Data	 §  Filtering	Data:	LIKE	Operator	 §  Transactions	
§  Deleting	Table	 §  Filtering	Data:	IN	Operator	
§  			Inserting	Rows	 §  Removing	Duplicates
SQL	Overview	
Ø  Structured	Query	Language	(SQL)	
Ø  Creates	a	database	and	defines	its	structure	
Ø  Performs	querying	database	
Ø  Controls	database	security	
Ø  SQL	has	two	sublanguage:	Data	control	Language	(DCL)	&	Data	Manipulating	Language	(DML)	
Ø  DCL	deals	with	defining	database	(creating	new	table,	fields)	and	with	database	security	
Ø  DML	deals	with	queries	and	data	manipulation	
Ø  Databases	that	uses	SQL:	MS	SQL	Server,	Oracle,	MySQL,	SQLite,	IBM	DB2,	Postgre	SQL,	Big	Data	
Ø  Install	Azure	Data	Studio	
Ø  Tools	used	for	SQL:		
Ø  Azure	Data	Studio	(Windows,	Mac	OS,	Linux)	
Ø  SQL	Server	Management	Studio	(SSMS)	(Windows)	
Ø  SQL	Server	Data	Tools	(SSDT)	(Windows)	
Ø  Visual	Studio	Code	(T-SQL)	(Windows,	Mac	OS,	Linux)	
Ø  SQL	Workbench
Ø  Installation	of	Microsoft	SQL	Server	2017	on	macOS	Mojave	version	10.14.4	
1.  Download	and	install	Docker	à	Create	Docker	account	(Link)	
§  Install	Docker	:	Download	Docker	Community	Edition	for	Mac.	(Link).		
§  This	enables	to	run	SQL	Server	from	within	a	Docker	container	
§  To	install	Docker,	download	.dmg	file	à	drag	the	Docker.app	icon	to	Application	folder	
§  To	launch	Docker,	open	Docker	à	provide	mac	password	.		
§  Docker	installs	its	networking	components	and	links	to	the	Docker	apps	
§  Increase	the	memory:	from	Docker	icon	select	Preferences	à	change	memory	to	4GB	(because	SQL	Server	
needs		at	least	3.25GB)	à	click	Apply	&	Restart	
2.  Download	and	install	SQL	Server:	On	Terminal	run	à	$	docker	pull	microsoft/mssql-server-linux		
3.  Launch	the	Docker	Image:	open	a	Terminal	window	and	run	à	$	docker	run	–d	–name	sql_server_demo	–e	
‘ACCEPT_EULA=Y’	–e	‘SA_PASSWORD=reallyStrongPwd123’	–p	1433:1433	microsoft/mssql-server-linux	
	(name,	password	can	be	changed)	
4.  Check	the	Docker	container:	run	à	$	docker	ps	
5.  Install	sql-cli:	run	$	npn	install	–g	sql-cli	OR	$	sudo	npn	install	–g	sql-cli		
6.  Connect	to	SQL	server:	run	à	$	mssql	–u	sa	–p	reallyStrongPwd123	
7.  Install	Azure	Data	Studio	(Link)	&	Connect	to	SQL	server:	open	Azure	Data	Studio	à	Welcome	page	à	under	Start	
click	New	Connection	à	provide	Server	Name:	localhost,	Authentication	Type:	SQL	Login,	user	name:	sa,	
password:	reallyStrongPwd123,	database	name:	<default>,	server	group:	<default>	
Installation	and	Setup
Ø  Start	Azure	Data	Studio	(see	instructions	on	installation	and	setup	slide)	
Ø  Create	a	new	database	
§  Right-click	on	server,	localhost	!	select	New	Query	-->	run	following	SQL	command	
							CREATE	DATABASE	database_name;	
Creating	a	Database
Ø  Create	a	new	Table	name	test	in	the	SQl_Tutorial		Database	
Ø  Change	the	connection	context	from	Master	to	SQl_Tutorial	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Creating	a	Table
Ø  Inserting	values	into	table	name	test	in	the	SQl_Tutorial		Database	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Inserting	Values
Ø  DB	SQl_Tutorial,	Table	Customer:	
	
	
	
	
	
	
	
Ø  Inserting	values	into	table	Customer:	
Example	Tables:	Customer	
Customer
Ø  DB	SQl_Tutorial,	Table	item:	
	
	
Ø  DB	SQl_Tutorial,	Table	sale:	
Example	Tables:	item,	sale	
item	 sale	
Ø  Inserting	values	in	table	item:	
Ø  Inserting	values	in	table	sale:
Ø  Selecting	all	columns	and	rows	from		table	Customer		
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Retrieving	All	Columns	And	Rows
Ø  Selecting	specific	rows	from		table	Customer		
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Retrieving	Subset	Of	Rows
Ø  Retrieving	top	N	number	rows	from		table	Disease	using		SELECT	TOP		statement	followed	by	number	of	rows	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Retrieving	Top	N	number	Rows
Ø  Retrieving	top	x	percent	rows	from		table	Disease	using		SELECT	TOP	x	PERCENT		statement		
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Retrieving	Top	X	percent	Rows
Ø  Selecting	specific	columns	and	all	rows	from		table	Customer		
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Retrieving	Subset	Of	Columns
Ø  Counting	rows	in	table	Customer		
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Counting	Rows
Ø  Updating	data	in	table	Customer		
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Updating	Data
Ø  Deleting	data	in	table	Customer		
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Deleting	Data
Ø  Deleting	existing	table	test_tb	from	SQl_Tutorial	Database	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Deleting	Table
Ø  Inserting	rows	into	table	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Inserting	Rows
Ø  Copying	rows	from	table	test	into	table	test_tb_3	using	WHERE	clause--	WHERE	a	IN	(2,	3)	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Copying	Rows	From	One	Table	Into	Another
Ø  Retrieving	rows	and	columns	using	aliases	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Using	Aliases
Ø  Retrieving	rows	with	NULL	value	from	table	test_tb_2	
Ø  Retrieving	rows	which	are	NOT	NULL	from	table	test_tb_2	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
The	NULL	Value
Ø  Create	a	new	table	test_tb_1	with	“NOT	NULL”	Constraint	
Ø  The	insertion	of	a	row	which	doesn’t	have	a	value	will	fail	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Constraining	columns:	NOT	NULL
Ø  Create	a	new	table	test		
Ø  Insert	row	values	with	DEFAULT	constraint	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Constraining	columns:	DEFAULT
Ø  Create	a	new	table	test	
Ø  Insert	row	values	with	UNIQUE	constraint	
Ø  NULL		value	or	NULL	state	is	exempt	from	the	UNIQUE	constraint	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Constraining	columns:	UNIQUE
Ø  An	ID	column	is	a	column	with	unique,	sequential	values	for	each	row	in	a	table	
Ø  Create	ID	column	with	auto	increment	integer	primary	key		
Ø  Auto	increment	Primary	key	in	SQL	Server	is	defined	using	IDENTITY	and	PRIMARY	KEY	constraint	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Primary	Key	Constraint	On	Create	Table
Ø  Define	PRIMARY	KEY	constraint	on	multiple	columns	when	the	table	is	created.	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Multi-Column	Primary	Key	Constraint	On	Create	Table
Ø  Define	PRIMARY	KEY	constraint	on	multiple	columns	on	existing	table.	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Multi-Column	Primary	Key	Constraint	On	Existing	Table
Ø  Enable,	Disable,	and	Drop	a	PRIMARY	KEY	constraint	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Disable,	Enable	and	Drop	A	Primary	Key	Constraint
Ø  A	FOREIGN	KEY	links	two	tables	together	
Ø  Foreign	key	in	one	table	(child	table)	refers	to	the	Primary	key	in	another	table	(referenced	or	parent	table)	
Ø  Define	FOREIGN	KEY	constraint	when	the	table	is	created.	
Ø  Concept	is	shown	below	with	example	tables	Customer,	and	Orders.	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
Foreign	Key	Constraint	On	Create	Table
Ø  Define	multi-column	FOREIGN	KEY	constraint	when	the	table	is	created.	
Ø  Concept	is	shown	below	with	example	tables	Customer,	and	Orders.	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
Multi-Column	Foreign	Key	Constraint	On	Create	Table
Ø  Define	FOREIGN	KEY	constraint	existing	table.	
Ø  Concept	is	shown	below	with	example	tables	Customer,	and	Orders.	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
Foreign	Key	Constraint	On	Existing	Table
Ø  Define	multi-column	FOREIGN	KEY	constraint	on	existing	table.	
Ø  Concept	is	shown	below	with	example	tables	Customer,	and	Orders.	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
Multi-Column	Foreign	Key	Constraint	On	Existing	Table
Ø  Drop	a	FOREIGN	KEY	constraint	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Drop	A	Foreign	Key	Constraint
Ø  Change	a	table	schema	after	it’s	already	been	defined	and	populated	with	data	
Ø  Using	ALTER	statement	followed	by	ADD	clause	
Ø  In	the	following	example,	we	added	d	column	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
	
Changing	A	Schema:	Add	A	New	Column
Ø  Install	the	SQL	Server	Import	Extension	(click	here	to	see	installation	steps)	
Ø  The	SQL	Server	Import	Extension	converts	.txt	and	.csv	files	into	a	SQL	table.	
Ø  Once	installation	is	complete,	start	Import	Wizard	!	Right-click	on	the	database	à	click	Import	Wizard	
Ø  Importing	a	file	à	on	Import	flat	file	wizard	!	select	a	file	by	clicking	Browse	
Ø  Keep	clicking	Next	to	proceed	à	on	modify	columns	columns	can	be	changed	
Ø  Click	on	Import	data	à	click	Done	to	finish	the	task	
Ø  Refresh	target	Database	and	run	SELECT	query	on	the	table	name	to	retrieve	the	data	
	
	
Import	Files	Into	SQL	Server	
Imported	titanic.csv	file	using	Import	Wizard
Ø  In	Azure	Data	Studio,	to	save	query	results	as	CSV,	Excel,	and	JSON,	click	on	the	file	icons	on	the	right	side	of	the	result	
window.	
	
	
	
	
	
	
	
Ø  To	save	a	subset	of	the	results	directly	à	select	the	rows,	columns,	or	block	of	interest	(click	and	drag	to	select	within	
the	result)à	then	Right	click	à	A	dialog	will	appear	where	to	save	the	selection	
	
Saving	Query	Results
Ø  Filtering	data	using	WHERE	clause	
Ø  WHERE	clause	allows	to	retrieve	specific	rows	instead	of	entire	table	
Ø  For	e.g.,	we	want	to	retrieve	survived	passenger	list	for	age	>	50	and	sex	=	‘female’	from	table	Titanic	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Filtering	Data:	WHERE	Clause
Ø  Filtering	data	using	LIKE	operator	by	constructing	a	wildcard	(%	sign)	
Ø  For	e.g.,	we	want	to	retrieve	Name	that	has	the	word	‘William’	in	it	from	table	Titanic	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Filtering	Data:	LIKE	Operator
Ø  IN	operator	is	used	to	select	results	that	match	values	in	a	list	
Ø  For	e.g.,	we	want	to	retrieve	survived	passenger	list	where	Sex	column	match	with	female	from	table	Titanic	
Ø  Run	the	following	command	as	shown	in	below	figure	à	
	
Filtering	Data:	IN	Operator
Ø  Retrieve	unique	results	from	a	column	by	removing	duplicates	using	SELECT	DISTINCT	statement	
Ø  To	retrieve	unique	disease	from	table	Disease	run	the	following	command	as	shown	in	below	figure	à	
	
Removing	Duplicates
Ø  Sorting	results	(in	ascending	or	descending	order)	on	single	or	multiple	columns	using	ORDER	BY	clause	
Ø  In	the	following	example	we	want	to	sort	Disease	column	in	descending	order,		
Ø  and	within	that	sort	County	column	in	ascending	order,	and	sort	Year	in	descending	orderà	
	
Ordering	Results:	ORDER	BY	Clause
Ø  The	GROUP	BY	statement	groups	rows	that	have	the	same	values	into	summary	rows,	like	“find	the	number	of	cases	
for	each	disease	for	the	year	2018”	
Ø  The	GROUP	BY	statement	is	often	used	with	aggregate	functions	(COUNT,	MAX,	MIN,	SUM,	AVG)	
Ø  For	example,	we	want	to	find	the	number	of	cases	for	each	disease	for	the	year	2018	from	table	Disease	à	
	
Grouping	Data:	GROUP	BY	Statement
Ø  The	conditional	expression	uses	CASE	keyword	followed	by	WHEN	condition	THEN	result	statement	
Ø  The	concept	is	illustrated	in	the	following	example	using	a	test	table.	
	
Conditional	Expressions
Ø  SQL	performs	query	on	related	data	from	multiple	tables	using	JOIN	clause	
Ø  Unique	ID	columns,	automatically	generated	by	Database	system,	is	used	to	create	relationships	
Ø  The	most	common	form	of	join	is	inner	join	(the	default	join)	
Ø  Inner	join	includes	rows	from	both	tables	where	the	join	condition	is	met	
Ø  The	less	common	form	of	join	is	outer	join:	left	outer	join,	right	outer	join,	and	full	outer	join	
Ø  A	left	outer	join	includes	the	rows	where	the	condition	is	met	and	also	includes	all	the	rows	from	the	
table	on	the	left,	where	the	condition	is	not	met	
Ø  A	right	outer	join	includes	the	rows	where	the	condition	is	met	and	also	includes	all	the	rows	from	the	
table	on	the	right,	where	the	condition	is	not	met	
Ø  A	full	outer	join	combines	the	effects	of	the	left	and	right	joins	
Ø  Many	database	systems	do	not	support	right	and	full	joins	
	
Accessing	Related	Tables:	JOIN	Clause
Ø  The	concept	of	inner	join	is	illustrated	in	the	following	example	using	item	and	sale	tables	
Ø  In	the	given	example,	JOIN	clause	gives	the	id,	the	quantity,	and	the	price	from	sale	table;	and	the	name	
and	the	description	from	the	item	table	
	
JOIN	Clause	Example
Ø  In	practice,	it’s	very	common	to	have	tables	with	many-to-many	relationships	
Ø  The	many-to-many	relationships	are	implemented	using	a	junction	table	
Ø  The	concept	is	illustrated	in	the	following	example	using	customer,	item	and	sale	tables	
Ø  In	the	given	example,	JOIN	clause	gives	the	customer	name	and	zip	from	customer	table;	the	name	and	
the	description	from	the	item	table;	and	the	quantity	and	the	price	from	sale	table	
	
Join	Multiple	Tables
LEFT	JOIN	Example
String	Functions	
LEN(string):	 Returns	the	length	of	the	given	string	
DATALENGTH(string):	 Returns	string	length	including	trailing	spaces	in	SQL	server	
SUBSTRING(string,	start,	length)	:	 Returns	some	characters	from	a	given	string	
TRIM(string):	 Removes	leading	and	trailing	spaces	from	a	string.	
ASCII(string)	 Returns	the	ASCII	value	of	the	first	character	of	the	string	
CHAR(code)	 Returns	the	character	based	on	the	ASCII	code	
CHARINDEX(substring,	string,	start)	 Searches	for	a	substring	in	a	string	and	returns	the	position	
CONCAT(string1,	string2,	string3,…)	 Add	two	or	more	strings	together	
CONCAT_WS(separator,	string1,	
string2,…)	
Add	two	or	more	strings	together	with	separator	
SOUNDEX(expression)	 Returns	a	four-character	code	to	evaluate	the	similarity	of	two	expressions	
DIFFERENCE(expression1,	
expression2)	
Compares	two	SOUNDEX	values	and	return	an	integer	
REVERSE(string)	 Reverses	a	string
Ø  Length	functions:	
§  LEN(string)	for	SQL	Server	Or	LENGTH(string)	for	other	database	system;	returns	the	length	of	the	given	string	
§  DATALENGTH(string)	returns	string	length	including	trailing	spaces	in	SQL	server	
§  COL_LENGTH(table_name,	col_name)	returns	the	maximum	size	in	bytes	in	SQL	server	
	
Getting	Length	Of	Strings
Ø  The	function	SUBSTRING(string,	start,	length)		for	SQL	Server	and	SUBSTR(string,	start,	length)	for	other	database	
system;	returns	some	characters	from	a	given	string	
Getting	Part	Of	Strings
Ø  The	function	TRIM(string)	removes	leading	and	trailing	spaces	from	a	string	
Ø  LTRIM(string)	removes	leading	spaces	from	a	string	
Ø  TRIM(string)	removes	trailing	spaces	from	a	string	
Removing	Spaces
Numeric	Functions	
ABS(number):	 Returns	the	absolute	value	of	a	number	
AVG	(expression):	 Returns	the	average	value	of	an	expression	
COUNT(expression)	:	 Returns	the	number	of	records	returned	by	a	select	query	
FLOOR(number):	 Returns	the	largest	integer	value	that	is	smaller	than	or	equal	to	a	number	
MAX(expression)	 Returns	the	maximum	value	in	a	set	of	values	
POWER(a,	b)	 Returns	the	value	of	a	number	raised	to	the	power	of	another;	a	-base,	b		-exponent	
RAND(seed)	 Returns	a	random	number		>=	0	and	<	1	
ROUND(number,	decimals,	
operation)	
Rounds	a	number	to	a	specified	number	of	decimal	places,		number—to	be	rounded,	
decimals—the	number	of	decimal	places	to	round	number	to,	operation–	(opt,	default	
0),	if	0	it	rounds	the	result	to	the	number	of	decimal,	if	another	value	than	0,	it	
truncates	the	result	to	the	number	of	decimals.	
SQRT(number)	 Returns	the	square	root	of	a	number	
SQUARE(number	 Returns	the	square	of	a	number	
SUM(expression)	 Calculates	the	sum	of	a	set	of	values
Integer	Division
Rounding	Numbers
Date	And	Time	Functions	
CURRENT_TIMESTAMP:	 Returns	the	current	date	and	time	
YEAR(date):	 Returns	the	year	part	for	a	specified	date	
MONTH(date):	 Returns	the	month	part	for	a	specified	date	
DAY(date):	 Returns	the	day	part	for	a	specified	date	
GETDATE():	 Returns	the	current	database	system	date	and	time	(in	‘YYYY-MM-DD	
hh:mm:ss:mmm’	format)	
ISDATE(expression):	 Checks	an	expression	and	returns	1	if	it	is	a	valid	date,	otherwise	returns	0	
SYSDATETIME():	 Returns	the	date	and	time	of	the	computer	where	the	SQL	server	is	running	
DATEADD(interval,	number,	date):	 Adds	a	time/date	interval	to	a	date	and	then	returns	the	date	
DATEDIFF(interval,	date1,	date2)	 Returns	differences	between	two	dates	
DATEFROMPARTS(year,	month,	day)	 Returns	a	date	from	the	specified	parts	(year,	month,	and	day)	
DATEPART(interval,	date)	 Returns	a	specified	part	of	a	date	
DATENAME(interval,	date)	 Returns	a	specified	part	of	a	date
Date	Time	Function	Examples
Ø  Aggregating	data	is	the	information	derived	from	more	than	one	row	at	a	time	
Ø  In	the	table	Disease,	we	use	COUNT()	aggregate	function	to	know	how	many	cases	are	present	in	each	disease		
Ø  COUNT()	returns	a	single	value	from	a	query	that	spans	many	rows	of	data	
Ø  The	GROUP	BY	clause	groups	the	results	before	calling	the	aggregation	function	COUNT()	
Ø  The	HAVING	clause	retrieves	results	for	a	specified	condition,	in	this	case,	retrieves	results	for	COUNT(*)	>	2000	
Ø  And	finally,	execute	ORDER	BY	Count	DESC,	Disease,	to	retrieve	disease	count	in	descending	order,	and	Disease	in	
ascending	order	within	Count.	
	
Aggregating	Data
Ø  The	following	statement	uses	the	CONCAT()	function	to	concatenate	values	in	the	First_Name	and	Last_Name	
columns	of	the	table	Student	
Concatenating	Column	Data
Ø  SQL	query	uses	wildcard	characters	to	search	a	pattern	
Ø  The	LIKE	and	NOT	operators	are	used	with	WHERE	clause	to	search	a	pattern	
Ø  For	example,	using	the	wildcard	“A%”	we	can	search	any	string	starting	with	a	capital	A	
Ø  Using	the	wildcard	“%A%”	we	can	search	all	results	that	contain	a	capital	A	
Ø  Using	the	_wildcard	we	can	search	any	string	at	specific	location;	for	e.g.,	‘_A%’	gives	the	results	only	when	C	is	in	the	
second	position	
	
Searching	For	Patterns:	Wildcard
Ø  The	UNION	operator	combines	the	results	of	two	or	more	SELECT	statements	
Ø  Each	SELECT	statement	within	UNION	must	have	the	same	number	of	columns	
Ø  The	columns	must	also	have	similar	data	types	
Ø  The	columns	in	each	SELECT	statement	must	also	be	in	the	same	order	
Ø  UNION	operator	selects	only	distinct	values	by	default.	To	allow	duplicate	values,	use	UNION	ALL	
Ø  UNION	Syntax	:	SELECT	column(s)	FROM	table1	UNION	column(s)	FROM	table2	
UNION	Operator
UNION	Operator	Example
Ø  A	transaction	is	a	group	of	operations	that	are	handled	as	one	unit	of	work	If	one	operation	fails,	the	entire	group	of	
operations	fail.	Transaction	Commands:	
§  BEGIN	TRANSACTION	–	to	begin	a	transaction	
§  COMMIT	-	to	end	and	save	a	transaction	
§  ROLLBACK	–	to	rollback	the	changes	
	
Transactions
Ø  Click	on	Github	for	example	codes	discussed	in	this	presentation.	
Ø  References:	
1.  LinkedIn	video	by	Bill	Weinman	
2.  SQL	Cookbook	by	Anthony	Molinaro	
3.  SQL	Notes	for	Professionals	
4.  W3schools.com	
Summary

More Related Content

PPTX
SQL Windowing
PDF
Ajax World2008 Eric Farrar
PPTX
Mimsy XG Resource Session
PPTX
Exciting Features for SQL Devs in SQL 2012
PPTX
Exploring Advanced SQL Techniques Using Analytic Functions
PPTX
Exploring Advanced SQL Techniques Using Analytic Functions
PPTX
SQL Server Workshop for Developers - Visual Studio Live! NY 2012
PPTX
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...
SQL Windowing
Ajax World2008 Eric Farrar
Mimsy XG Resource Session
Exciting Features for SQL Devs in SQL 2012
Exploring Advanced SQL Techniques Using Analytic Functions
Exploring Advanced SQL Techniques Using Analytic Functions
SQL Server Workshop for Developers - Visual Studio Live! NY 2012
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...

Similar to SQL Basics (20)

PDF
Sql tutorial
PDF
sql notes Provideby AGN HUB Tech & It Solutions
PPTX
DOC
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
PPTX
SQLBasic to advance for the beggineers.pptx
PPTX
introduction to structural query language
PDF
Structures query language ___PPT (1).pdf
DOCX
PPTX
sql.pptxm og yd 6rxjfskhzihyzgmxbjfxuzkfa6
PPTX
sql.fjstsusgshsgsjjshshsjsjjshsjjsjsypptx
DOCX
unit-5 sql notes.docx
PPTX
SQL Query
PPTX
Lab1 select statement
DOCX
PPTX
Using Basic Structured Query Language lo1.pptx
PPTX
sql ppt.pptx
PDF
Chapter – 6 SQL Lab Tutorial.pdf
PPT
postgresqlllllllllllllllllllllllllllllll.ppt
PDF
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
PPTX
SQL Training- Introduction Part One.pptx
Sql tutorial
sql notes Provideby AGN HUB Tech & It Solutions
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
SQLBasic to advance for the beggineers.pptx
introduction to structural query language
Structures query language ___PPT (1).pdf
sql.pptxm og yd 6rxjfskhzihyzgmxbjfxuzkfa6
sql.fjstsusgshsgsjjshshsjsjjshsjjsjsypptx
unit-5 sql notes.docx
SQL Query
Lab1 select statement
Using Basic Structured Query Language lo1.pptx
sql ppt.pptx
Chapter – 6 SQL Lab Tutorial.pdf
postgresqlllllllllllllllllllllllllllllll.ppt
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
SQL Training- Introduction Part One.pptx
Ad

Recently uploaded (20)

PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
Computer network topology notes for revision
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
Database Infoormation System (DBIS).pptx
PDF
Mega Projects Data Mega Projects Data
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPTX
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
PPTX
Global journeys: estimating international migration
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
Business Acumen Training GuidePresentation.pptx
Introduction-to-Cloud-ComputingFinal.pptx
Computer network topology notes for revision
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Database Infoormation System (DBIS).pptx
Mega Projects Data Mega Projects Data
Major-Components-ofNKJNNKNKNKNKronment.pptx
Moving the Public Sector (Government) to a Digital Adoption
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
STUDY DESIGN details- Lt Col Maksud (21).pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
IBA_Chapter_11_Slides_Final_Accessible.pptx
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
Global journeys: estimating international migration
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Clinical guidelines as a resource for EBP(1).pdf
Data_Analytics_and_PowerBI_Presentation.pptx
Ad

SQL Basics