Introduction to structured query language (sql)Sabana Maharjan
This document provides an introduction to structured query language (SQL). It discusses the two broad categories of SQL functions: data definition language and data manipulation language. The data definition language includes commands for creating database objects like tables and views, while the data manipulation language includes commands for inserting, updating, deleting, and retrieving data from tables. The document then covers topics like SQL data types, table structures, constraints, indexes, and basic data manipulation commands. It also discusses more advanced SQL concepts such as joins, aggregate functions, and views.
This document provides an introduction to SQL and relational database concepts. It explains that SQL is used to manipulate and retrieve data from relational databases. It also outlines the main SQL commands: DDL for data definition, DML for data manipulation, DCL for data control, and DQL for data queries. Key relational database concepts like tables, records, columns, and relationships are defined. Constraints, data types and integrity are discussed. Examples are provided for SQL statements like CREATE, INSERT, UPDATE, DELETE, and SELECT.
The document provides an overview of database systems, including their purpose, components, and architecture. It describes how database systems offer solutions to problems with using file systems to store data by providing data independence, concurrency control, recovery from failures, and more. It also defines key concepts like data models, data definition and manipulation languages, transactions, storage management, database users, administrators, and the roles they play in overall database system structure.
This document provides an overview of SQL programming including:
- A brief history of SQL and how it has evolved over time.
- Key SQL fundamentals like database structures, tables, relationships, and normalization.
- How to define and modify database structures using commands like CREATE, ALTER, DROP.
- How to manipulate data using INSERT, UPDATE, DELETE, and transactions.
- How to retrieve data using SELECT statements, joins, and other techniques.
- How to aggregate data using functions like SUM, AVG, MAX, MIN, and COUNT.
- Additional topics covered include subqueries, views, and resources for further learning.
This document provides an overview of the key technologies and concepts used to develop an online bookshop project. It discusses the Java programming language, key Java APIs like AWT, exceptions handling, and Swing. It also describes the software and hardware requirements including Java JDK, Tomcat, MySQL, PC specifications. The document outlines the main modules of the project like administrator view, user view, home page, search, product catalogue, shopping cart etc. It provides details about the tables used to store user, book, order and other data in MySQL database.
This document provides information about SQL queries and joins. It begins by introducing SQL (Structured Query Language) which is used to communicate with databases and retrieve required information. It describes the basic CRUD (Create, Read, Update, Delete) functions of SQL. It then discusses different types of SQL queries - aggregate function queries, scalar function queries, and join queries. It provides the syntax and explanation of inner joins, outer joins (left, right, full) which are used to query data from multiple tables based on relationships between columns. The document is presented by Hammad, Bilal and Awais.
Scratch is a free programming tool that allows kids to create games, stories and art. It was developed by MIT. To use Scratch, you visit the website and click "Try it Out". You can then choose a sprite and background. Programming in Scratch involves dragging blocks representing commands like motion, looks, sound and pen into the scripts area. Clicking the flag runs the program. The document provides examples of using different block commands to program a sprite's movement, appearance and add sound.
This document provides an introduction to SQL (Structured Query Language). It defines SQL as a standard language for accessing and manipulating databases. The key points covered include:
- SQL lets you perform queries against a database to retrieve, insert, update, and delete data. It can also be used to create and modify database structures.
- Common SQL commands covered are SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, ALTER TABLE, DROP TABLE.
- Additional SQL concepts explained are data types, WHERE clauses, ORDER BY clauses, GROUP BY clauses, and JOIN operations.
- RDBMS systems like MySQL, SQL Server, Oracle, etc. use SQL to communicate with the databases they manage.
Data Definition Language (DDL), Data Definition Language (DDL), Data Manipulation Language (DML) , Transaction Control Language (TCL) , Data Control Language (DCL) - , SQL Constraints
Presentation slides of Sequence Query Language (SQL)Punjab University
SQL is a language used to communicate with and perform operations on relational database management systems (RDBMS). The document outlines what SQL is, what it can do, important SQL commands like SELECT, INSERT, UPDATE and DELETE, how to create and drop databases and tables, and key concepts like primary keys, foreign keys, and constraints. SQL allows users to retrieve, manipulate and transform data stored in an RDBMS through statements that include keywords, clauses, aggregates, expressions, identifiers, parameters, and operators.
SQL is a standard language for accessing and manipulating databases. The document provides an introduction to SQL basics including SQL statements to select, insert, update and delete data from database tables. It explains key SQL components like the WHERE clause for filtering records and the ORDER BY clause for sorting query results. Examples are given for each SQL statement and concept discussed.
Joins in SQL are used to combine data from two or more tables based on common columns between them. There are several types of joins, including inner joins, outer joins, and cross joins. Inner joins return rows that match between tables, outer joins return all rows including non-matching rows, and cross joins return the cartesian product between tables.
SQL is a standard language for storing, manipulating and retrieving data in databases. It allows users to access and manipulate data in databases. Some key functions of SQL include executing queries against a database, retrieving data from a database, inserting, updating and deleting records in a database, and creating, altering and dropping database objects like tables.
SQL is a standard language for querying and manipulating data in relational databases. It contains five categories of statements: data definition language (DDL) for defining data structure, data manipulation language (DML) for managing data, data control language (DCL) for privileges, transaction control statements for transactions, and session control statements for sessions. Common DDL commands include CREATE, ALTER, and DROP for databases and tables. Common DML commands include SELECT, INSERT, UPDATE, and DELETE for querying and modifying data. Joins are used to combine data from two or more tables.
This document provides an overview of SQL (Structured Query Language). It discusses that SQL is used to define, manipulate, and control data in a relational database. It can define database schemas, insert, modify, retrieve, and delete data from databases. The document also provides a brief history of SQL and describes its main components like DDL, DML, and DCL. It provides examples of common SQL commands and functions. Finally, it discusses SQL Plus which is a basic Oracle utility used to interact with databases through a command line interface.
The SELECT statement is used to retrieve data from one or more tables. It allows you to select specific columns, rows, and expressions. The general syntax includes keywords like SELECT, FROM, WHERE, and clauses for filtering, sorting, grouping, and joining results. Examples demonstrate how to select all data, particular rows and columns, use aliases, DISTINCT, comparison operators, patterns, ranges, and handle NULL values.
The document discusses various SQL concepts like database and tables, RDBMS terminology, SQL commands categories, data types, creating and manipulating tables. It explains concepts like primary key, foreign key, aggregate functions like MAX(), MIN(), AVG(), SUM(). Examples are provided for queries using SELECT, WHERE, ORDER BY, UPDATE and DELETE statements. Logical and relational operators used for filtering data in WHERE clause are also explained.
SQL is a database query language used to store and manage data in relational database management systems (RDBMS). SQL commands are divided into four categories: DDL for defining database schemas, DML for manipulating data, DCL for controlling access privileges, and DQL for querying data. Some common SQL operations include JOINs to combine data from multiple tables and SET operations like UNION, INTERSECT, and MINUS.
Clauses in Sql(Structured Query Language), distinct clause, where clause, where clause, order by clause, group by clause, having clause, Relational Database Management System
MySQL is a popular and freely available open-source relational database management system (RDBMS). It stores data in tables and relationships between data are also stored in tables. MySQL uses SQL and works on many operating systems. It has commands for data definition (CREATE, ALTER, DROP), data manipulation (SELECT, INSERT, UPDATE, DELETE), transaction control (COMMIT, ROLLBACK), and data access control (GRANT, REVOKE). Joins allow retrieving data from multiple tables by linking rows together. Common join types are inner joins, outer joins, and self joins.
in this presentation the commands let you help to understand the basic of the database system software. how to retrieve data, how to feed data and manipulate it very efficiently by using this commands.
Mysql is an open source relational database management system that can be downloaded for free from mysql.com. It allows users to define, construct, manipulate and access databases through SQL queries. The document provides an overview of mysql and databases, instructions for downloading and starting mysql, descriptions of basic SQL queries like SELECT, INSERT, UPDATE and DELETE, and examples of creating a sample employee table and running queries on it.
This document provides an overview of SQL (Structured Query Language) including what it is, what it can do, and some key SQL statements. SQL is a standard language for accessing and manipulating databases and allows users to retrieve, insert, update, and delete data. The document describes common statements like SELECT, UPDATE, DELETE, and INSERT and provides examples of basic usage.
This document discusses different types of joins in SQL, including inner joins, outer joins, cross joins, and natural joins. It provides guidelines for writing join conditions, handling ambiguous column names, and joining more than two tables. The key types of joins covered are equijoins for matching column values, outer joins to also return non-matching rows, and self joins to join a table to itself.
SQL JOINS allow data to be combined from multiple tables by performing joins between columns that share common values. There are five main types of joins: equi joins which combine rows where joined columns are equal, inner joins which return rows where there is a match in both tables, outer joins which return all rows of the left or right table even if there is no match, self joins which join a table to itself, and non-equi joins which join on columns that are not equal. Joins are useful for combining related data across tables and are implemented using conditions in the WHERE clause that compare columns from different tables.
The document discusses various disaster recovery strategies for SQL Server including failover clustering, database mirroring, and peer-to-peer transactional replication. It provides advantages and disadvantages of each approach. It also outlines the steps to configure replication for Always On Availability Groups which involves setting up publications and subscriptions, configuring the availability group, and redirecting the original publisher to the listener name.
Microsoft SQL Server internals & architectureKevin Kline
From noted SQL Server expert and author Kevin Kline - Let’s face it. You can effectively do many IT jobs related to Microsoft SQL Server without knowing the internals of how SQL Server works. Many great developers, DBAs, and designers get their day-to-day work completed on time and with reasonable quality while never really knowing what’s happening behind the scenes. But if you want to take your skills to the next level, it’s critical to know SQL Server’s internal processes and architecture. This session will answer questions like:
- What are the various areas of memory inside of SQL Server?
- How are queries handled behind the scenes?
- What does SQL Server do with procedural code, like functions, procedures, and triggers?
- What happens during checkpoints? Lazywrites?
- How are IOs handled with regards to transaction logs and database?
- What happens when transaction logs and databases grow or shrinks?
This fast paced session will take you through many aspects of the internal operations of SQL Server and, for those topics we don’t cover, will point you to resources where you can get more information.
Data Definition Language (DDL), Data Definition Language (DDL), Data Manipulation Language (DML) , Transaction Control Language (TCL) , Data Control Language (DCL) - , SQL Constraints
Presentation slides of Sequence Query Language (SQL)Punjab University
SQL is a language used to communicate with and perform operations on relational database management systems (RDBMS). The document outlines what SQL is, what it can do, important SQL commands like SELECT, INSERT, UPDATE and DELETE, how to create and drop databases and tables, and key concepts like primary keys, foreign keys, and constraints. SQL allows users to retrieve, manipulate and transform data stored in an RDBMS through statements that include keywords, clauses, aggregates, expressions, identifiers, parameters, and operators.
SQL is a standard language for accessing and manipulating databases. The document provides an introduction to SQL basics including SQL statements to select, insert, update and delete data from database tables. It explains key SQL components like the WHERE clause for filtering records and the ORDER BY clause for sorting query results. Examples are given for each SQL statement and concept discussed.
Joins in SQL are used to combine data from two or more tables based on common columns between them. There are several types of joins, including inner joins, outer joins, and cross joins. Inner joins return rows that match between tables, outer joins return all rows including non-matching rows, and cross joins return the cartesian product between tables.
SQL is a standard language for storing, manipulating and retrieving data in databases. It allows users to access and manipulate data in databases. Some key functions of SQL include executing queries against a database, retrieving data from a database, inserting, updating and deleting records in a database, and creating, altering and dropping database objects like tables.
SQL is a standard language for querying and manipulating data in relational databases. It contains five categories of statements: data definition language (DDL) for defining data structure, data manipulation language (DML) for managing data, data control language (DCL) for privileges, transaction control statements for transactions, and session control statements for sessions. Common DDL commands include CREATE, ALTER, and DROP for databases and tables. Common DML commands include SELECT, INSERT, UPDATE, and DELETE for querying and modifying data. Joins are used to combine data from two or more tables.
This document provides an overview of SQL (Structured Query Language). It discusses that SQL is used to define, manipulate, and control data in a relational database. It can define database schemas, insert, modify, retrieve, and delete data from databases. The document also provides a brief history of SQL and describes its main components like DDL, DML, and DCL. It provides examples of common SQL commands and functions. Finally, it discusses SQL Plus which is a basic Oracle utility used to interact with databases through a command line interface.
The SELECT statement is used to retrieve data from one or more tables. It allows you to select specific columns, rows, and expressions. The general syntax includes keywords like SELECT, FROM, WHERE, and clauses for filtering, sorting, grouping, and joining results. Examples demonstrate how to select all data, particular rows and columns, use aliases, DISTINCT, comparison operators, patterns, ranges, and handle NULL values.
The document discusses various SQL concepts like database and tables, RDBMS terminology, SQL commands categories, data types, creating and manipulating tables. It explains concepts like primary key, foreign key, aggregate functions like MAX(), MIN(), AVG(), SUM(). Examples are provided for queries using SELECT, WHERE, ORDER BY, UPDATE and DELETE statements. Logical and relational operators used for filtering data in WHERE clause are also explained.
SQL is a database query language used to store and manage data in relational database management systems (RDBMS). SQL commands are divided into four categories: DDL for defining database schemas, DML for manipulating data, DCL for controlling access privileges, and DQL for querying data. Some common SQL operations include JOINs to combine data from multiple tables and SET operations like UNION, INTERSECT, and MINUS.
Clauses in Sql(Structured Query Language), distinct clause, where clause, where clause, order by clause, group by clause, having clause, Relational Database Management System
MySQL is a popular and freely available open-source relational database management system (RDBMS). It stores data in tables and relationships between data are also stored in tables. MySQL uses SQL and works on many operating systems. It has commands for data definition (CREATE, ALTER, DROP), data manipulation (SELECT, INSERT, UPDATE, DELETE), transaction control (COMMIT, ROLLBACK), and data access control (GRANT, REVOKE). Joins allow retrieving data from multiple tables by linking rows together. Common join types are inner joins, outer joins, and self joins.
in this presentation the commands let you help to understand the basic of the database system software. how to retrieve data, how to feed data and manipulate it very efficiently by using this commands.
Mysql is an open source relational database management system that can be downloaded for free from mysql.com. It allows users to define, construct, manipulate and access databases through SQL queries. The document provides an overview of mysql and databases, instructions for downloading and starting mysql, descriptions of basic SQL queries like SELECT, INSERT, UPDATE and DELETE, and examples of creating a sample employee table and running queries on it.
This document provides an overview of SQL (Structured Query Language) including what it is, what it can do, and some key SQL statements. SQL is a standard language for accessing and manipulating databases and allows users to retrieve, insert, update, and delete data. The document describes common statements like SELECT, UPDATE, DELETE, and INSERT and provides examples of basic usage.
This document discusses different types of joins in SQL, including inner joins, outer joins, cross joins, and natural joins. It provides guidelines for writing join conditions, handling ambiguous column names, and joining more than two tables. The key types of joins covered are equijoins for matching column values, outer joins to also return non-matching rows, and self joins to join a table to itself.
SQL JOINS allow data to be combined from multiple tables by performing joins between columns that share common values. There are five main types of joins: equi joins which combine rows where joined columns are equal, inner joins which return rows where there is a match in both tables, outer joins which return all rows of the left or right table even if there is no match, self joins which join a table to itself, and non-equi joins which join on columns that are not equal. Joins are useful for combining related data across tables and are implemented using conditions in the WHERE clause that compare columns from different tables.
The document discusses various disaster recovery strategies for SQL Server including failover clustering, database mirroring, and peer-to-peer transactional replication. It provides advantages and disadvantages of each approach. It also outlines the steps to configure replication for Always On Availability Groups which involves setting up publications and subscriptions, configuring the availability group, and redirecting the original publisher to the listener name.
Microsoft SQL Server internals & architectureKevin Kline
From noted SQL Server expert and author Kevin Kline - Let’s face it. You can effectively do many IT jobs related to Microsoft SQL Server without knowing the internals of how SQL Server works. Many great developers, DBAs, and designers get their day-to-day work completed on time and with reasonable quality while never really knowing what’s happening behind the scenes. But if you want to take your skills to the next level, it’s critical to know SQL Server’s internal processes and architecture. This session will answer questions like:
- What are the various areas of memory inside of SQL Server?
- How are queries handled behind the scenes?
- What does SQL Server do with procedural code, like functions, procedures, and triggers?
- What happens during checkpoints? Lazywrites?
- How are IOs handled with regards to transaction logs and database?
- What happens when transaction logs and databases grow or shrinks?
This fast paced session will take you through many aspects of the internal operations of SQL Server and, for those topics we don’t cover, will point you to resources where you can get more information.
A database is a collection of related data organized into tables. Data is any raw fact or statistic, and is important because all decisions depend on underlying data. A database management system (DBMS) is used to organize data into tables to avoid problems with file-based storage like inconsistency, redundancy, integrity issues, and security problems. It allows for concurrent access. DBMS are widely used in real-world applications like movie theaters, prisons, and banks to manage related information. A table in a database contains records organized into rows with attributes or fields forming the columns. A key uniquely identifies each record.
The document discusses the physical architecture of SQL Server, including components like pages, extents, tables, indexes, database files, file groups, and transaction log files. Pages are the smallest storage unit, while extents contain multiple pages. Tables and indexes are made up of pages and extents. Database files store this data on disk and are organized into file groups. Transaction log files log all data modifications for recovery purposes.
The document provides an overview of basic concepts related to SQL server databases including database objects, file systems, storage structures, and query processing. It discusses topics like SQL server databases, storage files and file groups, data pages and extents, data organization in heaps vs indexed tables, and how queries are processed through either full table scans or using indexes.
This document provides an overview of SQL Server architecture and components. It discusses common SQL Server versions, the different components that make up SQL Server like databases, files, transaction logs, and recovery models. It also covers new features introduced in SQL Server 2005 and 2012 like data partitioning using file groups, database snapshots, database mirroring, and availability groups.
The document introduces common data types in SQL such as char, varchar, int, numeric, and date. It describes how to create databases and tables using SQL statements like CREATE DATABASE, CREATE TABLE, INSERT INTO, and ALTER TABLE. It also covers SQL queries using SELECT, FROM, WHERE, ORDER BY, LIKE and other clauses to retrieve and filter data from one or more tables.
SQL is a standard language for accessing and manipulating databases. It allows users to perform functions like querying data, inserting records, updating records, and deleting records. The main SQL statements are SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, and DROP. SQL also includes clauses like WHERE, ORDER BY, GROUP BY and JOIN that allow users to filter and sort query results. Common data definition language statements are used to create and modify database structures like tables, indexes, and relationships.
This document provides an introduction to database management systems (DBMS) and SQL Server. It discusses what a database is and where databases are used. It then explains what a DBMS is and some examples of DBMS software. The document goes on to describe the relational database model including entities, attributes, relationships and keys. It also discusses the entity-relationship model. Finally, it covers SQL statements including DDL, DML, and DCL and provides examples of commands for creating tables, inserting and updating data, and setting privileges.
SQL Server 2012 is a cloud-ready information platform that helps organizations unlock breakthrough insights across the organization and quickly build solutions to extend data across on-premises and public cloud, backed by mission critical confidence. Sujit Rai, a technical expert at Convonix shares its uses in business intelligence.
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
The document discusses Structured Query Language (SQL) and its history and components. It notes that SQL is a declarative query language used to define database schemas, manipulate data through queries, and control transactions. The document outlines SQL's data definition language for defining schemas and data manipulation language for querying and modifying data. It also provides examples of SQL statements for creating tables and defining constraints.
This document provides an introduction to Structured Query Language (SQL) and T-SQL. It discusses the basic SELECT statement and how to select data from single and multiple tables using various join types. The key topics covered include the SELECT statement syntax, arithmetic and logical operators, filtering rows with WHERE, sorting with ORDER BY, and performing inner, outer, left, right and full joins. Examples are provided throughout to illustrate each SQL concept.
This document provides an overview of SQL commands used to manipulate and retrieve data from an Oracle database. It discusses data manipulation language commands like SELECT, INSERT, UPDATE, and DELETE. It also covers data definition language commands such as CREATE, ALTER, and DROP for managing database structures. Finally, it reviews transaction control commands like COMMIT and ROLLBACK and data control language commands like GRANT and REVOKE for managing permissions. Examples are provided for each type of SQL command.
This document provides an overview of SQL (Structured Query Language). It discusses SQL functions including data manipulation language (DML) and data definition language (DDL). DML commands like SELECT, UPDATE, DELETE and INSERT are covered. The SELECT statement syntax and use of clauses like WHERE, ORDER BY, GROUP BY and JOINs are explained. Aggregate functions like COUNT, AVG, SUM etc and scalar functions are also summarized. Examples are provided throughout to illustrate the concepts and syntax.
This document provides an overview of SQL (Structured Query Language) and its main components. It discusses SQL query types like SELECT, INSERT, UPDATE, and DELETE statements. It also covers SQL joins, aliases, clauses, functions, conditions, tables and views. Finally, it provides examples and practice exercises for the SELECT and INSERT statements.
This document discusses different types of joins in SQL, including:
1) Equijoins to retrieve records that match between two tables using column equality.
2) Nonequijoins using operators like BETWEEN to join on non-equal columns.
3) Outer joins to return both matching and non-matching record results from the left or right tables.
4) Self-joins to join a table to itself.
5) Cross joins to generate the Cartesian product between two tables without a join condition.
The document provides an introduction to SQL and covers various SQL statements and operators including:
1. SQL statements like SELECT, INSERT, UPDATE, and DELETE are used to retrieve, modify and manipulate data in databases.
2. Operators like WHERE, BETWEEN, IN, LIKE and NULL are used to filter rows and compare values in conditions.
3. Functions and clauses such as SELECT, FROM, DISTINCT, GROUP BY, JOIN, ORDER BY, etc. are used to customize data retrieval and presentation.
Hello people this is first time in the history when somebody has take a pain to create such a large ppt it is almost my 5 months laborious work..
although i know ppt cannot b more than 30 slides but at the same time i dont want my readers to to feel the lack of knowledge
THIS PPT BELONGS TO TECHNICALS PERSONS hope u like it thanking you ........
This document provides an introduction to SQL (Structured Query Language). SQL is a language used to define, query, modify, and control relational databases. The document outlines the main SQL commands for data definition (CREATE, ALTER, DROP), data manipulation (INSERT, UPDATE, DELETE), and data control (GRANT, REVOKE). It also discusses SQL data types, integrity constraints, and how to use SELECT statements to query databases using projections, selections, comparisons, logical conditions, and ordering. The FROM clause is introduced as specifying the relations involved in a query.
This document provides information about SQL and database management systems. It discusses:
- SQL is a standard language for querying, manipulating, and defining data in databases. It was developed by IBM in the 1970s.
- SQL can be used to perform functions like retrieving data from a database, inserting new records, updating existing records, and deleting records.
- The main components of SQL are DDL, DML, DCL, and DQL which allow creating, modifying and deleting database structures, manipulating data, controlling access to data, and querying data respectively.
- Common SQL statements are discussed including SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE TABLE, and DROP TABLE. Data types and
The document provides an introduction to the SQL language, including its main components of DML (Data Manipulation Language) and DDL (Data Definition Language). It discusses SQL concepts such as creating tables with data types, defining primary and foreign keys, and using basic queries with SELECT, FROM, WHERE and ORDER BY clauses.
This document provides an overview of SQL (Structured Query Language) concepts including:
- What a database is and common SQL statements like SELECT, INSERT, UPDATE, DELETE
- Database schema examples and how to create tables
- Data types, constraints, and altering tables
- How to insert, update, delete and select data from tables
- Joins between multiple tables
- Aggregate functions and grouping data
- Date functions and formatting
The document covers fundamental SQL topics through examples and explanations to introduce the basics of querying and managing data in a relational database using SQL.
SQL (Structured Query Language) is a standard language for accessing and manipulating databases. It allows users to execute queries against a database, retrieve data from a database, insert records into a database, update records in a database, and delete records from a database. Common SQL statements include SELECT to retrieve data, INSERT to add data, UPDATE to modify data, DELETE to remove data, and CREATE/ALTER to manage tables and databases.
This document provides an overview of structured query language (SQL) including the different types of SQL commands, how to manipulate data using SQL statements like INSERT, UPDATE, DELETE, and SELECT, and how to retrieve data from single and multiple tables using joins and subqueries. Key topics covered include data definition language (DDL) to define databases, data manipulation language (DML) to query and modify data, and data control language (DCL) to administer database privileges. The document explains SQL concepts like integrity constraints, transactions, and aliases as well as syntax for common queries.
This document provides an overview of structured query language (SQL) including the different types of SQL commands, how to manipulate data using SQL statements like INSERT, UPDATE, DELETE, and SELECT, and how to retrieve data from single and multiple tables using joins and subqueries. Key topics covered include data definition language (DDL) to define databases, data manipulation language (DML) to query and modify data, and data control language (DCL) to administer database privileges. The document explains SQL concepts like integrity constraints, transactions, and aliases as well as syntax for common queries.
The document provides an outline of key concepts for database programming with MySQL. It discusses MySQL data types, the data definition language (DDL) for defining databases and tables, the data manipulation language (DML) for querying and manipulating data using SQL statements like SELECT, INSERT, UPDATE, DELETE. It also covers MySQL clauses like WHERE, ORDER BY, LIMIT, and joins for retrieving data from multiple tables. The document demonstrates how to connect to and query a MySQL database using PHP with examples of prepared statements. It proposes a course project and assignment to apply the concepts by building a basic application.
Structured Query Language (SQL) is used to define, manipulate, and control data in a relational database. The document provides an overview of SQL, covering its main components like Data Definition Language (DDL) for defining tables, Data Manipulation Language (DML) for inserting, updating, deleting and selecting data, and Data Control Language (DCL) for controlling database privileges. It describes the basic DML commands, discusses integrity constraints and transactions, and shows how to perform single table and joined queries using SQL syntax.
This document provides an overview of querying and reporting in SQL, covering topics like arithmetic operators, built-in functions, selecting data, grouping results, joins, and subqueries. The agenda includes learning objectives, descriptions of SELECT statements, and explanations of concepts like aggregate functions, limiting results, sorting data, and correlating subqueries.
The document discusses SQL SELECT statements and their capabilities. It explains how to write basic SELECT statements to retrieve data from one or more tables, including selecting specific columns, filtering rows, sorting results, and performing calculations. It also covers JOIN operations, including inner joins to combine data from multiple tables and self joins to join a table to itself.
The document discusses SQL SELECT statements and their capabilities. It explains how to write basic SELECT statements to retrieve data from one or more tables, including selecting specific columns, filtering rows, sorting results, and performing calculations. It also covers JOIN operations, including inner joins to combine data from multiple tables and self joins to join a table to itself.
This document discusses SQL SELECT statements and their capabilities. It begins by listing the objectives and providing definitions of SQL and the Microsoft SQL Server database model. It then describes Data Definition Language and Data Manipulation Language statements. The document focuses on the capabilities of SELECT statements, including projecting columns, selecting rows, joining tables, and using arithmetic expressions, null values, column aliases, and the DISTINCT keyword to eliminate duplicate rows. Examples are provided for each concept.
The document provides an overview of the RichFaces framework including:
- What RichFaces is and its history
- Installing and configuring RichFaces
- Ajax action components like a4j:support, a4j:commandButton, a4j:poll
- UI components like menus, calendar, trees
- Examples of using various RichFaces components
This document discusses JSP custom tags, including:
- Tag files allow defining custom tags and should be used to modularize JSP output or reuse behavior.
- There are two types of tag files: stand-alone tags and tags containing other tags/text. Both can have attributes.
- The document demonstrates creating a simple "hello" tag and using attributes, JSTL, modifying body content, and exporting variables from tags.
- Custom tags can help build reusable components, iterate/filter content, and encapsulate logic in JSPs.
JSF (JavaServer Faces) provides an event model, validation model, and conversion model to handle user input and events in web applications. The event model defines different event types like action, value change, and phase events that allow components to notify listeners of user interactions. The validation model validates user input on UI components using standard and custom validators. The conversion model converts between view data types like strings and model data types using standard and custom converters.
This document provides an overview of JavaServer Faces (JSF), including:
- An introduction to JSF and what it is
- A description of the JSF request lifecycle and faces servlet
- An explanation of JSF component models and commonly used tags
- A step-by-step guide for creating a basic "Hello World" JSF application
- Details about JSP architectures (Model 1 and Model 2) that provide context for JSF
The Unified Expression Language (EL) provides a simplified way to access objects in JSP and JSF, allowing values to be retrieved from or assigned to JavaBeans properties and elements in collections, and supporting implicit objects, operators, and conditional evaluation. EL was created to unify the different expression languages used in JSP and JSF and addresses issues with earlier technologies like JSTL and JSP by providing a more powerful yet concise syntax. EL evaluates expressions and returns values or references to support both immediate and deferred access of data in web applications.
- JavaServer Pages (JSP) is a technology for generating dynamic web content that allows Java code to be embedded within HTML pages. The Java code is executed on the server to produce HTML that is then sent to the client.
- JSP pages make it easy to create dynamic web applications using simple scripting elements like expressions, scriptlets, and directives that are translated into Java servlets. They provide many predefined variables like request, response, and session to access data.
- JSP pages are compiled into Java servlet classes that operate in a request/response lifecycle like servlets. The servlet classes are stored and executed by the web container to handle requests and generate the HTML responses.
The document provides an overview of Java web applications and deployment using Apache Tomcat web application server. It discusses what a web container is, how Tomcat works as a web container, and how to install, run and configure Tomcat. It also describes how to create Java web applications that can be deployed as WAR files, and how to define servlets and mappings in the web deployment descriptor (web.xml). Finally, it shows how to create a simple web application and deploy it on Tomcat.
This document provides an overview of Java servlets technology, including:
1. What Java servlets are and their main purposes and advantages such as portability, power, and integration with server APIs.
2. Key aspects of servlet architecture like the servlet lifecycle, the HttpServletRequest and HttpServletResponse objects, and how different HTTP methods map to servlet methods.
3. Examples of simple servlets that process parameters, maintain a session counter, and examples of deploying servlets in Eclipse IDE.
This document provides an introduction to Cascading Style Sheets (CSS). It explains that CSS is used to separate a document's content from its presentation or style. CSS defines elements like fonts, colors, spacing and layout. Styles can be applied inline, embedded in <style> tags, or linked via an external CSS file. The document outlines CSS syntax, selectors, and precedence of different styling methods. CSS provides control over text formatting, colors, spacing, and positioning of HTML elements.
The document discusses HTML tables and forms. It covers core table tags like <table>, <tr>, and <td> and how to structure tables with headers, bodies, and footers. It also explains how to customize tables using attributes like cellspacing, cellpadding, colspan, and rowspan. For forms, it describes common form controls like text fields, textareas, radio buttons, checkboxes and how to lay them out in a form with a submit button. It provides an example form to demonstrate these concepts.
The document provides an introduction to HTML basics including text, images, tables and forms. It covers the structure of an HTML document with the <head> and <body> sections. It describes common tags for headings, paragraphs, hyperlinks and images. It also discusses attributes, comments, and different ways to style and format text in HTML. The document is intended to teach HTML fundamentals.
The document provides an overview of key web technologies including:
- The World Wide Web (WWW) is a global system of interconnected documents accessed via URLs over HTTP. It consists of web servers that host content and web browsers that render pages.
- HTTP is the fundamental protocol of the WWW. It uses a request-response model where clients make requests that servers respond to. Common requests are GET to retrieve resources and POST to submit data.
- Cookies are small pieces of data stored by the client that are included in future HTTP requests to maintain state across interactions.
The document provides an overview of Dynamic HTML (DHTML) and its core technologies: HTML, CSS, JavaScript, and the DOM. It explains that DHTML allows dynamic and interactive web pages by combining these technologies. JavaScript is described as the scripting language that defines dynamic behavior, handling events and user interactions to manipulate the DOM. The document gives examples of common JavaScript functions, syntax elements, and how to incorporate JavaScript code into web pages.
The document provides steps for converting an image-based website design into XHTML and CSS code. It discusses identifying sections, deciding on a layout type, distinguishing content from style, and creating the basic page structure with appropriate HTML tags. Floating DIVs and DIVs that behave like tables are described as options for multi-column page layouts. Centering content, vertical alignment, and image formats are also covered.
The document discusses different XML parsers in Java including DOM, SAX, and StAX. DOM represents the XML document as an in-memory tree which allows flexible processing but uses more memory. SAX is event-driven and reads the XML sequentially using less memory. StAX is similar to SAX but simplified and "pull"-based where the developer manually navigates elements. The document also covers using JAXP for XML processing independence and the key classes involved in DOM and StAX parsing.
This document provides an introduction to XML, including:
1) It describes XML as a universal language for describing structured data in a platform-independent way, supported by the W3C.
2) It explains some key differences between XML and HTML, and when each should be used.
3) It discusses XML schemas like DTD and XSD that define rules for XML documents and enable validation.
This document provides an overview of using JDBC (Java Database Connectivity) to access databases from Java applications. It covers the main JDBC concepts like drivers, connections, statements, result sets, and transactions. It also describes the typical steps for querying and updating databases using JDBC: establishing a connection, creating statements, executing SQL statements, processing result sets, and closing resources. The document includes examples for connecting to Oracle and ODBC databases and using prepared statements. It discusses best practices like using connection pools, tuning transactions, and optimizing SQL queries.
The document provides an overview of common data structures including lists, stacks, queues, trees, and hash tables. It describes each data structure, how it can be implemented both statically and dynamically, and how to use the core Java classes like ArrayList, Stack, LinkedList, and HashMap that implement these structures. Key points covered include common operations for each structure, examples of using the Java classes, and applications like finding prime numbers in a range or matching brackets in an expression.
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingCeline George
The Accounting module in Odoo 17 is a complete tool designed to manage all financial aspects of a business. Odoo offers a comprehensive set of tools for generating financial and tax reports, which are crucial for managing a company's finances and ensuring compliance with tax regulations.
Odoo Inventory Rules and Routes v17 - Odoo SlidesCeline George
Odoo's inventory management system is highly flexible and powerful, allowing businesses to efficiently manage their stock operations through the use of Rules and Routes.
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...Celine George
Analytic accounts are used to track and manage financial transactions related to specific projects, departments, or business units. They provide detailed insights into costs and revenues at a granular level, independent of the main accounting system. This helps to better understand profitability, performance, and resource allocation, making it easier to make informed financial decisions and strategic planning.
The Pala kings were people-protectors. In fact, Gopal was elected to the throne only to end Matsya Nyaya. Bhagalpur Abhiledh states that Dharmapala imposed only fair taxes on the people. Rampala abolished the unjust taxes imposed by Bhima. The Pala rulers were lovers of learning. Vikramshila University was established by Dharmapala. He opened 50 other learning centers. A famous Buddhist scholar named Haribhadra was to be present in his court. Devpala appointed another Buddhist scholar named Veerdeva as the vice president of Nalanda Vihar. Among other scholars of this period, Sandhyakar Nandi, Chakrapani Dutta and Vajradatta are especially famous. Sandhyakar Nandi wrote the famous poem of this period 'Ramcharit'.
Exploring Substances:
Acidic, Basic, and
Neutral
Welcome to the fascinating world of acids and bases! Join siblings Ashwin and
Keerthi as they explore the colorful world of substances at their school's
National Science Day fair. Their adventure begins with a mysterious white paper
that reveals hidden messages when sprayed with a special liquid.
In this presentation, we'll discover how different substances can be classified as
acidic, basic, or neutral. We'll explore natural indicators like litmus, red rose
extract, and turmeric that help us identify these substances through color
changes. We'll also learn about neutralization reactions and their applications in
our daily lives.
by sandeep swamy
The *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responThe *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responses*: Insects can exhibit complex behaviors, such as mating, foraging, and social interactions.
Characteristics
1. *Decentralized*: Insect nervous systems have some autonomy in different body parts.
2. *Specialized*: Different parts of the nervous system are specialized for specific functions.
3. *Efficient*: Insect nervous systems are highly efficient, allowing for rapid processing and response to stimuli.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive in diverse environments.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive
How to Manage Opening & Closing Controls in Odoo 17 POSCeline George
In Odoo 17 Point of Sale, the opening and closing controls are key for cash management. At the start of a shift, cashiers log in and enter the starting cash amount, marking the beginning of financial tracking. Throughout the shift, every transaction is recorded, creating an audit trail.
The ever evoilving world of science /7th class science curiosity /samyans aca...Sandeep Swamy
The Ever-Evolving World of
Science
Welcome to Grade 7 Science4not just a textbook with facts, but an invitation to
question, experiment, and explore the beautiful world we live in. From tiny cells
inside a leaf to the movement of celestial bodies, from household materials to
underground water flows, this journey will challenge your thinking and expand
your knowledge.
Notice something special about this book? The page numbers follow the playful
flight of a butterfly and a soaring paper plane! Just as these objects take flight,
learning soars when curiosity leads the way. Simple observations, like paper
planes, have inspired scientific explorations throughout history.
Title: A Quick and Illustrated Guide to APA Style Referencing (7th Edition)
This visual and beginner-friendly guide simplifies the APA referencing style (7th edition) for academic writing. Designed especially for commerce students and research beginners, it includes:
✅ Real examples from original research papers
✅ Color-coded diagrams for clarity
✅ Key rules for in-text citation and reference list formatting
✅ Free citation tools like Mendeley & Zotero explained
Whether you're writing a college assignment, dissertation, or academic article, this guide will help you cite your sources correctly, confidently, and consistent.
Created by: Prof. Ishika Ghosh,
Faculty.
📩 For queries or feedback: [email protected]
Understanding P–N Junction Semiconductors: A Beginner’s GuideGS Virdi
Dive into the fundamentals of P–N junctions, the heart of every diode and semiconductor device. In this concise presentation, Dr. G.S. Virdi (Former Chief Scientist, CSIR-CEERI Pilani) covers:
What Is a P–N Junction? Learn how P-type and N-type materials join to create a diode.
Depletion Region & Biasing: See how forward and reverse bias shape the voltage–current behavior.
V–I Characteristics: Understand the curve that defines diode operation.
Real-World Uses: Discover common applications in rectifiers, signal clipping, and more.
Ideal for electronics students, hobbyists, and engineers seeking a clear, practical introduction to P–N junction semiconductors.
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schoolsdogden2
Algebra 1 is often described as a “gateway” class, a pivotal moment that can shape the rest of a student’s K–12 education. Early access is key: successfully completing Algebra 1 in middle school allows students to complete advanced math and science coursework in high school, which research shows lead to higher wages and lower rates of unemployment in adulthood.
Learn how The Atlanta Public Schools is using their data to create a more equitable enrollment in middle school Algebra classes.
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsDrNidhiAgarwal
Unemployment is a major social problem, by which not only rural population have suffered but also urban population are suffered while they are literate having good qualification.The evil consequences like poverty, frustration, revolution
result in crimes and social disorganization. Therefore, it is
necessary that all efforts be made to have maximum.
employment facilities. The Government of India has already
announced that the question of payment of unemployment
allowance cannot be considered in India
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessMark Soia
Boost your chances of passing the 2V0-11.25 exam with CertsExpert reliable exam dumps. Prepare effectively and ace the VMware certification on your first try
Quality dumps. Trusted results. — Visit CertsExpert Now: https://www.certsexpert.com/2V0-11.25-pdf-questions.html
2. Contents Relational Databases and Data Models SQL The HR Database Schema in Oracle Introducing SELECT Statement The WHERE Clause Sorting with ORDER BY Selecting Data From Multiple Tables
3. Contents (2) Selecting Data From Multiple Tables Natural Joins Join with USING Clause Inner Joins with ON Clause Left, Right and Full Outer Joins Cross Joins Nested SELECT Statements Aggregating Data Group Functions and GROUP BY
4. Contents (3) Oracle SQL Functions Oracle Data Types Data Definition Language (DDL) Creating Tables in Oracle Inserting Data Updating Data Deleting Data
6. Relational Database Concepts The relational model consists of the following: Collection of tables (called relations) Set of operators to act on the relations Data integrity for accuracy and consistency
7. Definition of a Database A relational database is a collection of relations (two-dimensional tables) Database Table Name: EMPLOYEES Table Name: DEPARTMENTS ZZZ Alexiev Danail 102 YYY Spasov Rosen 101 XXX Nakov Svetlin 100 EMAIL LAST_NAME FIRST_NAME EMPLOYEE_ID 124 Finances 50 201 Sales 20 200 IT 10 MANAGER_ID DEPARTMENT_NAME DEPARTMENT_ID
8. Data Models Model of system in client's mind Table model of entity model Entity model of client's model Database
9. Entity Relationship Model Create an entity relationship diagram from business specifications or narratives Scenario “ . . . Assign one or more employees to a department . . .” “ . . . Some departments do not yet have assigned employees . . .” EMPLOYEE #* number * name o job title DEPARTMENT #* number * name o location assigned to composed of
10. Relating Multiple Tables Each row of data in a table is uniquely identified by a primary key (PK) You can logically relate data from multiple tables using foreign keys (FK) Table Name: EMPLOYEES Table Name: DEPARTMENTS Primary key Foreign key Primary key 90 Alexiev Danail 102 50 Spasov Rosen 101 80 Nakov Svetlin 100 DEPARTMENT_ID LAST_NAME FIRST_NAME EMPLOYEE_ID Finances 50 Sales 20 IT 10 DEPARTMENT_NAME DEPARTMENT_ID
12. Relational Databases A relational database: Can be accessed and modified by executing S tructured Q uery L anguage (SQL) statements Uses a set of operations to extract subset of the data Contains a collection of tables Relationships are defined between the tables
13. Communicating with a DB SQL statement is sent to the database SQL statement is entered SELECT department_name FROM departments The result is returned (usually as a table) Database Finances Sales IT DEPARTMENT_NAME
15. What is SQL? Structured Query Language (SQL) Declarative language for query and manipulation of relational data SQL consists of: Data Manipulation Language (DML) SELECT , INSERT , UPDATE , DELETE Data Definition Language (DDL) CREATE , DROP , ALTER GRANT , REVOKE
19. Capabilities of SQL SELECT Table 1 Table 2 Table 1 Table 1 Selection Take some of the rows Projection Take some of the columns Join Combine tables by some column
20. Basic SELECT Statement SELECT identifies what columns FROM identifies which table SELECT *|{[DISTINCT] column|expression [alias],...} FROM table
21. SELECT Example Selecting all departments Selecting specific columns SELECT * FROM DEPARTMENTS SELECT DEPARTMENT_ID, LOCATION_ID FROM DEPARTMENTS 124 201 200 MANAGER_ID 1900 Shipping 50 1800 Marketing 20 1700 Administration 10 LOCATION_ID DEPARTMENT_NAME DEPARTMENT_ID 1900 50 1800 20 1700 10 LOCATION_ID DEPARTMENT_ID
22. Arithmetic Operations Arithmetic operators are available: +, -, *, / Example: SELECT LAST_NAME, SALARY, SALARY + 300 FROM EMPLOYEES 17000 17000 24000 SALARY 17300 De Haan 17300 Kochhar 24300 King SALARY + 300 LAST_NAME
23. The null Value A null is a value that is unavailable, unassigned, unknown, or inapplicable Not the same as zero or a blank space Arithmetic expressions containing a null value are evaluated to null SELECT LAST_NAME, MANAGER_ID FROM EMPLOYEES NULL is displayed as empty space or as (null) 100 100 (null) MANAGER_ID De Haan Kochhar King LAST_NAME
24. Column Alias Renames a column heading Useful with calculations Immediately follows the column name There is an optional AS keyword Double quotation marks if contains spaces SELECT LAST_NAME "Name" , 12*SALARY AS "Annual Salary" FROM EMPLOYEES 204000 288000 Annual Salary Kochhar King Name
25. Concatenation Operator Concatenates columns or character strings to other columns Is represented by two vertical bars ( || ) Creates a resultant column that is a character expression SELECT LAST_NAME || JOB_ID AS "Employees" FROM EMPLOYEES De Haan AD_VP Kochhar AD_VP King AD_PRES Employees
26. Literal Character Strings A literal is a character, a number, or a date included in the SELECT list Date and character literal values must be enclosed within single quotation marks Each character string is output once for each row returned SELECT LAST_NAME || ' is a ' || JOB_ID AS "Employee Details" FROM EMPLOYEES De Haan is a AD_VP Kochhar is a AD_VP King is a AD_PRES Employees
27. Removing Duplicate Rows The default display of queries is all rows, including duplicate rows Eliminate duplicate rows by using the DISTINCT keyword in the SELECT clause SELECT DEPARTMENT_ID FROM EMPLOYEES SELECT DISTINCT DEPARTMENT_ID FROM EMPLOYEES 60 ... 90 90 DEPARTMENT_ID ... 60 90 DEPARTMENT_ID
28. UNION and INTERSECT UNION combines the results from several SELECT statements The columns count and types should match INTERSECT makes logical intersection of given sets of records SELECT FIRST_NAME AS NAME FROM EMPLOYEES UNION SELECT LAST_NAME AS NAME FROM EMPLOYEES Abel Adam Alana Alberto ... NAME
29. Limiting the Rows Selected Restrict the rows returned by using the WHERE clause: More examples: SELECT LAST_NAME, DEPARTMENT_ID FROM EMPLOYEES WHERE DEPARTMENT_ID = 90 SELECT FIRST_NAME, LAST_NAME, JOB_ID FROM EMPLOYEES WHERE LAST_NAME = 'Whalen' SELECT LAST_NAME, SALARY FROM EMPLOYEES WHERE SALARY <= 3000 De Haan Kochhar King LAST_NAME 90 90 90 DEPARTMENT_ID
30. Using BETWEEN operator to specify a range: Using IN / NOT IN operators to specify a set of values: Using LIKE operator to specify a pattern: Other Comparison Conditions SELECT LAST_NAME, SALARY FROM EMPLOYEES WHERE SALARY BETWEEN 2500 AND 3000 SELECT FIRST_NAME, LAST_NAME, MANAGER_ID FROM EMPLOYEES WHERE MANAGER_ID IN (100, 101, 201) SELECT FIRST_NAME FROM EMPLOYEES WHERE FIRST_NAME LIKE 'S%'
31. Checking for NULL value: Note: COLUMN=NULL is always false! Using OR and AND operators: Other Comparison Conditions (2) SELECT LAST_NAME, MANAGER_ID FROM EMPLOYEES WHERE MANAGER_ID IS NULL SELECT LAST_NAME, JOB_ID, SALARY FROM EMPLOYEES WHERE SALARY >= 1000 AND JOB_ID LIKE '%MAN%' SELECT LAST_NAME FROM EMPLOYEES WHERE COMMISSION_PCT IS NOT NULL OR LAST_NAME LIKE '%S%'
32. Sorting with ORDER BY Sort rows with the ORDER BY clause ASC : ascending order, default DESC : descending order SELECT LAST_NAME, HIRE_DATE FROM EMPLOYEES ORDER BY HIRE_DATE SELECT LAST_NAME, HIRE_DATE FROM EMPLOYEES ORDER BY HIRE_DATE DESC Kochhar Whalen King LAST_NAME 21-SEP-89 17-SEP-87 17-JUN-87 HIRE_DATE Grant Mourgos Zlotkey LAST_NAME 24-MAY-99 16-NOV-99 29-JAN-00 HIRE_DATE
34. Data from Multiple Tables Sometimes you need data from more than one table: Fay Kochhar King LAST_NAME 20 90 90 DEPARTMENT_ID 10 20 90 DEPARTMENT_ID Administration Marketing Executive DEPARTMENT_NAME Kochhar Fay King LAST_NAME Executive Marketing Executive DEPARTMENT_NAME
35. Cartesian Product This will produce Cartesian product: The result: SELECT LAST_NAME, DEPARTMENT_NAME FROM EMPLOYEES, DEPARTMENTS Administration King Executive Kochhar Marketing Kochhar .. King King LAST_NAME .. Marketing Executive DEPARTMENT_NAME
36. Cartesian Product A Cartesian product is formed when: A join condition is omitted A join condition is invalid All rows in the first table are joined to all rows in the second table To avoid a Cartesian product, always include a valid join condition
37. Types of Joins Natural joins Join with USING clause Inner joins with ON clause Left, right and full outer joins Cross joins
38. Natural Join The NATURAL JOIN combines the rows from two tables that have equal values in all matched by name columns SELECT DEPARTMENT_ID, DEPARTMENT_NAME, LOCATION_ID, CITY FROM DEPARTMENTS NATURAL JOIN LOCATIONS ... Executive Administration Shipping IT DEPARTMENT_NAME ... 1700 1700 1500 1400 LOCATION_ID Seattle 10 Seattle 90 ... ... 50 60 DEPARTMENT_ID San Francisco Southlake CITY
39. Join with USING Clause If several columns have the same names we can limit the NATURAL JOIN to only one of them by the USING clause: SELECT E.EMPLOYEE_ID, E.LAST_NAME, D.LOCATION_ID, D.DEPARTMENT_NAME FROM EMPLOYEES E JOIN DEPARTMENTS D USING (DEPARTMENT_ID) IT 1400 Hunold 103 IT 1400 Ernst 104 ... 1700 LOCATION_ID ... De Haan LAST_NAME ... Executive DEPARTMENT_NAME ... 102 EMPLOYEE_ID
40. Inner Join with ON Clause To specify arbitrary conditions or specify columns to join, the ON clause is used Such JOIN is called also INNER JOIN SELECT E.EMPLOYEE_ID, E.LAST_NAME, E.DEPARTMENT_ID, D.DEPARTMENT_ID, D.LOCATION_ID FROM EMPLOYEES E JOIN DEPARTMENTS D ON (E.DEPARTMENT_ID = D.DEPARTMENT_ID) 20 20 10 DEPARTMENT_ID 20 20 10 DEPARTMENT_ID Fay Hartstein Whalen LAST_NAME 1800 1800 1700 LOCATION_ID 202 201 200 EMPLOYEE_ID
41. INNER vs. OUTER Joins The join of two tables returning only matched rows is an inner join A join between two tables that returns the results of the inner join as well as unmatched rows from the left (or right) table is a left (or right ) outer join A join between two tables that returns the results of an inner join as well as the results of a left and right join is a full outer join
42. INNER JOIN SELECT E.FIRST_NAME || ' ' || E.LAST_NAME AS MANAGER_NAME, D.DEPARTMENT_ID, D.DEPARTMENT_NAME FROM EMPLOYEES E INNER JOIN DEPARTMENTS D ON E.EMPLOYEE_ID=D.MANAGER_ID Shipping 50 Adam Fripp IT 60 Alexander Hunold Public Relations 70 Hermann Baer Human Resources 40 Susan Mavris Purchasing 30 Den Raphaely ... 20 10 DEPARTMENT_ID ... Marketing Administration DEPARTMENT_ NAME ... Michael Hartstein Jennifer Whalen MANAGER_NAME
43. LEFT OUTER JOIN SELECT E.FIRST_NAME || ' ' || E.LAST_NAME AS MANAGER_NAME, D.DEPARTMENT_ID, D.DEPARTMENT_NAME FROM EMPLOYEES E LEFT OUTER JOIN DEPARTMENTS D ON E.EMPLOYEE_ID=D.MANAGER_ID (null) (null) Jason Mallin (null) (null) Hazel Philtanker (null) (null) Nanette Cambrault (null) (null) Clara Vishney Purchasing 30 Den Raphaely ... 20 10 DEPARTMENT_ID ... Marketing Administration DEPARTMENT_ NAME ... Michael Hartstein Jennifer Whalen MANAGER_NAME
44. RIGHT OUTER JOIN SELECT E.FIRST_NAME || ' ' || E.LAST_NAME AS MANAGER_NAME, D.DEPARTMENT_ID, D.DEPARTMENT_NAME FROM EMPLOYEES E RIGHT OUTER JOIN DEPARTMENTS D ON E.EMPLOYEE_ID=D.MANAGER_ID Corporate Tax 130 (null) Control And Credit 140 (null) Shareholder Services 150 (null) Treasury 120 (null) Purchasing 30 Den Raphaely ... 20 10 DEPARTMENT_ID ... Marketing Administration DEPARTMENT_ NAME ... Michael Hartstein Jennifer Whalen MANAGER_NAME
45. FULL OUTER JOIN SELECT E.FIRST_NAME || ' ' || E.LAST_NAME AS MANAGER_NAME, D.DEPARTMENT_ID, D.DEPARTMENT_NAME FROM EMPLOYEES E FULL OUTER JOIN DEPARTMENTS D ON E.EMPLOYEE_ID=D.MANAGER_ID (null) (null) Jason Mallin ... ... ... Shareholder Services 150 (null) (null) (null) Clara Vishney ... ... ... ... 20 10 DEPARTMENT_ID ... Marketing Administration DEPARTMENT_ NAME ... Michael Hartstein Jennifer Whalen MANAGER_NAME
46. Three-Way Joins A three-way join is a join of three tables SELECT E.EMPLOYEE_ID, CITY, DEPARTMENT_NAME FROM EMPLOYEES E JOIN DEPARTMENTS D ON D.DEPARTMENT_ID = E.DEPARTMENT_ID JOIN LOCATIONS L ON D.LOCATION_ID = L.LOCATION_ID Administration San Francisco 124 ... Southlake Southlake CITY ... IT IT DEPARTMENT_ NAME ... 104 103 EMPLOYEE_ID
47. Cross Join The CROSS JOIN clause produces the cross-product of two tables Same as a Cartesian product Not often used SELECT LAST_NAME, DEPARTMENT_NAME FROM EMPLOYEES CROSS JOIN DEPARTMENTS Administration King Executive Kochhar .. King King LAST_NAME .. Marketing Executive DEPARTMENT_NAME
48. Additional Conditions You can apply additional conditions in the WHERE clause: SELECT E.EMPLOYEE_ID, E.FIRST_NAME || ' ' || E.LAST_NAME AS NAME, E.MANAGER_ID, E.DEPARTMENT_ID, D.DEPARTMENT_NAME FROM EMPLOYEES E JOIN DEPARTMENTS D ON (E.DEPARTMENT_ID = D.DEPARTMENT_ID) WHERE E.MANAGER_ID = 149 Sales 80 149 Ellen Abel 174 Sales 80 149 Alyssa Hutton 175 ... DEPARTMENT_ID ... MANAGER_ID ... NAME ... DEPARTMENT_NAME ... EMPLOYEE_ID
50. Nested SELECT Statements SELECT statements can be nested in the where clause Note: Always prefer joins to nested SELECT statements (better performance) SELECT FIRST_NAME, LAST_NAME, SALARY FROM EMPLOYEES WHERE SALARY = (SELECT MAX(SALARY) FROM EMPLOYEES) SELECT FIRST_NAME, LAST_NAME, SALARY FROM EMPLOYEES WHERE DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM DEPARTMENTS WHERE DEPARTMENT_NAME='Accounting')
51. Using the EXISTS operator in SELECT statements Find all employees that have worked in the past in the department #110 Using the EXISTS operator SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES E WHERE EXISTS (SELECT EMPLOYEE_ID FROM JOB_HISTORY JH WHERE DEPARTMENT_ID = 110 AND JH.EMPLOYEE_ID=E.EMPLOYEE_ID)
53. Group Functions Group functions operate on sets of rows to give one result per group 17000 102 17000 101 6000 104 ... 9000 24000 SALARY ... 103 100 EMPLOYEE_ID 24000 MAX(SALARY)
54. Group Functions in SQL COUNT(*) – count of the selected rows SUM(column ) – sum of the values in given column from the selected rows AVG(column ) – average of the values in given column MAX(column ) – the maximal value in given column MIN(column ) – the minimal value in given column
55. AVG() and SUM() Functions You can use AVG() and SUM() for numeric data types SELECT AVG(SALARY), MAX(SALARY), MIN(SALARY), SUM(SALARY) FROM EMPLOYEES WHERE JOB_ID LIKE '%REP%' 273000 SUM(SALARY) 6000 MIN(SALARY) 11500 MAX(SALARY) 8272.72 AVG(SALARY)
56. MIN() and MAX() Functions You can use MIN() and MAX() for any data type (number, date, varchar, ...) Displaying the first and last employee's name in alphabetical order: SELECT MIN(HIRE_DATE), MAX(HIRE_DATE) FROM EMPLOYEES SELECT MIN(LAST_NAME), MAX(LAST_NAME) FROM EMPLOYEES 29-JAN-00 MAX(HIRE_DATE) 17-JUN-1987 MIN(HIRE_DATE)
57. The COUNT( … ) Function COUNT(*) returns the number of rows in the result table COUNT( expr ) returns the number of rows with non-null values for the expr SELECT COUNT(*) FROM EMPLOYEES WHERE DEPARTMENT_ID = 50 SELECT COUNT(COMMISSION_PCT) FROM EMPLOYEES WHERE DEPARTMENT_ID = 80 5 COUNT(*) 3 COUNT(COMMISION_PCT)
58. Group Functions and Nulls Group functions ignore null values in the column If each null value in COMMISSION_PCT is considered as 0 and is included in the calculation, the result will be 0.0425 SELECT AVG(COMMISSION_PCT) FROM EMPLOYEES .2229 AVG(COMMISSION_PCT)
61. The GROUP BY Statement We can divide rows in a table into smaller groups by using the GROUP BY clause The syntax: The < group_by_expression> is a list of columns SELECT < columns> , < group_function(column)> FROM < table> [WHERE < condition> ] [GROUP BY < group_by_expression> ] [ORDER BY < columns >
62. The GROUP BY Statement Example of grouping data: The GROUP BY column does not have to be in the SELECT list SELECT DEPARTMENT_ID, SUM(SALARY) FROM EMPLOYEES GROUP BY DEPARTMENT_ID ... ... 7000 (null) 24900 30 51600 100 SUM(SALARY) DEPARTMENT_ID
64. Grouping by Several Columns – Example Example of grouping data by several columns: SELECT DEPARTMENT_ID, JOB_ID, COUNT(EMPLOYEE_ID), SUM(SALARY) FROM EMPLOYEES GROUP BY DEPARTMENT_ID, JOB_ID ORDER BY SUM(SALARY) DESC ... 80 50 80 DEPARTMENT_ID ... SA_MAN SH_CLERK SA_REP JOB_ID ... ... 61000 5 64300 20 243500 29 SUM(SALARY) COUNT( EMPLOYEE_ID)
65. Illegal Queries This SELECT statement is illegal Can not combine columns with groups functions unless when using GROUP BY This SELECT statement is also illegal Can not use WHERE for group functions SELECT DEPARTMENT_ID, COUNT(LAST_NAME) FROM EMPLOYEES SELECT DEPARTMENT_ID, AVG(SALARY) FROM EMPLOYEES WHERE AVG(SALARY) > 8000 GROUP BY DEPARTMENT_ID;
66. Using GROUP BY with HAVING Clause HAVING works like WHERE but is used for the grouping functions SELECT DEPARTMENT_ID, COUNT(EMPLOYEE_ID), AVG (SALARY) FROM EMPLOYEES GROUP BY DEPARTMENT_ID HAVING COUNT(EMPLOYEE_ID) BETWEEN 3 AND 6 60 90 30 100 DEPARTMENT_ID 5760 5 19333.33 3 4150 6 8600 6 AVG (SALARY) COUNT(EMPLOYEE_ID)
67. Using Grouping Functions and Table Joins We can apply grouping function from joined tables SELECT COUNT(*) AS EMPS, DEPARTMENT_NAME FROM EMPLOYEES E JOIN DEPARTMENTS D ON E.DEPARTMENT_ID=D.DEPARTMENT_ID WHERE HIRE_DATE BETWEEN '1991-1-1' AND '1997-12-31' GROUP BY DEPARTMENT_NAME HAVING COUNT(*) > 5 ORDER BY EMPS DESC 15 19 EMPS Sales Shipping DEPARTMENT_NAME
69. Oracle Data Types NUMBER – integer number (up to 38 digits) NUMBER(p , s ) – integer/real number of given precision p and scale s NUMBER(10, 2) – fixed point real number VARCHAR2(size) – string of variable length up to given size (locale specific) VARCHAR2(50) – string of length up to 50 NVARCHAR2(size) – Unicode string of variable length up to given size
70. Oracle Data Types (2) DATE – date between Jan 1, 4712 BC and Dec 31, 9999 AD TIMESTAMP – date and time (year, month, day, hour, minute, and seconds) Precision can be defined BLOB – binary large data object, RAW data (up to 128 TB) Can contain photos, videos, etc. CLOB , NCLOB – character large data object (up to 128 TB)
73. Creating Objects CREATE / CREATE OR REPLACE commands CREATE TABLE <name> (<fields definitions>) CREATE SEQUENCE <name> CREATE VIEW <name> AS <select> CREATE TABLE PERSONS ( PERSON_ID INTEGER NOT NULL, NAME NVARCHAR2(50) NOT NULL, CONSTRAINT PERSON_PK PRIMARY KEY(PERSON_ID) ) CREATE OR REPLACE VIEW PERSONS_TOP_10 AS SELECT NAME FROM PERSONS WHERE ROWNUM <= 10
74. Modifying Objects ALTER command ALTER TABLE <name> <command> ALTER -- Add a foreign key constraint TOWN --> COUNTIRY ALTER TABLE TOWN ADD CONSTRAINT TOWN_COUNTRY_FK FOREIGN KEY (COUNTRY_ID) REFERENCES COUNTRY(ID) ENABLE -- Add column COMMENT to the table PERSON ALTER TABLE PERSONS ADD ("COMMENT" VARCHAR2(800)) -- Remove column COMMENT from the table PERSON ALTER TABLE PERSONS DROP COLUMN "COMMENT"
75. Deleting Objects DROP command DROP TABLE <name> DROP SEQUENCE <name> DROP TRIGGER <name> DROP INDEX <name> DROP SEQUENCE SEQ_PERSON DROP CONSTRAINT TRG_PERSON_INSERT DROP TABLE PERSONS
77. Creating Tables in Oracle Creating new table: Define the table name Define the columns and their types Define the table primary key Define a sequence for populating the primary key Define a trigger for automatically populate the primary key on insertion Define foreign/keys and constraints
78. Creating Tables in Oracle – Example CREATE TABLE PERSONS ( PERSON_ID NUMBER NOT NULL, NAME VARCHAR2(100) NOT NULL, CONSTRAINT PERSONS_PK PRIMARY KEY(PERSON_ID) ); CREATE SEQUENCE SEQ_PERSONS; CREATE TRIGGER TRG_PERSONS_INSERT BEFORE INSERT ON PERSONS FOR EACH ROW BEGIN SELECT SEQ_PERSONS.nextval INTO :new.PERSON_ID FROM dual; END;
80. Inserting Data INSERT command INSERT INTO <table> VALUES (<values>) INSERT INTO <table>(<columns>) VALUES (<values>) INSERT INTO <table> SELECT <values> INSERT INTO COUNTRY VALUES ('1', 'Bulgaria', 'Sofia') INSERT INTO COUNTRY(NAME, CAPITAL) VALUES ('Bulgaria', 'Sofia') INSERT INTO COUNTRY(COUNTRY_ID, NAME, CAPITAL) SELECT NULL, COUNTRY, CAPITAL FROM CAPITALS
82. Updating Data UPDATE command UPDATE <table> SET <column=expression> WHERE <condition> Note: Don't forget the WHERE clause! UPDATE PERSONS SET NAME = 'Updated Name' WHERE PERSON_ID = 1 UPDATE EMPLOYEES SET SALARY = SALARY * 1.10 WHERE DEPARTMENT_ID = 3
83. Updating Joined Tables Updating joined tables is done by nested SELECT UPDATE (SELECT SALARY FROM EMPLOYEES E INNER JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID WHERE D.NAME = 'Accounting') SET SALARY = SALARY * 1.10
85. Deleting Data Deleting rows from a table DELETE FROM <table> WHERE <condition> Note: Don’t forget the WHERE clause! Delete all rows from a table at once TRUNCATE TABLE < table > DELETE FROM PERSONS WHERE PERSON_ID = 1 DELETE FROM PERSONS WHERE NAME LIKE 'S%' TRUNCATE TABLE PERSONS
86. Problems What is SQL? What is DML? What is DDL? Recite the most important SQL commands. What is PL/SQL? Start Oracle SQL Developer and connect to the database. Use the HR user. Examine the major tables in the HR schema. Write a SQL query to find all information about all department. Write a SQL query to find all department names. Write a SQL query to find the salary of each employee by month, by day and hour. Consider that one month has 20 workdays and each workday has 8 work hours.
87. Problems (2) Write a SQL query to find the email addresses of each employee. Consider that the mail domain is mail.somecompany.com . Emails should look like " [email_address] ". The produced column should be names "Full Email Address". Write a SQL query to find all different salaries that are paid to the employees. Write a SQL query to find all information about the employees whose position is "AC_MGR" (Accounting Manager). Write a SQL query to find the names of all employees whose first name starts with "Sa".
88. Problems (3) Write a SQL query to find the names of all employees whose last name contains the character sequence " ei ". Write a SQL query to find the names of all employees whose salary is in the range [3000...5000]. Write a SQL query to find the names of all employees whose salary is 2500, 4000 or 5000. Write a SQL query to find all locations that has no state or post code defined. Write a SQL query to find all employees that are paid more than 10000. Order them in decreasing order by salary.
89. Problems (4) Write a SQL query to find to top 5 best paid employees. Write a SQL query to find all departments and the town of their location. Use natural join. Write a SQL query to find all departments and the town of their location. Use join with USING clause. Write a SQL query to find all departments and the town of their location. Use inner join with ON clause. Write a SQL query to find all the locations and the departments for each location along with the locations that do not have department. User right outer join. Rewrite the query to use left outer join.
90. Problems (5) Write a SQL query to find the manager of each department. Write a SQL query to find the location of each department manager. Write a SQL query to find the names of all employees from the departments "Sales" and "Finance" whose hire year is between 1995 and 2000. Write a SQL query to find the names and salaries of the employees that take the minimal salary in the company. Use nested SELECT statement. Write a SQL query to find the names and salaries of the employees that take a salary that is up to 10% higher than the minimal salary for the company.
91. Problems (6) Write a SQL query to find the average salary in the "Sales" department. Write a SQL query to find the number of employees in the "Sales" department. Write a SQL query to find the number of all locations where the company has an office. Write a SQL query to find the number of all departments that has manager. Write a SQL query to find the number of all departments that has no manager. Write a SQL query to find all departments and the average salary for each of them.
92. Problems (7) Write a SQL query to find the count of all employees in each department and for each manager. Write a SQL query to find all managers that have exactly 5 employees. Display their names and the name and location of their department. Write a SQL query to find all departments along with their managers. For departments that do not have manager display "(no manager)". Write a SQL query to find the names of all employees whose last name is exactly 5 characters long. Write a SQL query to print the current date and time in the format " day.month.year hour:minutes:seconds ".
93. Problems (8) Write a SQL statement to create a table USERS. Users should have username, password, full name and last login time. Choose appropriate data types for the fields of the table. Define a primary key column with a primary key constraint. Define a sequence for populating the primary key. Define a trigger to update the primary key column value before inserting a record. Write a SQL statement to create a view that displays the users from the USERS table that have been in the system today. Test if the view works correctly.
94. Problems (9) Write a SQL statement to create a table GROUPS. Groups should have unique name (use unique constraint). Define primary key and a sequence and a trigger for populating it. Write a SQL statement to add a column GROUP_ID to the table USERS. Fill some data in this new column and as well in the GROUPS table. Write a SQL statement to add a foreign key constraint between tables USERS and GROUPS. Write SQL statements to insert several records in the USERS and GROUPS tables.
95. Problems (10) Write SQL statements to insert in the USER table the names of all employees from the EMPLOYEES table. Combine the first and last names as a full name. For user name use the email column from EMPLOYEES. Use blank password. Write a SQL statement that changes the password to NULL for all USERS that have not been in the system since 10.03.2006. Write a SQL statement that deletes all users without passwords (NULL or empty password).
96. Homework Write a SQL query to display the average employee salary by country. Write a SQL query to display the average employee salary by region. Write a SQL query to display the country of each employee along with his name and department city. Write a SQL query to display the country where maximal number of employees work. Write a SQL query to display the number of managers for each region and each country. Define table WORKHOURS to store work reports for each employee (date, task, hours, comments). Don't forget to define automatically populated primary key (primary key constraint + sequence + trigger).
97. Homework (2) Define foreign key between the tables WORKHOURS and EMPLOYEE. Add additional column in the employee table if needed. Write several SQL statements to fill some data in the WORKHOURS table. Write a SQL query to find all the average work hours per week for each country. Write a SQL query to find all the departments where some employee worked overtime (over 8 hours/day) during the last week. Write a SQL query to find all employees that have worked 3 or more days overtime in the last week. Display their name, location department and country.