This document provides an overview of SQL including its introduction, database architectures, data types, keys, built-in functions, commands, joins, views, indexes, triggers, schemas and more. SQL is a tool for organizing, managing and retrieving data from a database. It allows users to define data structure, retrieve, manipulate and control access to data. The document discusses single database, multiple database and multi-location architectures. It also covers data types like character, numeric, date and LOB for Oracle.
The document provides an overview of SQL Server training. It defines data and databases, explaining that a collection of data leads to a database. It also discusses database management systems (DBMS), explaining that a DBMS allows users to create, read, update and delete data in an organized way. The document also covers types of databases like hierarchical, network, relational and object-oriented databases. It focuses on relational database management systems (RDBMS) and discusses advantages like storing data uniquely and performing complex queries. Finally, it discusses Microsoft SQL Server in more detail.
This chapter covers the following:
- What is SQL
- Categories of SQL statements
- History of SQL
- Relational Database Structure
- MySQL Setup for practice
- SQL Basics (Lexical elements, Data types, Literals)
Oracle is an object-relational database management system. It is the leading RDBMS vendor worldwide. Every Oracle database contains logical structures like tablespaces, schema objects, and physical structures like data files, redo log files, and a control file. SQL is the standard language used for storing, manipulating, and retrieving data from relational databases like Oracle. PL/SQL adds procedural functionality to SQL and is tightly integrated with the Oracle database.
This document provides an overview of SQL programming. It covers the history of SQL and SQL Server, SQL fundamentals including database design principles like normalization, and key SQL statements like SELECT, JOIN, UNION and stored procedures. It also discusses database objects, transactions, and SQL Server architecture concepts like connections. The document is intended as a training guide, walking through concepts and providing examples to explain SQL programming techniques.
A database is a collection of organized data that can be manipulated and accessed using DBMS. DBMS allows users to interact with databases through data definition, update, retrieval, and administration functions. Some key points covered include that Edgar Codd proposed the relational database model, SQL is the standard language for accessing and updating databases, and normalization organizes data to reduce redundancy and inconsistencies.
DB2 is a relational database developed by IBM that supports SQL and the relational model. It has various editions including Advanced Enterprise Server Edition and Express Edition. DB2 uses a multi-tier architecture with components like SSAS, DBAS, and IRLM. It manages data through logical objects like tables and physical objects like tablespaces and databases. Tables are stored in tablespaces which are contained within databases. DB2 supports data types, null values, indexes, and referential integrity through primary keys, unique keys, and foreign keys to link tables.
The document is a presentation on IBM's DB2 database software. It contains:
1) An overview of the DB2 product family and add-on products.
2) Descriptions of DB2 administrative programs, table spaces, constraints, and data types.
3) Explanations of instances and databases, controlling authorities, and the development center.
4) Details about the backup wizard, failure detection and recovery, and a comparison to Oracle's database software.
The document discusses SQL (Structured Query Language) which is used to interact with relational database management systems like MySQL. It provides a brief history of SQL, explaining that SQL originated from SEQUEL in 1974 and became a standard language used by Oracle and Ingres databases in the late 1970s. The document also provides an overview of the basic components of SQL including DDL for defining databases, DML for manipulating data, and DCL for controlling permissions. It uses examples to demonstrate some common SQL statements and their syntax.
The document provides an overview of SQL Server training. It defines data and databases, explaining that a collection of data leads to a database. It also discusses database management systems (DBMS), explaining that a DBMS allows users to create, read, update and delete data in an organized way. The document also covers types of databases like hierarchical, network, relational and object-oriented databases. It focuses on relational database management systems (RDBMS) and discusses advantages like storing data uniquely and performing complex queries. Finally, it discusses Microsoft SQL Server in more detail.
This chapter covers the following:
- What is SQL
- Categories of SQL statements
- History of SQL
- Relational Database Structure
- MySQL Setup for practice
- SQL Basics (Lexical elements, Data types, Literals)
Oracle is an object-relational database management system. It is the leading RDBMS vendor worldwide. Every Oracle database contains logical structures like tablespaces, schema objects, and physical structures like data files, redo log files, and a control file. SQL is the standard language used for storing, manipulating, and retrieving data from relational databases like Oracle. PL/SQL adds procedural functionality to SQL and is tightly integrated with the Oracle database.
This document provides an overview of SQL programming. It covers the history of SQL and SQL Server, SQL fundamentals including database design principles like normalization, and key SQL statements like SELECT, JOIN, UNION and stored procedures. It also discusses database objects, transactions, and SQL Server architecture concepts like connections. The document is intended as a training guide, walking through concepts and providing examples to explain SQL programming techniques.
A database is a collection of organized data that can be manipulated and accessed using DBMS. DBMS allows users to interact with databases through data definition, update, retrieval, and administration functions. Some key points covered include that Edgar Codd proposed the relational database model, SQL is the standard language for accessing and updating databases, and normalization organizes data to reduce redundancy and inconsistencies.
DB2 is a relational database developed by IBM that supports SQL and the relational model. It has various editions including Advanced Enterprise Server Edition and Express Edition. DB2 uses a multi-tier architecture with components like SSAS, DBAS, and IRLM. It manages data through logical objects like tables and physical objects like tablespaces and databases. Tables are stored in tablespaces which are contained within databases. DB2 supports data types, null values, indexes, and referential integrity through primary keys, unique keys, and foreign keys to link tables.
The document is a presentation on IBM's DB2 database software. It contains:
1) An overview of the DB2 product family and add-on products.
2) Descriptions of DB2 administrative programs, table spaces, constraints, and data types.
3) Explanations of instances and databases, controlling authorities, and the development center.
4) Details about the backup wizard, failure detection and recovery, and a comparison to Oracle's database software.
The document discusses SQL (Structured Query Language) which is used to interact with relational database management systems like MySQL. It provides a brief history of SQL, explaining that SQL originated from SEQUEL in 1974 and became a standard language used by Oracle and Ingres databases in the late 1970s. The document also provides an overview of the basic components of SQL including DDL for defining databases, DML for manipulating data, and DCL for controlling permissions. It uses examples to demonstrate some common SQL statements and their syntax.
Database such as MySQL and SQL server are an integral part of business, hospital, banks and universities. Immensely, Every person who have of access computer or technology eventually work on to store data.
1) SQL stands for Structured Query Language and is used to construct tables and manipulate data within tables.
2) SQL has two sublanguages - DML for data manipulation and DDL for data definition like creating tables and defining data types.
3) The document provides information on common SQL data types, creating tables using DDL commands like CREATE TABLE, and defines primary and foreign keys which enforce integrity constraints.
This document provides an agenda for an introductory course on T-SQL. The course will cover topics such as null values, distinct, having vs where clauses, data types, creating and modifying tables, joins, subqueries, functions, errors, variables, control flow and stored procedures. It provides background that SQL was first introduced in 1970 and was developed by Donald Chamberlin and Raymond Boyce at IBM as SEQUEL, later changed to SQL. The next session will cover writing basic queries.
This document discusses key concepts related to files in R including file names, formats, paths, encodings, and types. It describes text files as human-readable files organized in lines with different extensions for different programs. Binary files contain machine-readable 1s and 0s. Paths locate files in a directory hierarchy using components like parent directories denoted by "..". Common encodings include ASCII for English and UTF-8 for multiple languages. R supports text, binary, and delimited files like CSVs that separate values with commas.
This document provides an overview of SQL and SQLite concepts. It begins with an introduction to relational database management systems (RDBMS) and types of SQL commands. It then covers topics like data definition language (DDL) for creating tables, data manipulation language (DML) for inserting, updating and deleting data, and introducing SQLite features. The document demonstrates how to set up a SQLite environment, use the DB Browser for SQLite GUI, and provides examples of interactive commands in the SQLite command line interface including creating databases and tables, inserting data, and running queries.
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...Massimo Cenci
The naming convention is a key component of any IT project.
The purpose of this article is to suggest a standard for a practical and effective Data Warehouse design in Oracle environment
The document compares differences between SQL Server and PostgreSQL, cross joins and full outer joins, SQL Server and Oracle, views and stored procedures, and IN and EXISTS clauses. Some key differences include:
- PostgreSQL uses COPY instead of BULK INSERT and defaults to a different listening port than SQL Server
- A cross join returns all row combinations while a full outer join returns all rows from both tables with NULLs for unmatched fields
- SQL Server and Oracle have different default users, data types, and query plan reading directions
- Views allow single SELECT queries while stored procedures support multiple statements and parameterization
- IN checks for value matches in a subquery while EXISTS only checks if the subquery returns any rows
The document provides information about a database management systems practical file submitted by a student. It includes an index listing 7 experiments conducted, including introductions to Oracle, SQL data types, commands, performance, permissions, joins, constraints, and functions. It then provides details on each of the listed topics, giving overviews and examples of key concepts like data definition language, data manipulation language, data control language, SQL data types, transaction statements, SQL commands like select, create table, alter table, and more.
This document discusses databases and SQL. It defines a database as an integrated collection of data managed by a database management system (DBMS) using SQL. The most popular type is the relational database which organizes data into tables related through primary keys. SQL is used for queries with statements like SELECT, INSERT, DELETE, and UPDATE. Database interfaces like Perl DBI, PHP dbx, and Python DB-API allow access from programming languages. ADO.NET is an API for database access in .NET.
DBMS allows users to access and manage data through simple commands like SQL without worrying about how the data is physically stored. It handles data storage in files, databases, or other secondary storage. The document then discusses various file structures like sequential, indexed, and hash files that allow efficient data organization and retrieval. It also covers database concepts like schemas, transactions, integrity constraints, and different database models.
The document provides an introduction to SQL and relational databases. It describes how relational databases organize data into tables with rows and columns, and how primary keys and foreign keys link related data across multiple tables. It introduces SQL as a non-procedural language used to communicate with the database management system to query, insert, update and delete data from relational databases in a simple English-like syntax.
This document provides an overview of the MySQL database including:
- The different types of databases including MySQL, MS SQL Server, Oracle Server, and MS Access.
- The advantages of using MySQL such as being open-source, powerful, standard SQL language, works on many operating systems and with many languages.
- Key aspects of MySQL including queries, clauses, operators, keys, joins, and datatypes. Queries are used to manipulate and retrieve data while keys uniquely identify records. Joins combine data from multiple tables.
This document provides an agenda for a T-SQL training session. It discusses selecting a database management system (SQL Server) and database (PUBS) to use. It introduces basic SQL concepts like databases, tables, connecting to a database. It demonstrates simple SELECT queries, concatenating columns, using aliases. It also covers filtering queries using WHERE clauses with comparison operators, compound criteria with AND/OR, ranges, wildcards, escape characters and pattern matching. Negation is also introduced using NOT and comparison operators.
Advanced Queuing provides database-integrated message queuing functionality that allows asynchronous communication between applications. It allows producers to ENQUEUE messages into queues and consumers to DEQUEUE messages. Key features include persistence of messages, propagation between queues, priority ordering of messages, transformation of message formats, and access control. The document provides an overview of these features and how to configure and use Advanced Queuing through PL/SQL interfaces and APIs.
The document discusses configuring files and filegroups in SQL Server. It describes how SQL Server uses data files to store database contents and transaction log files to store transactions. It also discusses filegroups, which map database objects to files on disk. The document outlines the types of file extensions (.mdf, .ndf, .ldf) used and how the proportional fill algorithm works. It recommends best practices for configuring files and filegroups when creating a new database. The document also briefly discusses FILESTREAM, the tempdb database, and file naming conventions.
The document discusses file organization and management in BASIC. It defines what a file is and differentiates between program files and data files. It describes two types of file organization - random access files and sequential access files. Sequential access files must be accessed in order and allow for easy file creation and maintenance while random access files allow non-sequential access but require more complex programming. The document outlines commands and functions for file management in BASIC and provides steps for updating, inserting, deleting, and searching records in a sequential access file.
Joins are used to combine rows from two or more tables, and there are two types: Oracle joins which include invalid, equi, non-equi, self and outer joins. SQL joins include cross, natural, using clause, on clause, left outer, right outer and full outer joins.
This document discusses different types of joins in SQL, including inner joins, outer joins, self joins, and cross joins. It provides examples of SQL queries using each type of join to retrieve data from multiple tables based on relationships between columns. The key types of joins covered are equijoins to match column values, non-equijoins to match column ranges, and outer joins to return non-matching rows.
This document discusses various types of joins in SQL including equi joins, outer joins, cartesian joins, and self joins. It also covers set operators like UNION, INTERSECT, and MINUS that combine the results of queries. Subqueries are discussed as a way to return data from multiple tables using a query within another query.
Database such as MySQL and SQL server are an integral part of business, hospital, banks and universities. Immensely, Every person who have of access computer or technology eventually work on to store data.
1) SQL stands for Structured Query Language and is used to construct tables and manipulate data within tables.
2) SQL has two sublanguages - DML for data manipulation and DDL for data definition like creating tables and defining data types.
3) The document provides information on common SQL data types, creating tables using DDL commands like CREATE TABLE, and defines primary and foreign keys which enforce integrity constraints.
This document provides an agenda for an introductory course on T-SQL. The course will cover topics such as null values, distinct, having vs where clauses, data types, creating and modifying tables, joins, subqueries, functions, errors, variables, control flow and stored procedures. It provides background that SQL was first introduced in 1970 and was developed by Donald Chamberlin and Raymond Boyce at IBM as SEQUEL, later changed to SQL. The next session will cover writing basic queries.
This document discusses key concepts related to files in R including file names, formats, paths, encodings, and types. It describes text files as human-readable files organized in lines with different extensions for different programs. Binary files contain machine-readable 1s and 0s. Paths locate files in a directory hierarchy using components like parent directories denoted by "..". Common encodings include ASCII for English and UTF-8 for multiple languages. R supports text, binary, and delimited files like CSVs that separate values with commas.
This document provides an overview of SQL and SQLite concepts. It begins with an introduction to relational database management systems (RDBMS) and types of SQL commands. It then covers topics like data definition language (DDL) for creating tables, data manipulation language (DML) for inserting, updating and deleting data, and introducing SQLite features. The document demonstrates how to set up a SQLite environment, use the DB Browser for SQLite GUI, and provides examples of interactive commands in the SQLite command line interface including creating databases and tables, inserting data, and running queries.
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...Massimo Cenci
The naming convention is a key component of any IT project.
The purpose of this article is to suggest a standard for a practical and effective Data Warehouse design in Oracle environment
The document compares differences between SQL Server and PostgreSQL, cross joins and full outer joins, SQL Server and Oracle, views and stored procedures, and IN and EXISTS clauses. Some key differences include:
- PostgreSQL uses COPY instead of BULK INSERT and defaults to a different listening port than SQL Server
- A cross join returns all row combinations while a full outer join returns all rows from both tables with NULLs for unmatched fields
- SQL Server and Oracle have different default users, data types, and query plan reading directions
- Views allow single SELECT queries while stored procedures support multiple statements and parameterization
- IN checks for value matches in a subquery while EXISTS only checks if the subquery returns any rows
The document provides information about a database management systems practical file submitted by a student. It includes an index listing 7 experiments conducted, including introductions to Oracle, SQL data types, commands, performance, permissions, joins, constraints, and functions. It then provides details on each of the listed topics, giving overviews and examples of key concepts like data definition language, data manipulation language, data control language, SQL data types, transaction statements, SQL commands like select, create table, alter table, and more.
This document discusses databases and SQL. It defines a database as an integrated collection of data managed by a database management system (DBMS) using SQL. The most popular type is the relational database which organizes data into tables related through primary keys. SQL is used for queries with statements like SELECT, INSERT, DELETE, and UPDATE. Database interfaces like Perl DBI, PHP dbx, and Python DB-API allow access from programming languages. ADO.NET is an API for database access in .NET.
DBMS allows users to access and manage data through simple commands like SQL without worrying about how the data is physically stored. It handles data storage in files, databases, or other secondary storage. The document then discusses various file structures like sequential, indexed, and hash files that allow efficient data organization and retrieval. It also covers database concepts like schemas, transactions, integrity constraints, and different database models.
The document provides an introduction to SQL and relational databases. It describes how relational databases organize data into tables with rows and columns, and how primary keys and foreign keys link related data across multiple tables. It introduces SQL as a non-procedural language used to communicate with the database management system to query, insert, update and delete data from relational databases in a simple English-like syntax.
This document provides an overview of the MySQL database including:
- The different types of databases including MySQL, MS SQL Server, Oracle Server, and MS Access.
- The advantages of using MySQL such as being open-source, powerful, standard SQL language, works on many operating systems and with many languages.
- Key aspects of MySQL including queries, clauses, operators, keys, joins, and datatypes. Queries are used to manipulate and retrieve data while keys uniquely identify records. Joins combine data from multiple tables.
This document provides an agenda for a T-SQL training session. It discusses selecting a database management system (SQL Server) and database (PUBS) to use. It introduces basic SQL concepts like databases, tables, connecting to a database. It demonstrates simple SELECT queries, concatenating columns, using aliases. It also covers filtering queries using WHERE clauses with comparison operators, compound criteria with AND/OR, ranges, wildcards, escape characters and pattern matching. Negation is also introduced using NOT and comparison operators.
Advanced Queuing provides database-integrated message queuing functionality that allows asynchronous communication between applications. It allows producers to ENQUEUE messages into queues and consumers to DEQUEUE messages. Key features include persistence of messages, propagation between queues, priority ordering of messages, transformation of message formats, and access control. The document provides an overview of these features and how to configure and use Advanced Queuing through PL/SQL interfaces and APIs.
The document discusses configuring files and filegroups in SQL Server. It describes how SQL Server uses data files to store database contents and transaction log files to store transactions. It also discusses filegroups, which map database objects to files on disk. The document outlines the types of file extensions (.mdf, .ndf, .ldf) used and how the proportional fill algorithm works. It recommends best practices for configuring files and filegroups when creating a new database. The document also briefly discusses FILESTREAM, the tempdb database, and file naming conventions.
The document discusses file organization and management in BASIC. It defines what a file is and differentiates between program files and data files. It describes two types of file organization - random access files and sequential access files. Sequential access files must be accessed in order and allow for easy file creation and maintenance while random access files allow non-sequential access but require more complex programming. The document outlines commands and functions for file management in BASIC and provides steps for updating, inserting, deleting, and searching records in a sequential access file.
Joins are used to combine rows from two or more tables, and there are two types: Oracle joins which include invalid, equi, non-equi, self and outer joins. SQL joins include cross, natural, using clause, on clause, left outer, right outer and full outer joins.
This document discusses different types of joins in SQL, including inner joins, outer joins, self joins, and cross joins. It provides examples of SQL queries using each type of join to retrieve data from multiple tables based on relationships between columns. The key types of joins covered are equijoins to match column values, non-equijoins to match column ranges, and outer joins to return non-matching rows.
This document discusses various types of joins in SQL including equi joins, outer joins, cartesian joins, and self joins. It also covers set operators like UNION, INTERSECT, and MINUS that combine the results of queries. Subqueries are discussed as a way to return data from multiple tables using a query within another query.
The document discusses different types of SQL joins, including inner joins, outer joins, equi joins, non-equi joins, natural joins, cross joins, left joins, right joins, full outer joins, and self joins. It provides the syntax and examples for each type of join. It also discusses joining tables through referential integrity, where a foreign key references a primary key in another table to link the tables together.
Types Of Join In Sql Server - Join With Example In Sql Serverprogrammings guru
Do you know How many types of Joins in SQL. In this ppt presentation we are discussion about types of joins in sql server eg: INNER JOIN , SELF JOIN ,OUTER JOIN ,Right outer Join,Left outer Join,Full Outer Join,CROSS JOIN .
The document provides an overview of Oracle for beginners, including the different editions of Oracle database, data types in Oracle such as character, numeric, date, and LOB data types. It also discusses how to create and alter Oracle tables, including adding, modifying and dropping columns, as well as renaming tables and columns. Primary keys in Oracle tables are also covered at a high level.
Oracle is an object-relational database management system. It is the leading RDBMS vendor worldwide. Every Oracle database contains logical structures like tablespaces, schema objects, and physical structures like data files, redo log files, and a control file. SQL is the standard language used for storing, manipulating, and retrieving data from relational databases like Oracle. PL/SQL adds procedural logic to SQL and is tightly integrated with Oracle databases. It allows developers to define functions and procedures to manipulate data in the database.
This document discusses revisiting SQL basics and advanced topics. It covers objectives, assumptions, and topics to be covered including staying clean with conventions, data types, revisiting basics, joining, subqueries, joins versus subqueries, group by, set operations, and case statements. The topics sections provides details on each topic with examples to enhance SQL knowledge and write better queries.
This document provides an introduction to SQL and the Oracle database system. It begins with an overview of database tables, columns, and data types. It then covers SQL queries, including selecting columns and tuples, aggregate functions, and string operations. The document also discusses data definition, modification, and integrity constraints and triggers in SQL.
This document provides an introduction to SQL and the Oracle database system. It begins with an overview of database tables, columns, and data types. It then covers SQL queries, including selecting columns and tuples, aggregate functions, and string operations. The document also discusses data definition, modification, and integrity constraints and triggers in SQL.
This document provides an introduction to SQL and the Oracle database system. It includes sections on SQL queries, data definition and modification, views, stored procedures and functions using PL/SQL, embedded SQL, integrity constraints, triggers, and database architecture. The document also references additional recommended literature for further learning about Oracle and SQL. It aims to provide a detailed overview of the core concepts for working with Oracle databases using SQL.
The document discusses various SQL commands and concepts. It begins by defining SQL and explaining its purpose and architecture. It then covers the different types of SQL commands - DDL, DML, DCL, and TCL. Specific commands like CREATE, SELECT, INSERT, UPDATE and DELETE are discussed along with their uses. Data types like NUMBER, CHAR, VARCHAR, DATE and LONG are also explained. The document provides examples of creating a table and altering it using SQL statements.
SQL is a language used to manage and query relational databases. It allows users to create, modify, retrieve, and delete data from the database. The main components of SQL include DDL for defining database schema, DML for manipulating data, and DQL for querying data. SQL tables store data in rows and columns and can be queried using commands like SELECT, WHERE, GROUP BY and JOIN.
This document provides an overview of the basic architecture and terminology of SQL Server. It discusses the three main components: 1) the relational engine, which handles query processing, memory management, and other tasks; 2) the storage engine, which manages storage and retrieval of data to disk in the form of data files and log files; and 3) the SQL operating system, which acts as an interface between SQL Server and the host machine's operating system, handling services like memory management. The document serves as an introduction to SQL Server architecture for beginners by defining common terminology.
This document contains study material prepared by D.GAYA, Assistant Professor of Computer Science at Pondicherry University Community College, for the subject Relational Database Management System. It covers various topics related to SQL including basic SQL reports and commands, data types, joins, DDL, DML, DCL commands, and binary data types. Examples are provided to explain concepts such as creating and dropping databases, creating tables, commenting in SQL, and using the TO_HEX and HEX_TO_BINARY functions for binary data.
The document provides an overview of database management systems (DBMS) and structured query language (SQL). It discusses that a DBMS allows for the creation, maintenance and control of access to a database. It also describes the basic processes supported by a DBMS, including storing, manipulating, querying and updating database content. The document then covers how data is organized in a database through concepts like database files, tables, records, fields and data types. It provides examples to illustrate these concepts. Finally, it describes the different types of SQL statements like data definition language, data manipulation language and database control language statements.
The document provides information about databases, database management systems (DBMS), relational database management systems (RDBMS), SQL Server, and Transact-SQL (T-SQL). It defines key terms like data, database, table, and column. It describes different data types in SQL Server. It also provides details about editions of SQL Server, its installation requirements, system and user databases. Overall, the document is an introduction to concepts related to databases and SQL Server.
This document discusses SQL and Oracle database concepts. It provides definitions of SQL, Oracle, and key Oracle data types. It also summarizes Oracle's object-relational capabilities and explains how to perform common data definition language (DDL) tasks like creating tables, adding constraints, and altering table structures in 3 sentences or less.
This document provides an overview of Oracle database including:
- Oracle is a powerful relational database management system (RDBMS) that allows sharing of data across multiple users through a centralized database server.
- It supports both relational and object-oriented features, making it an object-relational database management system (ORDBMS).
- SQL is the standard language used to access and manage data within an Oracle or other relational database.
This document provides an overview and tutorial on database concepts, SQL using MySQL. It aims to give the reader a lucid understanding of databases, relational database management systems (RDBMS), and SQL. The tutorial explains key concepts such as data normalization, data types, and the basic SQL commands of INSERT, DELETE, SELECT, and UPDATE. It also demonstrates creating a sample contacts database with multiple tables to illustrate storing and retrieving data using SQL queries.
Data massage! databases scaled from one to one million nodes (ulf wendel)Zhang Bo
The speaker provides an overview of databases and database concepts, beginning with a brief history from the 1960s when applications stored data in individual files. Database management systems were introduced in the 1970s to consolidate data. The speaker then discusses data modeling concepts like the entity-relationship model and database normalization. Key topics from the relational model are covered like SQL, transactions and concurrency control. Physical storage structures like B-trees and indexing are also mentioned briefly. The talk aims to provide background for both traditional and NoSQL databases.
The document provides an overview of SQL (Structured Query Language) and relational databases. It defines what a database and RDBMS are, explains that SQL is the standard language for communicating with relational databases, and distinguishes SQL from MySQL. The summary then provides an overview of the key topics covered in the document, which include creating and interacting with database tables using SQL commands like SELECT, INSERT, UPDATE, and DELETE.
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPRAHUL
This Dissertation explores the particular circumstances of Mirzapur, a region located in the
core of India. Mirzapur, with its varied terrains and abundant biodiversity, offers an optimal
environment for investigating the changes in vegetation cover dynamics. Our study utilizes
advanced technologies such as GIS (Geographic Information Systems) and Remote sensing to
analyze the transformations that have taken place over the course of a decade.
The complex relationship between human activities and the environment has been the focus
of extensive research and worry. As the global community grapples with swift urbanization,
population expansion, and economic progress, the effects on natural ecosystems are becoming
more evident. A crucial element of this impact is the alteration of vegetation cover, which plays a
significant role in maintaining the ecological equilibrium of our planet.Land serves as the foundation for all human activities and provides the necessary materials for
these activities. As the most crucial natural resource, its utilization by humans results in different
'Land uses,' which are determined by both human activities and the physical characteristics of the
land.
The utilization of land is impacted by human needs and environmental factors. In countries
like India, rapid population growth and the emphasis on extensive resource exploitation can lead
to significant land degradation, adversely affecting the region's land cover.
Therefore, human intervention has significantly influenced land use patterns over many
centuries, evolving its structure over time and space. In the present era, these changes have
accelerated due to factors such as agriculture and urbanization. Information regarding land use and
cover is essential for various planning and management tasks related to the Earth's surface,
providing crucial environmental data for scientific, resource management, policy purposes, and
diverse human activities.
Accurate understanding of land use and cover is imperative for the development planning
of any area. Consequently, a wide range of professionals, including earth system scientists, land
and water managers, and urban planners, are interested in obtaining data on land use and cover
changes, conversion trends, and other related patterns. The spatial dimensions of land use and
cover support policymakers and scientists in making well-informed decisions, as alterations in
these patterns indicate shifts in economic and social conditions. Monitoring such changes with the
help of Advanced technologies like Remote Sensing and Geographic Information Systems is
crucial for coordinated efforts across different administrative levels. Advanced technologies like
Remote Sensing and Geographic Information Systems
9
Changes in vegetation cover refer to variations in the distribution, composition, and overall
structure of plant communities across different temporal and spatial scales. These changes can
occur natural.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Diana Rendina
Librarians are leading the way in creating future-ready citizens – now we need to update our spaces to match. In this session, attendees will get inspiration for transforming their library spaces. You’ll learn how to survey students and patrons, create a focus group, and use design thinking to brainstorm ideas for your space. We’ll discuss budget friendly ways to change your space as well as how to find funding. No matter where you’re at, you’ll find ideas for reimagining your space in this session.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
2. 2
CONTENTS
TOPIC PAGE NO.
SQL – Introduction………………………………………………………………………….3
Database Architecture……………………………………………………………………….4-6
Single-Database Architecture
Multiple Database Architecture
Multi-Location Architecture
Types of Keys in SQL……………………………………………………………………….6-7
Primary Key
Unique Key
Foreign Key
Composite Primary Key
DATA TYPES: (ORACLE Specific)………………………………………………………..8-9
Character
Numeric
DATE
LOB
BUILT-IN FUNCTIONS…………………………………………………………………….10
Types of Commands in SQL…………………………………………………………………11-15
DDL
DML
DCL
TCL
JOINS………………………………………………………………………………………...16
TYPES OF JOINS……………………………………………………………………………16-20
Inner Join
Equi Join
Natural Join
Cross or Cartesian Join
Outer Join
Left Outer Join
Right Outer Join
Full Outer Join
Self Join
ALIAS………………………………………………………………………………………..21
VIEWS……………………………………………………………………………………….21-22
Horizontal View
Vertical View
INDEXES…………………………………………………………………………………….22-23
TRIGGERS…………………………………………………………………………………...23-24
DUAL TABLE………………………………………………………………………………..24
SCHEMAS…………………………………………………………………………………...24-25
CLUSTERING……………………………………………………………………………….25-26
SYSTEM TABLES…………………………………………………………………………...27
SYSTEM CATALOGS……………………………………………………………………….27
EXPLAIN PLANS……………………………………………………………………………28-30
3. 3
SQL – Introduction
SQL is a tool for organizing, managing, and retrieving data stored by a computer database. The
name "SQL" is an abbreviation for Structured Query Language.
The above figure shows how SQL works.
1. SQL Request is sent to the DBMS(Oracle/MySQL etc.)
2. DBMS interacts with the database to find the requested data.
3. Data is returned back by DBMS.
SQL is used to control all of the functionsthat a DBMS provides for its users, including:
• Data definition: SQL lets a user define the structure and organization of the storeddata and
relationships among the stored data items.
• Data retrieval: SQL allows a user or an application program to retrieve stored datafrom the
database and use it.
• Data manipulation: SQL allows a user or an application program to update the database by
adding new data, removing old data, and modifying previously storeddata.
• Access control: SQL can be used to restrict a user's ability to retrieve, add, and modifydata,
protecting stored data against unauthorized access.
• Data sharing: SQL is used to coordinate data sharing by concurrent users, ensuringthat they
do not interfere with one another.
• Data integrity: SQL defines integrity constraints in the database, protecting it fromcorruption
due to inconsistent updates or system failures.
4. 4
Database Architecture
Architecture describes the structure of the contents of the database specified by SQL1 Standard.
There are two types of architecture:
1. Single-Database Architecture
2. Multiple-Database Architecture
3. Multi-Location Architecture
Single-Database Architecture:
Above figure shows singledatabase architecture where DBMS supports one systemwide
database. Examples of such databases are: DB2, Oracle etc.
An advantage of this architecture is that the tables in the various applications can easily
reference one another.
A disadvantage of this architecture is that the database will grow huge over time as more and
more applications are added to it. The problems of managing a database of that size - performing
backups, recovering data, analyzing performance, and so onusually require a full-time database
administrator.
Multi-Database Architecture:
The below figure clearly shows three different databases with a unique name assigned to each of
the database. DBMSs which implement this architecture are: MS SQL Server, Sybase etc.
The main advantage of the multi-database architecture over the single-database architecture is
that it divides the data management tasks into smaller, more manageable pieces.
The main disadvantage of the multi-database architecture is that the individual databases may
become unconnected to one another. Typically a table in one database cannot contain a foreign
key reference to a table in a different database. Often the DBMS does not support queries across
database boundaries, making it impossible to relate data from two applications.
6. 6
Supports multiple databases.
Uses computer system‟s directory structure to organize them.
Different databases at different locations can have the same name.
The major advantage of the multi-location architecture is flexibility.
The disadvantages of this type of databases are same as that of multi-database architecture. In
addition there is one more drawback i.e. there is no master database that keeps track of all the
databases where they are located in the system‟s directory.
Types of Keys in SQL
Keys are those fields which are used to uniquely identify the records in a database. The
following are the types of keys in SQL:
1. Primary Key:
It is the field that can uniquely identify a record and every value in this field
uniquely identifies a row in the record.
Cannot accept NULL values.
Cannot accept duplicate values.
2. Unique Key:
It‟s a set of one more fields that can uniquely identify a record.
Can accept NULL value.
Cannot accept duplicate values.
3. Foreign Key:
A column in one table whose value matches the primary key in some other table
is called a foreign key.
Can accept NULL as well as duplicate values.
7. 7
The CUST column is a foreign key for the CUSTOMERS table, relating each
order to the customer who placed it.
The REP column is a foreign key for the SALESREPS table, relating each order
to the salesperson who took it.
The MFR and PRODUCT columns together are a composite foreign key for the
PRODUCTS table, relating each order to the product being ordered.
4. Composite Primary Key:
It is a combination of one or more fields/columns that uniquely identifies a record.
Below is a table with a composite primary key in which MFR_ID and
PRODUCT_ID are combined to act as primary key.
8. 8
DATA TYPES: (ORACLE Specific)
Data types are broadly classified into:
1. Character data types
2. Numeric data types
3. Date data types
4. LOB data types
Character Data Types:
1. CHAR Data Type :
Stores fixed length character strings.
Must specify the string length (1-2000 bytes or characters)
2. VARCHAR2 and VARCHAR Data type :
VARCHAR2 stores variable length character strings.
Specify a maximum string length between 1 to 4000 bytes.
VARCHAR is synonymous with VARCHAR2 (later is recommended to use).
3. NCHAR and NVARCHAR2 Data type :
Store Unicode character data.
NCHAR stores fixed length character strings (1 to 2000 bytes).
NVARCHAR2 stores variable length character strings (1 to 4000 bytes).
Note:A database column that stores Unicode can store text written in any language.
Numeric Data Types:
1. NUMBER Data type:
Stores fixed and floating-point numbers.
Positive numbers in the range 1 x 10-130
to 9.99...9 x 10125
with up to 38 significant
digits.
Negative numbers from -1 x 10-130
to 9.99...99 x 10125
with up to 38 significant digits.
Optionally, you can also specify a precision (total number of digits) and scale
(number of digits to the right of the decimal point):
column_name NUMBER (precision, scale)
If a precision is not specified, the column stores values as given. If no
scale is specified, the scale is zero.
You can specify a scale and no precision:
column_name NUMBER (*, scale)
9. 9
2. Floating-Point Numbers:
There are two numeric data types for floating-point numbers:
BINARY_FLOAT (32-bit, single-precision floating-point number
datatype)
BINARY_DOUBLE(64-bit, double-precision floating-point number
datatype)
Use binary precision that enables faster arithmetic calculations and usually reduces
storage requirements.
Frequently used for scientific calculations.
DATE Data type:
The DATE data type stores point-in-time values (dates and times) in a table.
The standard Oracle date format is DD-MON-YY (Ex. 11-JUL-92)
To enter dates that are not in standard Oracle date format, use the TO_DATE function
with a format mask:
TO_DATE („JULY11, 1992‟, „MonthDD, YYYY‟)
LOB Data Types:
The LOB datatypes BLOB, CLOB, NCLOB, and BFILE enable you to store and manipulate
large blocks of unstructured data (such as text, graphic images, video clips, and sound
waveforms) in binary or character format.
Following are several types of LOB data types:
BLOB Data type (128 TB of binary data)
CLOB and NCLOB Data type (128 TB of character data)
Bfile Data type (stores a file locator that points to an external file containing the data)
Note:ORACLE doesn‟t support Boolean data type
10. 10
BUILT-IN FUNCTIONS
FUNCTION RETURNS
BIT_LENGTH (string)Number of bits in a bit string
CAST (value AS data type)The value converted to the specified data_type (e.g.,
dateconverted to character string)
CHAR_LENGTH(string)Length of a character string
CONVERT (String USINGconv)String converted as specified by a named
conversionmethod
CURRENT_DATECurrent date
CURRENT_TIME (precision)Current time with the specified precision
EXTRACT (part FROM source)Specified part (Day, Hour, etc.) from a DATETIME
value
LOWER (string)String converted to all lower case letters.
OCTET_LENGTH (string)Number of 8-bit bytes in a character string
POSITION (target IN source)Position where the target string appears in the source
string
SUBSTRING (source FROM n FOR len)A portion of the source string, beginning at the n-th
character, for a length of len
TRANSLATE (string USING trans) String translated as specified by a named translation
Function
TRIM (BOTH char FROM string) String with both leading and trailing occurrences of
char trimmed off
TRIM (LEADING char FROM string)String with any leading occurrences of
char trimmed off
TRIM (TRAILING char FROM string) String with any trailing occurrences of
char trimmed off
UPPER (string)String converted to all uppercase letters
Note:There are some column functions in SQL such as: SUM ( ), AVG ( ), MIN ( ), MAX ( ),
COUNT ( ), COUNT (*)
11. 11
Types of Commands in SQL
1. DDL (Data Definition Language)
Create – Adds a new table to the database
Drop – Removes a table from the database
Alter – Changes the structure of an existing table
2. DML (Data Manipulation Language)
Select – Retrieves data from the database
Insert – Adds new rows of data to the database
Delete – Removes rows of data from the database
Update – Modifies the database data
3. DCL (Data Control Language)
Grant – Grants user access privileges
Revoke – Removes user access privileges
4. TCL (Transaction Control Language)
Commit – Ends the current transaction
Rollback – Aborts the current transaction
SQLCommands with Example:
1. CREATE TABLE
Syntax:
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
......
CONSTRAINT constraint_name PRIMARY KEY (column_name1,
column_name2, …..,column_n)
)
Example:
CREATE TABLE Persons
(
P_Idint,
LastNamevarchar(255),
FirstNamevarchar(255),
Address varchar(255),
City varchar(255),
12. 12
CONSTRAINT person_pk PRIMARY KEY (P_Id)
)
Result:
P_Id LastName FirstName Address City
We can also make more than one columns as our primary keys under one constraint
name.
2. INSERT INTO
Syntax:
INSERT INTO table_name VALUES (value1, value2, value3,...)
INSERT INTO table_name (column1, column2, column3,...)VALUES
(value1, value2, value3,...)
Example:
INSERT INTO Persons VALUES (1,'Goel', 'Gaurish', 'Gurgaon',
'South_City1')
INSERT INTO Persons VALUES (2,'Dash', 'Bimal', 'Ghaziabad',
'Shipra_Sun_City')
INSERT INTO Persons VALUES (3,'Chawla', 'Preeti', 'Gurgaon',
'South_City2')
Result:
P_Id LastName FirstName Address City
1 Goel Gaurish Gurgaon South_City1
2 Dash Bimal Ghaziabad Shipra_Sun_city
3 Chawla Preeti Gurgaon South_City2
3. ALTER TABLE
Syntax:
ALTER TABLE table_name MODIFY column_namedatatype
Example:
ALTER TABLE Persons ADD DateOfBirth date
13. 13
Result:
P_Id LastName FirstName Address City DateOfBirth
1 Goel Gaurish Gurgaon South_City1
2 Dash Bimal Ghaziabad Shipra_Sun_city
3 Chawla Preeti Gurgaon South_City2
We can also drop a column using this command : ALTER TABLE Persons DROP
COLUMN DateOfBirth
4. UPDATE
Syntax:
UPDATE table_name SET column1=value, column2=value2 ...
WHERE some_column=some_value
Example:
UPDATE Persons SET DateOfBirth=‟11-JUL-92‟ WHERE
FirstName=‟Gaurish‟ AND LastName=‟Goel‟
Result:
P_Id LastName FirstName Address City DateOfBirth
1 Goel Gaurish Gurgaon South_City1 11-JUL-92
2 Dash Bimal Ghaziabad Shipra_Sun_city
3 Chawla Preeti Gurgaon South_City2
While using UPDATE command make sure that you don‟t forget to put WHERE clause
otherwise all the rows will be updated.
5. DELETE FROM
Syntax:
DELETE FROM table_name WHERE some_column=some_value
Example:
DELETE FROM Persons WHERE LastName='Chawla' AND
FirstName='Preeti'
TRUNCATE is used to delete all rows in a table. It is a DDL commandand this
action cannot be rolled back.
14. 14
Result:
P_Id LastName FirstName Address City DateOfBirth
1 Goel Gaurish Gurgaon South_City1 11-JUL-92
2 Dash Bimal Ghaziabad Shipra_Sun_city
To delete all rows use this command : DELETE * FROMtable_name
6. SELECT
Syntax:
SELECT * FROM table_name
SELECT column_name1, column_name2,….. FROM table_name
WHERE some_column = some_value
Example:
SELECT FirstName, LastName, DateOfBirth FROM Persons WHERE
Address = „Gurgaon‟
Result:
FirstName LastName DateOfBirth
Gaurish Goel 11-JUL-92
7. DROP TABLE
Syntax:
DROP TABLE table_name
Example:
DROP TABLE Persons
8. COMMITand ROLLBACK
SQL supports database transactions through two SQL transaction processing statements:
The COMMIT statement signals the successful end of a transaction. It tells the DBMS
that the transaction is now complete; all of the statements that comprise the transaction
have been executed, and the database is self-consistent.
The ROLLBACK statement signals the unsuccessful end of a transaction. It tells the
DBMS that the user does not want to complete the transaction; instead, the DBMS should
15. 15
back out any changes made to the database during the transaction. In effect, the DBMS
restores the database to its state before the transaction began.
9. GRANT and REVOKE
The basic GRANTstatement is used to grant security privileges on database objects to
specific users. Grant statement is normally used by the owner of the table to give access
to other users. Grant statement includes the specific list of grant privileges, the name of
the table to which the privileges apply and the user-id to which the privileges are granted.
Example:
GRANT select, insert, delete, update ON Persons TO Gaurish
Grant privileges Table_nameUser_name
PUBLIC keyword is used to give access privileges to all users.
WITH GRANT OPTION clause is used to give the right to a user to grant
privileges to other users.
The privileges that you have granted with the GRANT statement can be taken away with
the REVOKE statement. The REVOKE statement has a structure that closely parallels
the GRANT statement, specifying a specific set of privileges to be taken away, for a
specific database object, from one or more user-ids.
Example:
REVOKE select, insert ON Persons FROM Gaurish
16. 16
JOINS
SQL joins are used to query data from two or more tables, based on a relationship between
certain columns in these tables. The JOIN keyword is used in SQL statements. Two tables are
related to each other with keys.
For example: There are two tables Persons and Accounts. Both are related by a common field
P_Id.
Persons Table
P_Id LastName FirstName Address City
1 Goel Gaurish Gurgaon South_City1
2 Dash Bimal Ghaziabad Shipra_Sun_City
Accounts Table
Account_No Opening_Date P_Id
5423 12-NOV-11 1
4561 24-JUL-12 2
TYPES OF JOINS
1. Inner Join (also known as Simple Join)
1.1 Equi Join
1.1.1 Natural Join
1.1.2 Cross Join or Cartesian Join
2. Outer Join
2.1 Left Outer Join
2.2 Right Outer Join
2.3 Full Outer Join
3. Self Join
1. Inner Join:
Inner join creates a new result table by combining column values of two tables (A and B) based
upon the join-predicate.The query compares each row of A with each row of B to find all pairs of
rows which satisfy the join-predicate. When the join-predicate is satisfied, column values for
each matched pair of rows of A and B are combined into a result row.
17. 17
Example-1:
SELECT FirstName, Address, P.P_Id FROM Persons P, Accounts A WHERE P.P_ID = A.P_Id
Example-2:
SELECT FirstName, Address, P.P_Id FROM Persons P INNER JOIN Accounts A ON WHERE
P.P_ID = A.P_Id
Result of both examples:
FirstName Address P.Id
Gaurish Gurgaon 1
Bimal Ghaziabad 2
1.1 Equi Join
An equi-join is a specific type of comparator-based join that uses only equality comparisons in
the join-predicate. Using other comparison operators (such as <) disqualifies a join as an equi-
join.
If columns in an equi-join have the same name then we can use USING keyword.
SELECT * FROM Persons INNER JOIN Accounts USING (P_Id)
1.1.1 Natural Join
A natural join is a type of equi-join where the join predicate arises implicitly by comparing all
columns in both tables that have the same column-names in the joined tables. The resulting
joined table contains only one column for each pair of equally named columns.
SELECT * FROM Persons NATURAL JOIN Accounts
1.1.2 Cross or Cartesian Join
CROSS JOIN returns the Cartesian product of rows from tables in the join. In other words, it
will produce rows which combine each row from the first table with each row from the second
table. There are two ways of writing a cross join:
SELECT * FROM Persons CROSS JOIN Accounts // Explicit Cross Join
SELECT * FROM Persons, Accounts // Implicit Cross Join
18. 18
Result:
P_Id LastName FirstName Address City DateOfBirth Account_No Opening_Date P_Id
1 Goel Gaurish Gurgaon South_C
ity1
11-JUL-92 5423 12-NOV-11 1
2 Dash Bimal Ghaziabad Shipra_
Sun_Cit
y
5423 12-NOV-11 1
1 Goel Gaurish Gurgaon South_C
ity1
11-JUL-92 4561 24-JUL-12 2
2 Dash Bimal Ghaziabad Shipra_
Sun_Cit
y
4561 24-JUL-12 2
2. Outer Join
An outer join does not require each record in the two joined tables to have a matching record.
The joined table retains each record even if no other matching record exists.
2.1 Left Outer Join
The result of a left outer join (or simply left join) for table A and B always contains all records of
the "left" table (A), even if the join-condition does not find any matching record in the "right"
table (B).
Persons Table
P_Id LastName FirstName Address City DateOfBirth
1 Goel Gaurish Gurgaon South_City1 11-JUL-92
2 Dash Bimal Ghaziabad Shipra_Sun_City 23-DEC-78
3 Preeti Chawla Gurgaon South_City2 19-OCT-85
4 Ravi Kanth Gurgaon DLF_City 04-MAR-86
Accounts Table
Account_No Opening_Date P_Id
5423 12-NOV-11 1
4561 24-JUL-12 2
6879 14-AUG-10 4
7809 10-JAN-11 5
SELECT * FROM Persons LEFT OUTER JOIN Accounts ON Persons.P_Id =
Accounts.P_Id
19. 19
Result:
P_Id LastName FirstName Address City DateOfBirth Account_No Opening_Date P_Id
1 Goel Gaurish Gurgaon South_C
ity1
11-JUL-92 5423 12-NOV-11 1
2 Dash Bimal Ghaziabad Shipra_
Sun_Cit
y
23-DEC-78 4561 24-JUL-12 2
3 Chawla Preeti Gurgaon South_C
ity2
19-OCT-85 NULL NULL NUL
L
4 Kanth Ravi Gurgaon DLF_Ci
ty
04-MAR-86 6879 14-AUG-10 4
2.2 Right Outer Join
A right outer join (or right join) closely resembles a left outer join, except with the treatment of
the tables reversed. Every row from the "right" table (B) will appear in the joined table at least
once. If no matching row from the "left" table (A) exists, NULL will appear in columns from A
for those records that have no match in B.
SELECT * FROM Persons RIGHT OUTER JOIN Accounts ON Persons.P_ID =
Accounts.P_Id
Result:
P_Id LastName FirstName Address City DateOfBirth Account_No Opening_Date P_Id
1 Goel Gaurish Gurgaon South_C
ity1
11-JUL-92 5423 12-NOV-11 1
2 Dash Bimal Ghaziabad Shipra_
Sun_Cit
y
23-DEC-78 4561 24-JUL-12 2
4 Ravi Kanth Gurgaon DLF_Ci
ty
04-MAR-86 6879 14-AUG-10 4
NUL
L
NULL NULL NULL NULL NULL 7809 10-JAN-11 5
2.3 Full Outer Join
A full outer join combines the effect of applying both left and right outer joins. Where records in
the full outer joined tables do not match, the result set will have NULL values for every column
of the table that lacks a matching row. For those records that do match, a single row will be
produced in the result set (containing fields populated from both tables).
20. 20
SELECT * FROM Persons FULL OUTER JOIN Accounts ON Persons.P_Id =
Accounts.P_Id
Result:
P_Id LastName FirstName Address City DateOfBirth Account_No Opening_Date P_Id
1 Goel Gaurish Gurgaon South_C
ity1
11-JUL-92 5423 12-NOV-11 1
2 Dash Bimal Ghaziabad Shipra_
Sun_Cit
y
23-DEC-78 4561 24-JUL-12 2
3 Chawla Preeti Gurgaon South_C
ity2
19-OCT-85 NULL NULL NUL
L
4 Ravi Kanth Gurgaon DLF_Ci
ty
04-MAR-86 6879 14-AUG-10 4
NUL
L
NULL NULL NULL NULL NULL 7809 10-JAN-11 5
3. Self Join
A self join is a join of a table to itself. This table appears twice in the FROM clause and is
followed by table aliases that qualify column names in the join condition. To perform a self join,
Oracle Database combines and returns rows of the table that satisfy the join condition.
SELECT p1.FirstName, p2.Address FROM Persons p1, Persons p2 WHERE p1.P_Id =
p2.P_Id
Result:
FirstName Address
Gaurish Gurgaon
Bimal Ghaziabad
Chawla Gurgaon
Kanth Gurgaon
ALIAS(Formerly known asSYNONYMS)
When selecting data from many tables, it becomes difficult to write complex queries. To solve
this problem we can create aliases (shorthand notations) and use them at the place of table
names. Aliases were formerly known as Synonyms.
21. 21
Syntax:
create alias per for Persons
create alias acc for Accounts
We can also drop the created aliases:
drop alias per
drop alias acc
VIEWS
A view is a SQL query that is permanently stored in the database and assigned a name. The
results of the stored query are visible through the view, and SQL lets you access these query
results as if they were a real table in the database.But unlike a real table, a view does not exist in
the database as a stored set of data values.
A common use of views is to restrict a user's access to only selected rows or columns of a table.
Types of views:
1. Horizontal view
2. Vertical view
Horizontal View:
It restricts a user‟s access to selected rows
Syntax to create a view:
Create view view_name as select column_names from table_name where some_column =
some_value
Example:
CREATE VIEW GGN AS SELECT * FROM Persons WHERE Address = „Gurgaon‟
Result:
Above example will create a view with the name “GGN” which selects only those rows which
are having „Gurgaon‟ as their Address field.
Vertical View:
It restricts a user‟s access to selected columns
Syntax to create a view:
Create view view_name as select column_name1, column_name2, ….fromtable_name
Example:
CREATE VIEW GGG AS SELECT FirstName, LastName, City FROM Persons
22. 22
Result:
Above example will create a view with the name “GGG” which selects specifiedcolumns.
INDEXES
An index is a structure that provides rapid access to the rows of a table based on the values of
one or more columns. The DBMS uses the index as you might use the index of a book. The
index stores data values and pointers to the rows where those data values occur. In the index the
data values are arranged in ascending or descending order, so that the DBMS can quickly search
the index to find a particular value. It can then follow the pointer to locate the row containing the
value. The following figure may give an idea about the indexes:
There are two indexes for the PRODUCT table. One of the indexes provides access based on the
DESCRIPTION column. The other provides access based on the primary key of the table, which
is a combination of the MFR_ID and PRODUCT_ID columns.
When to use an index: Create index for those columns which are frequently accessed by the
users. Most DBMS products alwaysestablish an index for the primary key of a table, because
they anticipate that access to the table will most frequently be via the primary key.
23. 23
Syntax to create an index:
Unique is used to specify that the combination of columns being indexed must contain a unique
value for every row of the table.
Example:
CREATE UNIQUE INDEX prsn_indx ON Persons (P_Id, LastName)
TRIGGERS
Triggers are those procedures stored in PL/SQL that run (fire) implicitly when any user
actionoccurs. These actions include:
DML - Insert, Update, Delete
DDL - Create, Alter
Database events – logon/logoff, errors, startup/shutdown
Syntax:
Create trigger trigger_name on table_name for event_name (insert/update/delete) as action (SQL
command that specifies your action)
Example:
CREATE TRIGGER trig1
ON Persons
FOR INSERT
AS UPDATE Accounts SET Accounts.P_Id = Inserted.P_Id from Accounts, Inserted
Description:
The first part of the trigger tells that the trigger is to be invoked when an INSERT is attempted
on table Persons. The trigger‟s action is defined after the keyword AS. In this case the action is
to update the table Accounts. The row being inserted is referred to using the pseudo-table
nameinserted within the UPDATE statements.
24. 24
Note:There are two temporary tables Inserted & Deleted which are created automatically by the
DBMS. These tables make our task easier while writing queries.
DUAL TABLE
The DUAL table is a special one-column table present by default in all Oracle database
installations. It is suitable for use in selecting a pseudo column such as SYSDATE or USER. The
table has a single VARCHAR2(1) column called DUMMY that has a value of 'X'.
Example:
Select SYSDATE from DUAL
Select USER from DUAL
Select 1+2+3 from DUAL
SCHEMAS
A schema is a named entity within the database and includes the definitions for:
Tables
Views
Domains (function like extended data types used to define columns in a table)
Privileges
Character Sets (database structures used to support international languages)
Collations (define the sorting sequence of character sets)
Translations (control how text data is converted from one character set to another)
Syntax:
CREATE SCHEMA schema_name AUTHORIZATION user_name CREATE
(table/view/domain/character sets/collation/translation) or GRANT privileges
Example:
CREATE SCHEMA GGG AUTHORIZATION Gaurish
CREATE TABLE People (Name varchar (30), Age number (2))
CREATE TABLE Places (City varchar (30), State varchar (30))
GRANT ALL PRIVILEGES ON People TO PUBLIC
GRANT SELECT ON Places TO Bimal
25. 25
CLUSTERING
A cluster is a schema object that contains data from one or more tables, all of which have one or
more columns in common. Oracle Database stores together all the rows from all the tables that
share the same cluster key.Use the CREATECLUSTER statement to create a cluster.
Prerequisites:
To create a cluster in your own schema, you must have CREATECLUSTER system
privilege.
To create a cluster in another user's schema, you must have CREATEANYCLUSTER
system privilege.
Syntax:
Schema: Specify the schema to contain the cluster. If you omit schema, Oracle creates the
cluster in your current schema.
Cluster: Specify the name of the cluster to be created. After you create a cluster, you add tables
to it. A cluster can contain a maximum of 32 tables. You can access clustered tables with SQL
statements just as you can access non-clustered tables.
26. 26
Column: Specify one or more names of columns in the cluster key. You can specify up to 16
cluster key columns. These columns must correspond in both datatype and size to columns in
each of the clustered tables, although they need not correspond in name.
Datatype: Specify the datatype of each cluster key column.
Size:Specify the amount of space in bytes reserved to store all rows with the same cluster key
value or the same hash value. Use K or M to specify this space in kilobytes or megabytes. This
space determines the maximum number of cluster or hash values stored in a data block. If SIZE
is not a divisor of the data block size, Oracle uses the next largest divisor. If SIZE is larger than
the data block size, Oracle uses the operating system block size, reserving at least one data block
for each cluster or hash value.
TableSpace:Specify the tablespace in which the cluster is created.
Single Table:It specifies that the cluster contains only one table.
Index Clause:Specify INDEX to create an indexedcluster. In an indexed cluster, Oracle stores
together rows having the same cluster key value. Each distinct cluster key value is stored only
once in each data block, regardless of the number of tables and rows in which it occurs.
After you create an indexed cluster, you must create an index on the cluster key before you can
issue any data manipulation language (DML) statements against a table in the cluster. This index
is called the cluster index.
HashKeys Clause:Specify the HASHKEYS clause to create a hash cluster and specify the
number of hash values for a hash cluster. In a hash cluster, Oracle stores together rows that have
the same hash key value. The hash value for a row is the value returned by the cluster's hash
function.
Parallel clause: The parallel_clause lets you parallelize the creation of the cluster.
27. 27
SYSTEM TABLES
System tables provide information regarding the structure of the database itself. Each vendor has
its own structure for these tables. System tables are owned by SYS user. Some examples of
system tables are:
AW$ (Maintains a record of all analytic workspaces in the database, recording its name,
owner, and other information)
AW_Obj$ (Describes the objects stored in analytic workspaces), etc.
SYSTEM CATALOGS
The catalog is a collection of named database schemas. The catalog also contains a set of system
tables (confusingly, often called the "system catalog") that describe the structure of the database.
The system catalog is a collection of special tables in a database that are owned, created, and
maintained by the DBMS itself. These system tables contain data that describes the structure of
the database. The tables in the system catalog are automatically created when the database is
created.
The DBMS constantly refers to the data in the system catalog while processing SQL statements.
For example, to process a two-table SELECT statement, the DBMS must:
Verify that the two named tables actually exist.
Ensure that the user has permission to access them.
Check whether the columns referenced in the query exist.
Resolve any unqualified column names to one of the tables.
Determine the data type of each column.
28. 28
EXPLAIN PLANS
The EXPLAINPLAN statement displays execution plans chosen by the optimizer for SELECT,
UPDATE, INSERT, and DELETE statements. A statement execution plan is the sequence of
operations that the database performs to run the statement.
The row source tree is the core of the execution plan. The tree shows the following information:
An ordering of the tables referenced by the statement
An access method for each table mentioned in the statement
A join method for tables affected by join operations in the statement
Data operations like filter, sort, or aggregation
In addition to the row source tree, the plan table contains information about the following:
Optimization, such as the cost and cardinality of each operation
Partitioning, such as the set of accessed partitions
Parallel execution, such as the distribution method of join inputs
The EXPLAINPLAN results let you determine whether the optimizer selects a particular
execution plan, such as, nested loops join. The results also help you to understand the optimizer
decisions, such as why the optimizer chose a nested loops join instead of a hash join, and lets
you understand the performance of a query.
Execution plans can differ due to the following:
Different Schemas
Different Costs
Different Schemas:
The execution and explain plan occur on different databases.
The user explaining the statement is different from the user running the statement. Two
users might be pointing to different objects in the same database, resulting in different
execution plans.
Schema changes (usually changes in indexes) between the two operations.
Different Costs:
Even if the schemas are the same, the optimizer can choose different execution plans when the
costs are different. Some factors that affect the costs include the following:
Data volume and statistics
Bind variable types and values
Initialization parameters set globally or at session level
Explain Plan Restrictions: Oracle Database does not support EXPLAINPLAN for statements
performing implicit type conversion of date bind variables. With bind variables in general, the
EXPLAINPLAN output might not represent the real execution plan.
30. 30
Figure – 1
Select * from PS_DEMAND_PHYS_INV where business_unit = 'EURLC'
In figure – 1 only one condition is given which is resulting in FULL SCAN and a
high cost and hence poor performance. We should take care that full scan doesn‟t
occur in the execution plan of a query.
Figure – 2
Select * from PS_DEMAND_PHYS_INV where business_unit = 'EURLC' and order_no =
'0002104289';
While in figure – 2 two conditions are there which results in a tremendous decrease
in cost and good performance.
31. 31
APPENDICES
A
ALIAS 21
B
BUILT-IN FUNCTIONS 10
C
CLUSTERING 25
D
DATA TYPES
(ORACLE Specific)
Character Data Types 8
(ORACLE SPECIFIC)
DATE Data type 9
LOB Data Types 9
Numeric Data Types 8
DATA TYPES: (ORACLE Specific) 8
Database Architecture 4
Multi-Database Architecture 4
Multi-Location Architecture 5
Single-Database Architecture 4
DUAL TABLE 24
E
Equi Join
Cross or Cartesian Join 17
Natural Join 17
EXPLAIN PLANS 28
I
INDEXES 22
Inner Join
Equi Join 17
J
JOINS 16
O
Outer Join
Full Outer Join 20
Left Outer Join 18
Right Outer Join 19
S
SCHEMAS 24
SQL – Introduction 3
SQL Commands with Example 11
SYSTEM CATALOGS 27
SYSTEM TABLES 27
T
TRIGGERS 23
Types of Commands in SQL 11
DCL 11
DDL 11
DML 11
TCL 11
TYPES OF JOINS 16
Inner Join 16
Outer Join 18
Self Join 20
Types of Keys in SQL 6
Composite Primary Key 7
Foreign Key 6
Primary Key 6
Unique Key 6
V
VIEWS 21
Horizontal View 21
Vertical View 22