SlideShare a Scribd company logo
Introduction To SQL Unit 6 Modern Business Technology Introduction To TSQL Unit 6 Developed by Michael Hotek
Temporary Tables Temp tables are used to hold intermediate result sets for further processing These are used when you need to perform a process that can not be done in a single SQL statement They come in two different types local accessible only to that connection preceeded by a #  ex: #authors dropped when the session disconnects global accessible to all connections must be explicitly dropped preceeded by ##  ex: ##authors Names can only be 13 characters long
Temp tables can be a powerful addition to your code They should be minimized at all costs Many people overuse temp tables Poor database design Lack of SQL knowledge Lazy Temp tables can impose a significant drain on system resources Temporary Tables
Select Into Select into can be used to create a new table based upon a select statement Creates the table to match the structure of the select list Adds any data from the select The database option select into/bulkcopy needs to be turned on SELECT [ALL | DISTINCT]  select_list   [ INTO  [ new_table_name ]]  [FROM { table_name  |  view_name }[ ( optimizer_hints ) ]  [[ ,  { table_name2  |  view_name2 }[ ( optimizer_hints ) ]  [... ,  { table_name16  |  view_name16 }[ ( optimizer_hints ) ]]]  [WHERE clause]  [GROUP BY clause] [HAVING clause] [ORDER BY clause]
Select Into To create an empty table, include a where clause that will always be false select * into temptitles from titles where 1 = 2  It is highly recommended to do this and then insert the data into the table in a separate operation Rules, defaults, constraints, indexes, triggers, etc. are not associated with the new table
Views Views are nothing more than a name for a select statement that is stored in the database Behave exactly like a table Do not store any data May include more than one table Simplify and/or customize data Provides independence from the database schema Provides security The main factor in using security should usually be security
Views CREATE VIEW [ owner . ] view_name [ ( column_name  [ ,   column_name ]... ) ] [WITH ENCRYPTION] AS  select_statement  [WITH CHECK OPTION] Always explicitly specify the columns that will be included With encryption means that the definition of the view is encrypted when it is stored
With Check Option The with check option restricts the data that can be inserted and updated through a view Leaving this out, allows inserts and updates to the underlying data that might not show up in the view due to the where clause When this is included, the insert and update must conform to the where clause of the view
Restrictions Another view can be included in the definition of a view, but only 16 tables/views can be emcompassed Clauses not allowed order by compute/compute by select into Updates can be performed through a view as long as only one table at a time is updated Updates can not be performed is a distinct, group by, or aggregate is included in the view
Unit 6 Review Temporary tables can be created to hold intermediate result sets Temp tables are either local or global Select into can be used to create either a permanent or temporary table Views can be defined to provide alternate access to data Views primary consideration should be security
Unit 6 Exercises Time allotted for exercises is 30 minutes

More Related Content

What's hot (20)

PPS
Procedures/functions of rdbms
jain.pralabh
 
PDF
Stored-Procedures-Presentation
Chuck Walker
 
PPTX
Stored procedure in sql server
baabtra.com - No. 1 supplier of quality freshers
 
PPT
Lecture 2. MS SQL. Stored procedures.
Alexey Furmanov
 
PPTX
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Advance Sql Server Store procedure Presentation
Amin Uddin
 
PDF
Bypass dbms assert
fangjiafu
 
PPTX
Stored procedure
Deepak Sharma
 
PPTX
Function & procedure
atishupadhyay
 
PDF
PL/SQL TRIGGERS
Lakshman Basnet
 
PPT
Lecture 4. MS SQL. DML Triggers
Alexey Furmanov
 
PPT
Oracle Database Trigger
Eryk Budi Pratama
 
PPTX
MySql Triggers Tutorial - The Webs Academy
thewebsacademy
 
DOC
Subqueries views stored procedures_triggers_transactions
maxpane
 
PPT
Less08 Schema
vivaankumar
 
PPTX
View, Store Procedure & Function and Trigger in MySQL - Thaipt
Framgia Vietnam
 
PPTX
5. stored procedure and functions
Amrit Kaur
 
PPT
Less09 Data
vivaankumar
 
PPTX
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Procedures/functions of rdbms
jain.pralabh
 
Stored-Procedures-Presentation
Chuck Walker
 
Stored procedure in sql server
baabtra.com - No. 1 supplier of quality freshers
 
Lecture 2. MS SQL. Stored procedures.
Alexey Furmanov
 
Advance Sql Server Store procedure Presentation
Amin Uddin
 
Bypass dbms assert
fangjiafu
 
Stored procedure
Deepak Sharma
 
Function & procedure
atishupadhyay
 
PL/SQL TRIGGERS
Lakshman Basnet
 
Lecture 4. MS SQL. DML Triggers
Alexey Furmanov
 
Oracle Database Trigger
Eryk Budi Pratama
 
MySql Triggers Tutorial - The Webs Academy
thewebsacademy
 
Subqueries views stored procedures_triggers_transactions
maxpane
 
Less08 Schema
vivaankumar
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
Framgia Vietnam
 
5. stored procedure and functions
Amrit Kaur
 
Less09 Data
vivaankumar
 
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 

Viewers also liked (20)

PDF
1º trim 2016 boletin bibliografico
Daniel Francisco Doffo
 
PPT
강의자료8
Young Wook Kim
 
PPT
Solution[1]
Alex Beless
 
PPS
業務九把刀
superspeaker
 
PDF
How to Identify, Target, and Connect with Audiences —ECPA 2014
Peter McCarthy
 
PPTX
Prototyping ana luis
Ana Luis
 
PDF
E ticaret konferansı- 7 mayıs2015
Mustafa Kuğu
 
PPTX
Nueva zelanda
JORGE Guerrero
 
PPTX
Comparatives & superlatives
Lorenachumbravo
 
PDF
Seo september 2012
CIM East of England
 
PPTX
Mengenal & Mendaftar di Gmail
Ananta Bangun
 
PPT
BDD demisztifikálva
Open Academy
 
PPTX
CAS/CADE presentation 2013
danbuzzo
 
PPTX
Indefinite pronouns updated
Lorenachumbravo
 
PPTX
What Is CRM?
BrainSell Technologies
 
PPT
Chuong trinh thuc tap sinh
ionetwork
 
PPTX
Glb varshets-nasko
Krasimira Kaneva
 
DOC
שמאי מקרקעין - הנדסת הבניין
tal kerem
 
1º trim 2016 boletin bibliografico
Daniel Francisco Doffo
 
강의자료8
Young Wook Kim
 
Solution[1]
Alex Beless
 
業務九把刀
superspeaker
 
How to Identify, Target, and Connect with Audiences —ECPA 2014
Peter McCarthy
 
Prototyping ana luis
Ana Luis
 
E ticaret konferansı- 7 mayıs2015
Mustafa Kuğu
 
Nueva zelanda
JORGE Guerrero
 
Comparatives & superlatives
Lorenachumbravo
 
Seo september 2012
CIM East of England
 
Mengenal & Mendaftar di Gmail
Ananta Bangun
 
BDD demisztifikálva
Open Academy
 
CAS/CADE presentation 2013
danbuzzo
 
Indefinite pronouns updated
Lorenachumbravo
 
Chuong trinh thuc tap sinh
ionetwork
 
Glb varshets-nasko
Krasimira Kaneva
 
שמאי מקרקעין - הנדסת הבניין
tal kerem
 
Ad

Similar to Intro to tsql unit 6 (20)

PPT
Sql server introduction to sql server
Vibrant Technologies & Computers
 
PDF
Implementing views
sqlschoolgr
 
PPTX
Designing and Creating Views, Inline Functions, and Synonyms
Tayba Farooqui
 
PPT
Module05
Sridhar P
 
PPTX
Oracle Database View
Eryk Budi Pratama
 
PPT
MS SQL Server.ppt
QuyVo27
 
PPTX
SQL Sort Notes
ShivaAdasule
 
PPT
Database Foundation Training
Franky Lao
 
PDF
My sql102
Dave Stokes
 
PDF
Sql ch 13 - sql-views
Mukesh Tekwani
 
PPT
Les11
Vijay Kumar
 
PPTX
Views
myrajendra
 
PPTX
Views
myrajendra
 
PPTX
Views
myrajendra
 
PPTX
Microsoft SQL 000000000000000000001.pptx
HaribabuKonakanchi1
 
PPT
chap 9 dbms.ppt
arjun431527
 
Sql server introduction to sql server
Vibrant Technologies & Computers
 
Implementing views
sqlschoolgr
 
Designing and Creating Views, Inline Functions, and Synonyms
Tayba Farooqui
 
Module05
Sridhar P
 
Oracle Database View
Eryk Budi Pratama
 
MS SQL Server.ppt
QuyVo27
 
SQL Sort Notes
ShivaAdasule
 
Database Foundation Training
Franky Lao
 
My sql102
Dave Stokes
 
Sql ch 13 - sql-views
Mukesh Tekwani
 
Views
myrajendra
 
Views
myrajendra
 
Views
myrajendra
 
Microsoft SQL 000000000000000000001.pptx
HaribabuKonakanchi1
 
chap 9 dbms.ppt
arjun431527
 
Ad

More from Syed Asrarali (12)

PPT
Intro to tsql unit 14
Syed Asrarali
 
PPT
Intro to tsql unit 13
Syed Asrarali
 
PPT
Intro to tsql unit 10
Syed Asrarali
 
PPT
Intro to tsql unit 9
Syed Asrarali
 
PPT
Intro to tsql unit 8
Syed Asrarali
 
PPT
Intro to tsql unit 7
Syed Asrarali
 
PPT
Intro to tsql unit 5
Syed Asrarali
 
PPT
Intro to tsql unit 4
Syed Asrarali
 
PPT
Intro to tsql unit 3
Syed Asrarali
 
PPT
Intro to tsql unit 2
Syed Asrarali
 
PPT
Intro to tsql unit 1
Syed Asrarali
 
PPT
Intro to tsql unit 11
Syed Asrarali
 
Intro to tsql unit 14
Syed Asrarali
 
Intro to tsql unit 13
Syed Asrarali
 
Intro to tsql unit 10
Syed Asrarali
 
Intro to tsql unit 9
Syed Asrarali
 
Intro to tsql unit 8
Syed Asrarali
 
Intro to tsql unit 7
Syed Asrarali
 
Intro to tsql unit 5
Syed Asrarali
 
Intro to tsql unit 4
Syed Asrarali
 
Intro to tsql unit 3
Syed Asrarali
 
Intro to tsql unit 2
Syed Asrarali
 
Intro to tsql unit 1
Syed Asrarali
 
Intro to tsql unit 11
Syed Asrarali
 

Recently uploaded (20)

PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Q2 Leading a Tableau User Group - Onboarding
lward7
 
PDF
Learn Computer Forensics, Second Edition
AnuraShantha7
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Q2 Leading a Tableau User Group - Onboarding
lward7
 
Learn Computer Forensics, Second Edition
AnuraShantha7
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 

Intro to tsql unit 6

  • 1. Introduction To SQL Unit 6 Modern Business Technology Introduction To TSQL Unit 6 Developed by Michael Hotek
  • 2. Temporary Tables Temp tables are used to hold intermediate result sets for further processing These are used when you need to perform a process that can not be done in a single SQL statement They come in two different types local accessible only to that connection preceeded by a # ex: #authors dropped when the session disconnects global accessible to all connections must be explicitly dropped preceeded by ## ex: ##authors Names can only be 13 characters long
  • 3. Temp tables can be a powerful addition to your code They should be minimized at all costs Many people overuse temp tables Poor database design Lack of SQL knowledge Lazy Temp tables can impose a significant drain on system resources Temporary Tables
  • 4. Select Into Select into can be used to create a new table based upon a select statement Creates the table to match the structure of the select list Adds any data from the select The database option select into/bulkcopy needs to be turned on SELECT [ALL | DISTINCT] select_list [ INTO [ new_table_name ]] [FROM { table_name | view_name }[ ( optimizer_hints ) ] [[ , { table_name2 | view_name2 }[ ( optimizer_hints ) ] [... , { table_name16 | view_name16 }[ ( optimizer_hints ) ]]] [WHERE clause] [GROUP BY clause] [HAVING clause] [ORDER BY clause]
  • 5. Select Into To create an empty table, include a where clause that will always be false select * into temptitles from titles where 1 = 2 It is highly recommended to do this and then insert the data into the table in a separate operation Rules, defaults, constraints, indexes, triggers, etc. are not associated with the new table
  • 6. Views Views are nothing more than a name for a select statement that is stored in the database Behave exactly like a table Do not store any data May include more than one table Simplify and/or customize data Provides independence from the database schema Provides security The main factor in using security should usually be security
  • 7. Views CREATE VIEW [ owner . ] view_name [ ( column_name [ , column_name ]... ) ] [WITH ENCRYPTION] AS select_statement [WITH CHECK OPTION] Always explicitly specify the columns that will be included With encryption means that the definition of the view is encrypted when it is stored
  • 8. With Check Option The with check option restricts the data that can be inserted and updated through a view Leaving this out, allows inserts and updates to the underlying data that might not show up in the view due to the where clause When this is included, the insert and update must conform to the where clause of the view
  • 9. Restrictions Another view can be included in the definition of a view, but only 16 tables/views can be emcompassed Clauses not allowed order by compute/compute by select into Updates can be performed through a view as long as only one table at a time is updated Updates can not be performed is a distinct, group by, or aggregate is included in the view
  • 10. Unit 6 Review Temporary tables can be created to hold intermediate result sets Temp tables are either local or global Select into can be used to create either a permanent or temporary table Views can be defined to provide alternate access to data Views primary consideration should be security
  • 11. Unit 6 Exercises Time allotted for exercises is 30 minutes

Editor's Notes