SlideShare a Scribd company logo
1 of 31
Created by: Mrs. Rajni
Asst. Prof. in CS
Pt .Mohan Lal SD College for women
,Gurdaspur
 Explore basic commands and functions of
SQL
 How to use SQL for data administration (to
create tables, indexes, and views)
 How to use SQL for data manipulation (to
add, modify, delete, and retrieve data)
 How to use SQL to query a database to
extract useful information
2
 SQL functions fit into two broad categories:
 Data definition language
 SQL includes commands to:
 Create database objects, such as tables, indexes,
and views
 Define access rights to those database objects
 Data manipulation language
 Includes commands to insert, update, delete, and
retrieve data within database tables
3
 SQL is relatively easy to learn
 Basic command set has vocabulary of less
than 100 words
 Nonprocedural language
 American National Standards Institute (ANSI)
prescribes a standard SQL
 Several SQL dialects exist
4
5
6
7
 Examine simple database model and
database tables that will form basis for many
SQL examples
 Understand data environment
8
 Data type selection is usually dictated by
nature of data and by intended use
 Pay close attention to expected use of
attributes for sorting and data retrieval
purposes
9
10
 Use one line per column (attribute)
definition
 Use spaces to line up attribute
characteristics and constraints
 Table and attribute names are capitalized
 NOT NULL specification
 UNIQUE specification
11
 Primary key attributes contain both a NOT
NULL and a UNIQUE specification
 RDBMS will automatically enforce referential
integrity for foreign keys
 Command sequence ends with semicolon
12
 NOT NULL constraint
 Ensures that column does not accept nulls
 UNIQUE constraint
 Ensures that all values in column are unique
 DEFAULT constraint
 Assigns value to attribute when a new row is
added to table
 CHECK constraint
 Validates data when attribute value is entered
13
 Adding table rows
 Saving table changes
 Listing table rows
 Updating table rows
 Restoring table contents
 Deleting table rows
 Inserting table rows with a select subquery
14
 INSERT
 Used to enter data into table
 Syntax:
 INSERT INTO columnname
VALUES (value1, value2, … , valuen);
15
When entering values, notice that:
 Row contents are entered between
parentheses
 Character and date values are entered
between apostrophes
 Numerical entries are not enclosed in
apostrophes
 Attribute entries are separated by commas
 A value is required for each column
Use NULL for unknown values
16
 Changes made to table contents are not
physically saved on disk until, one of the
following occurs:
 Database is closed
 Program is closed
 COMMIT command is used
 Syntax:
 COMMIT [WORK];
 Will permanently save any changes made to
any table in the database
17
 SELECT
 Used to list contents of table
 Syntax:
 SELECT columnlist
FROM tablename;
 Columnlist represents one or more attributes,
separated by commas
 Asterisk can be used as wildcard character to list
all attributes
18
 UPDATE
 Modify data in a table
 Syntax:
 UPDATE tablename
SET columnname = expression [, columname =
expression]
[WHERE conditionlist];
 If more than one attribute is to be updated
in row, separate corrections with commas
19
ROLLBACK
 Used to restore database to its previous
condition
 Only applicable if COMMIT command has not
been used to permanently store changes in
database
Syntax:
 ROLLBACK;
COMMIT and ROLLBACK only work with
data manipulation commands that are
used to add, modify, or delete table rows
20
 DELETE
 Deletes a table row
 Syntax:
 DELETE FROM tablename
[WHERE conditionlist ];
 WHERE condition is optional
 If WHERE condition is not specified, all rows
from specified table will be deleted
21
 INSERT
 Inserts multiple rows from another table (source)
 Uses SELECT subquery
 Query that is embedded (or nested) inside another query
 Executed first
 Syntax:
 INSERT INTO tablename SELECT columnlist FROM
tablename;
22
 Select partial table contents by placing
restrictions on rows to be included in output
 Add conditional restrictions to SELECT
statement, using WHERE clause
 Syntax:
 SELECT columnlist
FROM tablelist
[ WHERE conditionlist ] ;
23
24
 BETWEEN
 Used to check whether attribute value is within a
range
 IS NULL
 Used to check whether attribute value is null
 LIKE
 Used to check whether attribute value matches
given string pattern
25
 IN
 Used to check whether attribute value matches
any value within a value list
 EXISTS
 Used to check if subquery returns any rows
26
 All changes in table structure are made by
using ALTER command
 Followed by keyword that produces specific
change
 Following three options are available:
 ADD
 MODIFY
 DROP
27
 ALTER can be used to change data type
 Some RDBMSs (such as Oracle) do not permit
changes to data types unless column to be
changed is empty
28
 Aggregate functions
 Special functions that perform arithmetic
computations over a set of rows
 ORDER BY clause
 Used to sort output of SELECT statement
 Can sort by one or more columns and use either
an ascending or descending order
 Join output of multiple tables with SELECT
statement
29
 Natural join uses join condition to match
only rows with equal values in specified
columns
 Right outer join and left outer join used to
select rows that have no matching values in
other related table
30
THANK YOU
31

More Related Content

What's hot (15)

SQL Server Views
SQL Server ViewsSQL Server Views
SQL Server Views
 
Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
 
2. DML_INSERT_DELETE_UPDATE
2. DML_INSERT_DELETE_UPDATE2. DML_INSERT_DELETE_UPDATE
2. DML_INSERT_DELETE_UPDATE
 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL Fundamentals
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
DML Commands
DML CommandsDML Commands
DML Commands
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
3. ddl create
3. ddl create3. ddl create
3. ddl create
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
SQL
SQLSQL
SQL
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
Oracle apps financial online training
Oracle apps financial online trainingOracle apps financial online training
Oracle apps financial online training
 

Similar to Introduction to structured query language (sql) (1)

Introduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).pptIntroduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).pptAshwini Rao
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)Sabana Maharjan
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...SakkaravarthiS1
 
Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}IlgarKarimov3
 
Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}IlgarKarimov3
 
Introduction to Structured Query Language (SQL) (1).ppt
Introduction to Structured Query Language (SQL) (1).pptIntroduction to Structured Query Language (SQL) (1).ppt
Introduction to Structured Query Language (SQL) (1).pptComputerScienceDepar6
 
Lec 1 = introduction to structured query language (sql)
Lec 1 = introduction to structured query language (sql)Lec 1 = introduction to structured query language (sql)
Lec 1 = introduction to structured query language (sql)Faisal Anwar
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxjainendraKUMAR55
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxEliasPetros
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)Dhani Ahmad
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1sagaroceanic11
 
Sql basic things
Sql basic thingsSql basic things
Sql basic thingsNishil Jain
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 

Similar to Introduction to structured query language (sql) (1) (20)

Introduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).pptIntroduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).ppt
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}
 
Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}Intruduction to SQL.Structured Query Language(SQL}
Intruduction to SQL.Structured Query Language(SQL}
 
Sql commands
Sql commandsSql commands
Sql commands
 
Introduction to Structured Query Language (SQL) (1).ppt
Introduction to Structured Query Language (SQL) (1).pptIntroduction to Structured Query Language (SQL) (1).ppt
Introduction to Structured Query Language (SQL) (1).ppt
 
15925 structured query
15925 structured query15925 structured query
15925 structured query
 
Lec 1 = introduction to structured query language (sql)
Lec 1 = introduction to structured query language (sql)Lec 1 = introduction to structured query language (sql)
Lec 1 = introduction to structured query language (sql)
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
 
Interview Questions.pdf
Interview Questions.pdfInterview Questions.pdf
Interview Questions.pdf
 
SQL Query
SQL QuerySQL Query
SQL Query
 
Sql basic things
Sql basic thingsSql basic things
Sql basic things
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Database Overview
Database OverviewDatabase Overview
Database Overview
 

More from RajniKashyap9

More from RajniKashyap9 (7)

Mail merge
Mail mergeMail merge
Mail merge
 
Computer software
Computer softwareComputer software
Computer software
 
Operating systems11 9-07
Operating systems11 9-07Operating systems11 9-07
Operating systems11 9-07
 
C language
C languageC language
C language
 
Basic computer organization
Basic computer organizationBasic computer organization
Basic computer organization
 
Internet
InternetInternet
Internet
 
C operators ppt
C operators pptC operators ppt
C operators ppt
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

Introduction to structured query language (sql) (1)

  • 1. Created by: Mrs. Rajni Asst. Prof. in CS Pt .Mohan Lal SD College for women ,Gurdaspur
  • 2.  Explore basic commands and functions of SQL  How to use SQL for data administration (to create tables, indexes, and views)  How to use SQL for data manipulation (to add, modify, delete, and retrieve data)  How to use SQL to query a database to extract useful information 2
  • 3.  SQL functions fit into two broad categories:  Data definition language  SQL includes commands to:  Create database objects, such as tables, indexes, and views  Define access rights to those database objects  Data manipulation language  Includes commands to insert, update, delete, and retrieve data within database tables 3
  • 4.  SQL is relatively easy to learn  Basic command set has vocabulary of less than 100 words  Nonprocedural language  American National Standards Institute (ANSI) prescribes a standard SQL  Several SQL dialects exist 4
  • 5. 5
  • 6. 6
  • 7. 7
  • 8.  Examine simple database model and database tables that will form basis for many SQL examples  Understand data environment 8
  • 9.  Data type selection is usually dictated by nature of data and by intended use  Pay close attention to expected use of attributes for sorting and data retrieval purposes 9
  • 10. 10
  • 11.  Use one line per column (attribute) definition  Use spaces to line up attribute characteristics and constraints  Table and attribute names are capitalized  NOT NULL specification  UNIQUE specification 11
  • 12.  Primary key attributes contain both a NOT NULL and a UNIQUE specification  RDBMS will automatically enforce referential integrity for foreign keys  Command sequence ends with semicolon 12
  • 13.  NOT NULL constraint  Ensures that column does not accept nulls  UNIQUE constraint  Ensures that all values in column are unique  DEFAULT constraint  Assigns value to attribute when a new row is added to table  CHECK constraint  Validates data when attribute value is entered 13
  • 14.  Adding table rows  Saving table changes  Listing table rows  Updating table rows  Restoring table contents  Deleting table rows  Inserting table rows with a select subquery 14
  • 15.  INSERT  Used to enter data into table  Syntax:  INSERT INTO columnname VALUES (value1, value2, … , valuen); 15
  • 16. When entering values, notice that:  Row contents are entered between parentheses  Character and date values are entered between apostrophes  Numerical entries are not enclosed in apostrophes  Attribute entries are separated by commas  A value is required for each column Use NULL for unknown values 16
  • 17.  Changes made to table contents are not physically saved on disk until, one of the following occurs:  Database is closed  Program is closed  COMMIT command is used  Syntax:  COMMIT [WORK];  Will permanently save any changes made to any table in the database 17
  • 18.  SELECT  Used to list contents of table  Syntax:  SELECT columnlist FROM tablename;  Columnlist represents one or more attributes, separated by commas  Asterisk can be used as wildcard character to list all attributes 18
  • 19.  UPDATE  Modify data in a table  Syntax:  UPDATE tablename SET columnname = expression [, columname = expression] [WHERE conditionlist];  If more than one attribute is to be updated in row, separate corrections with commas 19
  • 20. ROLLBACK  Used to restore database to its previous condition  Only applicable if COMMIT command has not been used to permanently store changes in database Syntax:  ROLLBACK; COMMIT and ROLLBACK only work with data manipulation commands that are used to add, modify, or delete table rows 20
  • 21.  DELETE  Deletes a table row  Syntax:  DELETE FROM tablename [WHERE conditionlist ];  WHERE condition is optional  If WHERE condition is not specified, all rows from specified table will be deleted 21
  • 22.  INSERT  Inserts multiple rows from another table (source)  Uses SELECT subquery  Query that is embedded (or nested) inside another query  Executed first  Syntax:  INSERT INTO tablename SELECT columnlist FROM tablename; 22
  • 23.  Select partial table contents by placing restrictions on rows to be included in output  Add conditional restrictions to SELECT statement, using WHERE clause  Syntax:  SELECT columnlist FROM tablelist [ WHERE conditionlist ] ; 23
  • 24. 24
  • 25.  BETWEEN  Used to check whether attribute value is within a range  IS NULL  Used to check whether attribute value is null  LIKE  Used to check whether attribute value matches given string pattern 25
  • 26.  IN  Used to check whether attribute value matches any value within a value list  EXISTS  Used to check if subquery returns any rows 26
  • 27.  All changes in table structure are made by using ALTER command  Followed by keyword that produces specific change  Following three options are available:  ADD  MODIFY  DROP 27
  • 28.  ALTER can be used to change data type  Some RDBMSs (such as Oracle) do not permit changes to data types unless column to be changed is empty 28
  • 29.  Aggregate functions  Special functions that perform arithmetic computations over a set of rows  ORDER BY clause  Used to sort output of SELECT statement  Can sort by one or more columns and use either an ascending or descending order  Join output of multiple tables with SELECT statement 29
  • 30.  Natural join uses join condition to match only rows with equal values in specified columns  Right outer join and left outer join used to select rows that have no matching values in other related table 30