SlideShare a Scribd company logo
SQL/212 SQL Programming Workshop 3 – Modifying Data, Managing the Database Bookstore SQL212 Module 3
SQL212 Contact Information Bookstore SQL212 Module 3 P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com [email_address]   Copyright 2001-2009. All rights reserved.
SQL212 Module 3 Part 1 – Modifying Data Part 2 – Managing Database Structures Part 3 – Creating Views and Indexes Part 4 -- Security Bookstore SQL212 Module 3
SQL/212 SQL Programming Part 1 – Modifying Data Bookstore SQL212 Module 3
Bookstore SQL212 Module 3 Relational Database with constraints (from text)
Data Modification Statements Insert Update Delete Bookstore SQL212 Module 3
Data Modification Statements End-user rarely sees these statements Application developer prepares these statements “behind the scenes” based on forms filled out by user Bookstore SQL212 Module 3
Insert Adds new rows to an existing table Two forms: Single Row Multi-Row Bookstore SQL212 Module 3
Single Row Insert Bookstore SQL212 Module 3 Basic Syntax: Insert [into] <table-name> Values (<value-list>)
Single Row Insert Bookstore SQL212 Module 3 Basic Example: insert into  sources(source_numb, source_name, source_street) values (22,'Specialty Books', 'Canal Street')
Insert Statement Bookstore SQL212 Module 3
Sources table after Insert Bookstore SQL212 Module 3
Multi-row Insert Bookstore SQL212 Module 3 Basic Syntax: Insert [into] <table-name> Select <select-statement> We will do this after creating a new table later in this module
Update Updates fields in an existing row Bookstore SQL212 Module 3 Basic Syntax: Update <table-name> Set <field1> = new value, <field2> = new value,… Where <selection-criteria>
Update Increase Ingram prices by 10% Bookstore SQL212 Module 3 Example: Update books Set retail_price = retail_price *1.10 Where source_numb = 1
Ingram Book Prices before Update Bookstore SQL212 Module 3
Ingram Book Prices after Update Bookstore SQL212 Module 3
Delete Deletes one or more rows Bookstore SQL212 Module 3 Basic Syntax: Delete from <table-name> Where <selection-criteria>
Delete Bookstore SQL212 Module 3 Example: delete the source we added Delete from sources Where source_numb = 22
Delete Bookstore SQL212 Module 3
Sources table after Delete Bookstore SQL212 Module 3
Delete and Referential Integrity Can affect referential integrity when deleting a “parent” row Can do following with child… Cascade: delete the child row Set null: set the child’s foreign key null Set default: as above but to default value No action: don’t allow delete of parent row Referential integrity can be established when creating or modifying table structures which we will look at later in the class Bookstore SQL212 Module 3
SQL/212 SQL Programming Part 2– Managing Database Structures Bookstore SQL212 Module 3
Schemas Logical view of a database; sort of a “sub-database” – we will not cover these in this module… Catalogs Clusters Domains (somewhat like a user defined datatype) These topics are highly dependent upon the vendor DBMS and installation practices In Oracle you are logged in to your schema Bookstore SQL212 Module 3
Tables Two types Base tables Temporary tables  Local (or module scope) Global (session scope) We will create base tables in this class Bookstore SQL212 Module 3
Creating Tables Use create statement Specify: Columns with data types and column constraints Table constraints Foreign key references Primary key designation Bookstore SQL212 Module 3
Data Types Int – integers or whole numbers Ex: how_many int Char – fixed length fields Ex: state char(2) Varchar/Varchar2 – variable length fields Ex: address varchar2(35) Money – money field Date/Datetime – date and time  And many others – see documentation or Help Bookstore SQL212 Module 3
Create Table Bookstore SQL212 Module 3 Basic syntax: Create table <table-name> <column1> <datatype> <constraints> ,.. <column1> <datatype> <constraints> … <table constraints> Note: often preceded by a drop
Temporary Tables Bookstore SQL212 Module 3 Basic syntax: Create [global] temporary table <table-name> <rest of statement as for normal create> Note: SQL Server uses a different syntax. Just put a #in front of the table name as in #mytable. Access doesn’t have true temporary tables.
Column Constraints Primary key Not NULL CHECK clause Default Unique Bookstore SQL212 Module 3
Table Constraints Primary Key Foreign Key Compare fields against each other. I.e. ship_date >= order_date Bookstore SQL212 Module 3
But first – the Drop Statement Deletes a database “object” Drop table <table-name> Drop view <view-name> Drop index <index-name> Drop domain <domain-name> Bookstore SQL212 Module 3
Create Table Bookstore SQL212 Module 3 Example 1: Create  a summary table Create  table summary( isbn varchar2(20)  primary key , How_many int  check  (how_many >= 0), Constraint  isbn_fk Foreign key  (isbn)  references  books(isbn) )
Create Summary Table Bookstore SQL212 Module 3
Constraints on Summary Table Bookstore SQL212 Module 3
Multi-row Insert Bookstore SQL212 Module 3 Basic Syntax: Insert [into] <table-name> Select <select-statement>
Multi-row Insert Bookstore SQL212 Module 3 Basic Example:  (store # times each book ordered) Insert into summary(isbn, how_many) Select isbn, count(*) From orderlines Group by isbn;
Multi-row Insert Bookstore SQL212 Module 3
Bookstore SQL212 Module 3 After multi-row insert in MS Access
SQL/212 SQL Programming Part 3 – Creating Views and Indexes, Modifying Structures Bookstore SQL212 Module 3
Views Think of a view as a named query wherein the definition is stored in the database Can be read like a table Some are updateable Bookstore SQL212 Module 3
Views Bookstore SQL212 Module 3 Basic syntax: Create view <view-name> (<column-list>) As <select statement>
Creating a View Bookstore SQL212 Module 3 Example: show inventory for each book
Using Views Can be used like a table subject to various limitations Cannot insert into grouped queries, etc. Etc. Sample syntax: select  column-list from employee_view Bookstore SQL212 Module 3
Using a View Bookstore SQL212 Module 3
Indexes Used  to speed searches, joins, etc. Placed on: primary and foreign keys Secondary keys In commercial practice often managed by DBA’s for large databases Bookstore SQL212 Module 3
Indexes Bookstore SQL212 Module 3 Basic syntax: Create [unique] index <index-name>  On <table-name> (field-name> [desc]) Note: can place index on a composite key;  ex: state and city
Indexes Bookstore SQL212 Module 3 Basic example: create index state_inx on customers(customer_state) Add an index on state to speed searches and reporting
Bookstore SQL212 Module 3 After indexing on customer_state
State_inx in Oracle Bookstore SQL212 Module 3
Modifying a Table Design Applies to tables Use ALTER statement Add columns Delete columns Rename columns Add column constraints Add table constraints Bookstore SQL212 Module 3
Modifying a Table Design Bookstore SQL212 Module 3 Basic syntax: Alter <table-name> Add <field-name>, Add <table-constraint>, Modify <field-name> Etc.
Modify a Table Design Bookstore SQL212 Module 3 Example: add a phone number field alter table publishers add phone char(12);
Bookstore SQL212 Module 3 After alter publishers table
SQL/212 SQL Programming Part 4 – Security Bookstore SQL212 Module 3
Security Important DBA function Beyond scope of this course Typically controlled through Enterprise Manager or Studio GUI’s In commercial practice application security frequently controlled via own login and a “users” table or similar Bookstore SQL212 Module 3
Security Specifics can vary by product Access: workgroup administrator SQL Server: users, roles Oracle: users, roles Bookstore SQL212 Module 3
SQL Security Statements Grant Revoke Deny Bookstore SQL212 Module 3
Grant Bookstore SQL212 Module 3 Syntax: Grant <access-right> [with grant option] On <object> to <user>   Note: by default only tables owners and admins can access a table. Others must be granted the relevant rights.
Access Rights Select Update Insert Delete References All privileges Bookstore SQL212 Module 3
Grant Bookstore SQL212 Module 3 Example: Give user ddurso the permission to update the employees table. Grant update On employees to ddurso
Revoke Revokes the rights Syntax similar to grant Bookstore SQL212 Module 3 [end module]
Notes Bookstore SQL212 Module 3
Notes Bookstore SQL212 Module 3

More Related Content

PPT
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
PPT
SQL212.2 Introduction to SQL using Oracle Module 2
PPT
SQL212.1 Introduction to SQL using Oracle Module 1
PPTX
Schema201 webinar
PPTX
Magento 2 theming - knowledge sharing session by suman kc
PPT
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
PPT
Module05
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.1 Introduction to SQL using Oracle Module 1
Schema201 webinar
Magento 2 theming - knowledge sharing session by suman kc
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
Module05

What's hot (20)

PDF
Assignment#02
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
PDF
Practical index dms 22319
PDF
Assignment#07
PDF
Dms 22319 micro project
ODP
PPTX
Oracle: DDL
PDF
Sql ch 13 - sql-views
PDF
Sql smart reference_by_prasad
PDF
Assignment#06
PPTX
Commands of DML in SQL
DOCX
SQL Tutorial for BCA-2
PDF
Access tips access and sql part 1 setting the sql scene
PPT
Drupal CMS: generating reports with the Forena module.
PDF
Assignment#05
PPTX
SQL - DML and DDL Commands
PPTX
Getting Started with MySQL II
DOCX
Assignment#02
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
Practical index dms 22319
Assignment#07
Dms 22319 micro project
Oracle: DDL
Sql ch 13 - sql-views
Sql smart reference_by_prasad
Assignment#06
Commands of DML in SQL
SQL Tutorial for BCA-2
Access tips access and sql part 1 setting the sql scene
Drupal CMS: generating reports with the Forena module.
Assignment#05
SQL - DML and DDL Commands
Getting Started with MySQL II
Ad

Viewers also liked (20)

PPT
Dahle Communication Group
PPS
one woman satisfies 12 men
PPS
Nice Travel
PPTX
How to find new Music
PDF
How to Do Lean Planning (and what does that mean anyway)
PPT
Rockets
PDF
081223-“明星制造”百脑汇高校才艺大赛
PDF
Social enter strategic planning
PPS
Lips & Mouth
PDF
Marketing Overview 1
PPTX
5 points on twitter with frank brunke
PDF
From Neo to Trinity: The Matrix Reinvented
PPT
4005-713 ` XML Architecture, Tools & Technique ` Presentation
PPT
Hurricanes &amp; Tornados
PPT
SQL206 SQL Median
PPT
Being Caught Stealing (Con La Mano En El Pastel)
PPS
Buenas Fotos Mal Fondo
PDF
ifilms Company Profile
PPT
Allemand
Dahle Communication Group
one woman satisfies 12 men
Nice Travel
How to find new Music
How to Do Lean Planning (and what does that mean anyway)
Rockets
081223-“明星制造”百脑汇高校才艺大赛
Social enter strategic planning
Lips & Mouth
Marketing Overview 1
5 points on twitter with frank brunke
From Neo to Trinity: The Matrix Reinvented
4005-713 ` XML Architecture, Tools & Technique ` Presentation
Hurricanes &amp; Tornados
SQL206 SQL Median
Being Caught Stealing (Con La Mano En El Pastel)
Buenas Fotos Mal Fondo
ifilms Company Profile
Allemand
Ad

Similar to SQL212.3 Introduction to SQL using Oracle Module 3 (20)

PPT
SQL200.3 Module 3
PPT
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
PPT
Lecture 14 Database.ppt
DOC
Module 3
PPTX
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
PPTX
SQL.pptx for the begineers and good know
PPTX
Database Overview
PPT
Lec 1 = introduction to structured query language (sql)
PPT
15925 structured query
PPT
Introduction to Structured Query Language (SQL) (1).ppt
PPT
Introduction to Structured Query Language (SQL).ppt
PDF
Intruduction to SQL.Structured Query Language(SQL}
PPT
Introduction to Structured Query Language (SQL).ppt
PPT
mis4200notes4_2.ppt
PPT
Introduction to structured query language (sql)
PPT
PPT
chapter 8 SQL.ppt
PPTX
SQL command practical power point slides, which help you in learning sql.pptx
SQL200.3 Module 3
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
Lecture 14 Database.ppt
Module 3
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SQL.pptx for the begineers and good know
Database Overview
Lec 1 = introduction to structured query language (sql)
15925 structured query
Introduction to Structured Query Language (SQL) (1).ppt
Introduction to Structured Query Language (SQL).ppt
Intruduction to SQL.Structured Query Language(SQL}
Introduction to Structured Query Language (SQL).ppt
mis4200notes4_2.ppt
Introduction to structured query language (sql)
chapter 8 SQL.ppt
SQL command practical power point slides, which help you in learning sql.pptx

More from Dan D'Urso (20)

PPT
SQL201S Accelerated Introduction to MySQL Queries
PPT
LCD201d Database Diagramming with Lucidchart
PPTX
Database Normalization
PPT
VIS201d Visio Database Diagramming
PPT
PRJ101a Project 2013 Accelerated
PPT
PRJ101xl Project Libre Basic Training
PPT
Introduction to coding using Python
PPTX
Stem conference
PDF
SQL200A Microsoft Access SQL Design
PPTX
Microsoft access self joins
PDF
SQL302 Intermediate SQL
PDF
AIN106 Access Reporting and Analysis
PPT
SQL302 Intermediate SQL Workshop 3
PPT
SQL302 Intermediate SQL Workshop 2
PDF
Course Catalog
PPT
SQL302 Intermediate SQL Workshop 1
PDF
SQL212 Oracle SQL Manual
PDF
SQL201W MySQL SQL Manual
PDF
AIN100
PDF
SQL202 SQL Server SQL Manual
SQL201S Accelerated Introduction to MySQL Queries
LCD201d Database Diagramming with Lucidchart
Database Normalization
VIS201d Visio Database Diagramming
PRJ101a Project 2013 Accelerated
PRJ101xl Project Libre Basic Training
Introduction to coding using Python
Stem conference
SQL200A Microsoft Access SQL Design
Microsoft access self joins
SQL302 Intermediate SQL
AIN106 Access Reporting and Analysis
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 2
Course Catalog
SQL302 Intermediate SQL Workshop 1
SQL212 Oracle SQL Manual
SQL201W MySQL SQL Manual
AIN100
SQL202 SQL Server SQL Manual

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Approach and Philosophy of On baking technology
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Big Data Technologies - Introduction.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
A Presentation on Artificial Intelligence
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation_ Review paper, used for researhc scholars
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Approach and Philosophy of On baking technology
sap open course for s4hana steps from ECC to s4
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Big Data Technologies - Introduction.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
A Presentation on Artificial Intelligence
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
A comparative analysis of optical character recognition models for extracting...
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”

SQL212.3 Introduction to SQL using Oracle Module 3

  • 1. SQL/212 SQL Programming Workshop 3 – Modifying Data, Managing the Database Bookstore SQL212 Module 3
  • 2. SQL212 Contact Information Bookstore SQL212 Module 3 P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com [email_address] Copyright 2001-2009. All rights reserved.
  • 3. SQL212 Module 3 Part 1 – Modifying Data Part 2 – Managing Database Structures Part 3 – Creating Views and Indexes Part 4 -- Security Bookstore SQL212 Module 3
  • 4. SQL/212 SQL Programming Part 1 – Modifying Data Bookstore SQL212 Module 3
  • 5. Bookstore SQL212 Module 3 Relational Database with constraints (from text)
  • 6. Data Modification Statements Insert Update Delete Bookstore SQL212 Module 3
  • 7. Data Modification Statements End-user rarely sees these statements Application developer prepares these statements “behind the scenes” based on forms filled out by user Bookstore SQL212 Module 3
  • 8. Insert Adds new rows to an existing table Two forms: Single Row Multi-Row Bookstore SQL212 Module 3
  • 9. Single Row Insert Bookstore SQL212 Module 3 Basic Syntax: Insert [into] <table-name> Values (<value-list>)
  • 10. Single Row Insert Bookstore SQL212 Module 3 Basic Example: insert into sources(source_numb, source_name, source_street) values (22,'Specialty Books', 'Canal Street')
  • 11. Insert Statement Bookstore SQL212 Module 3
  • 12. Sources table after Insert Bookstore SQL212 Module 3
  • 13. Multi-row Insert Bookstore SQL212 Module 3 Basic Syntax: Insert [into] <table-name> Select <select-statement> We will do this after creating a new table later in this module
  • 14. Update Updates fields in an existing row Bookstore SQL212 Module 3 Basic Syntax: Update <table-name> Set <field1> = new value, <field2> = new value,… Where <selection-criteria>
  • 15. Update Increase Ingram prices by 10% Bookstore SQL212 Module 3 Example: Update books Set retail_price = retail_price *1.10 Where source_numb = 1
  • 16. Ingram Book Prices before Update Bookstore SQL212 Module 3
  • 17. Ingram Book Prices after Update Bookstore SQL212 Module 3
  • 18. Delete Deletes one or more rows Bookstore SQL212 Module 3 Basic Syntax: Delete from <table-name> Where <selection-criteria>
  • 19. Delete Bookstore SQL212 Module 3 Example: delete the source we added Delete from sources Where source_numb = 22
  • 21. Sources table after Delete Bookstore SQL212 Module 3
  • 22. Delete and Referential Integrity Can affect referential integrity when deleting a “parent” row Can do following with child… Cascade: delete the child row Set null: set the child’s foreign key null Set default: as above but to default value No action: don’t allow delete of parent row Referential integrity can be established when creating or modifying table structures which we will look at later in the class Bookstore SQL212 Module 3
  • 23. SQL/212 SQL Programming Part 2– Managing Database Structures Bookstore SQL212 Module 3
  • 24. Schemas Logical view of a database; sort of a “sub-database” – we will not cover these in this module… Catalogs Clusters Domains (somewhat like a user defined datatype) These topics are highly dependent upon the vendor DBMS and installation practices In Oracle you are logged in to your schema Bookstore SQL212 Module 3
  • 25. Tables Two types Base tables Temporary tables Local (or module scope) Global (session scope) We will create base tables in this class Bookstore SQL212 Module 3
  • 26. Creating Tables Use create statement Specify: Columns with data types and column constraints Table constraints Foreign key references Primary key designation Bookstore SQL212 Module 3
  • 27. Data Types Int – integers or whole numbers Ex: how_many int Char – fixed length fields Ex: state char(2) Varchar/Varchar2 – variable length fields Ex: address varchar2(35) Money – money field Date/Datetime – date and time And many others – see documentation or Help Bookstore SQL212 Module 3
  • 28. Create Table Bookstore SQL212 Module 3 Basic syntax: Create table <table-name> <column1> <datatype> <constraints> ,.. <column1> <datatype> <constraints> … <table constraints> Note: often preceded by a drop
  • 29. Temporary Tables Bookstore SQL212 Module 3 Basic syntax: Create [global] temporary table <table-name> <rest of statement as for normal create> Note: SQL Server uses a different syntax. Just put a #in front of the table name as in #mytable. Access doesn’t have true temporary tables.
  • 30. Column Constraints Primary key Not NULL CHECK clause Default Unique Bookstore SQL212 Module 3
  • 31. Table Constraints Primary Key Foreign Key Compare fields against each other. I.e. ship_date >= order_date Bookstore SQL212 Module 3
  • 32. But first – the Drop Statement Deletes a database “object” Drop table <table-name> Drop view <view-name> Drop index <index-name> Drop domain <domain-name> Bookstore SQL212 Module 3
  • 33. Create Table Bookstore SQL212 Module 3 Example 1: Create a summary table Create table summary( isbn varchar2(20) primary key , How_many int check (how_many >= 0), Constraint isbn_fk Foreign key (isbn) references books(isbn) )
  • 34. Create Summary Table Bookstore SQL212 Module 3
  • 35. Constraints on Summary Table Bookstore SQL212 Module 3
  • 36. Multi-row Insert Bookstore SQL212 Module 3 Basic Syntax: Insert [into] <table-name> Select <select-statement>
  • 37. Multi-row Insert Bookstore SQL212 Module 3 Basic Example: (store # times each book ordered) Insert into summary(isbn, how_many) Select isbn, count(*) From orderlines Group by isbn;
  • 38. Multi-row Insert Bookstore SQL212 Module 3
  • 39. Bookstore SQL212 Module 3 After multi-row insert in MS Access
  • 40. SQL/212 SQL Programming Part 3 – Creating Views and Indexes, Modifying Structures Bookstore SQL212 Module 3
  • 41. Views Think of a view as a named query wherein the definition is stored in the database Can be read like a table Some are updateable Bookstore SQL212 Module 3
  • 42. Views Bookstore SQL212 Module 3 Basic syntax: Create view <view-name> (<column-list>) As <select statement>
  • 43. Creating a View Bookstore SQL212 Module 3 Example: show inventory for each book
  • 44. Using Views Can be used like a table subject to various limitations Cannot insert into grouped queries, etc. Etc. Sample syntax: select column-list from employee_view Bookstore SQL212 Module 3
  • 45. Using a View Bookstore SQL212 Module 3
  • 46. Indexes Used to speed searches, joins, etc. Placed on: primary and foreign keys Secondary keys In commercial practice often managed by DBA’s for large databases Bookstore SQL212 Module 3
  • 47. Indexes Bookstore SQL212 Module 3 Basic syntax: Create [unique] index <index-name> On <table-name> (field-name> [desc]) Note: can place index on a composite key; ex: state and city
  • 48. Indexes Bookstore SQL212 Module 3 Basic example: create index state_inx on customers(customer_state) Add an index on state to speed searches and reporting
  • 49. Bookstore SQL212 Module 3 After indexing on customer_state
  • 50. State_inx in Oracle Bookstore SQL212 Module 3
  • 51. Modifying a Table Design Applies to tables Use ALTER statement Add columns Delete columns Rename columns Add column constraints Add table constraints Bookstore SQL212 Module 3
  • 52. Modifying a Table Design Bookstore SQL212 Module 3 Basic syntax: Alter <table-name> Add <field-name>, Add <table-constraint>, Modify <field-name> Etc.
  • 53. Modify a Table Design Bookstore SQL212 Module 3 Example: add a phone number field alter table publishers add phone char(12);
  • 54. Bookstore SQL212 Module 3 After alter publishers table
  • 55. SQL/212 SQL Programming Part 4 – Security Bookstore SQL212 Module 3
  • 56. Security Important DBA function Beyond scope of this course Typically controlled through Enterprise Manager or Studio GUI’s In commercial practice application security frequently controlled via own login and a “users” table or similar Bookstore SQL212 Module 3
  • 57. Security Specifics can vary by product Access: workgroup administrator SQL Server: users, roles Oracle: users, roles Bookstore SQL212 Module 3
  • 58. SQL Security Statements Grant Revoke Deny Bookstore SQL212 Module 3
  • 59. Grant Bookstore SQL212 Module 3 Syntax: Grant <access-right> [with grant option] On <object> to <user> Note: by default only tables owners and admins can access a table. Others must be granted the relevant rights.
  • 60. Access Rights Select Update Insert Delete References All privileges Bookstore SQL212 Module 3
  • 61. Grant Bookstore SQL212 Module 3 Example: Give user ddurso the permission to update the employees table. Grant update On employees to ddurso
  • 62. Revoke Revokes the rights Syntax similar to grant Bookstore SQL212 Module 3 [end module]