The document discusses various SQL statements used for database, table, column, and record operations. It covers how to create, delete, and rename databases and tables. It also explains how to add, modify, and delete columns, set default values and unique constraints on columns. The document also covers creating indexes, procedures, functions, check constraints, and updating records.
This document discusses summary queries in SQL. It explains that summary queries are used to retrieve aggregate or summary information rather than details of individual records. It describes SQL column functions such as SUM, AVG, MIN, MAX, COUNT that can be used to summarize data. It also discusses GROUP BY and HAVING clauses that allow grouping and filtering of aggregated data. Subqueries and the CASE statement for conditional logic in SQL queries are also briefly covered.
The document discusses various SQL query concepts including:
1. Search conditions (predicates) in SQL queries including comparison tests, range tests, set membership tests, pattern matching tests, and null value tests.
2. The UNION feature allows combining the results of two or more queries into a single table. Query results combined with UNION can be sorted using an ORDER BY clause.
3. JOIN operations combine data from two or more tables by linking a column in one table with that in another table. Inner joins and outer joins are explained with examples.
The document discusses SQL JOIN statements. It defines an INNER JOIN as returning rows when there is at least one match between two tables. It provides an example of using INNER JOIN to combine data from Customers and Orders tables based on matching CustomerNumber columns. It also provides a simple example using INNER JOIN to extract customer names and total sales amounts from Customers and Sales tables by matching on CustomerID.
SQL statements manipulate data in relational databases. The main types are data manipulation (SELECT, INSERT, DELETE, UPDATE), data definition (CREATE TABLE, DROP TABLE), and transaction control (COMMIT, ROLLBACK). Tables contain rows and columns identified by unique names. Primary keys uniquely identify each row, and foreign keys in one table match primary keys in another to link the tables. Relational databases follow Codd's twelve rules including representing all data in tables, supporting null values, and providing a comprehensive sublanguage like SQL.
This document provides examples of SQL queries to retrieve data from databases. It covers basic SELECT statements to retrieve all or some columns from tables, sorting and filtering results, using functions like COUNT and AVG, joining data from multiple tables, and using wildcard characters in queries. The examples demonstrate how to select, filter, sort, aggregate, and join data using SQL.
The document summarizes topics that will be covered in an advanced SQL training seminar, including SQL statement types, data types, aggregate functions, NULL handling, comparison operators, mathematical functions, joins, subqueries, views, materialized views, inline views, and optimizing SQL queries. Techniques for data sharing between databases are also mentioned. The seminar aims to provide in-depth knowledge of SQL concepts through explanations, examples, exercises and discussion.
This document discusses various SQL functions and concepts including:
1. Single row and multiple row/aggregate functions where single row functions return one result per row and aggregate functions return one result for a group of rows. Common aggregate functions discussed are AVG, COUNT, MAX, MIN, and SUM.
2. The GROUP BY clause which combines records with the same field values and the HAVING clause which specifies conditions for grouped data.
3. Joins which combine data from multiple tables. Types discussed are Cartesian products and equi-joins.
4. SQL constraints including NOT NULL, DEFAULT, UNIQUE, and PRIMARY KEY constraints.
Sql server ___________session 3(sql 2008)Ehtisham Ali
This document discusses several new features in SQL Server 2008 related to data manipulation language (DML) and XML data types, including table value constructors, table-valued parameters, the MERGE statement, enhanced GROUP BY functionality using ROLLUP, CUBE, and GROUPING SETS, and improved XML data type handling. It provides examples and explanations of the syntax and usage for each feature.
This document discusses summary queries in SQL. It explains that summary queries are used to retrieve aggregate or summary information rather than details of individual records. It describes SQL column functions such as SUM, AVG, MIN, MAX, COUNT that can be used to summarize data. It also discusses GROUP BY and HAVING clauses that allow grouping and filtering of aggregated data. Subqueries and the CASE statement for conditional logic in SQL queries are also briefly covered.
The document discusses various SQL query concepts including:
1. Search conditions (predicates) in SQL queries including comparison tests, range tests, set membership tests, pattern matching tests, and null value tests.
2. The UNION feature allows combining the results of two or more queries into a single table. Query results combined with UNION can be sorted using an ORDER BY clause.
3. JOIN operations combine data from two or more tables by linking a column in one table with that in another table. Inner joins and outer joins are explained with examples.
The document discusses SQL JOIN statements. It defines an INNER JOIN as returning rows when there is at least one match between two tables. It provides an example of using INNER JOIN to combine data from Customers and Orders tables based on matching CustomerNumber columns. It also provides a simple example using INNER JOIN to extract customer names and total sales amounts from Customers and Sales tables by matching on CustomerID.
SQL statements manipulate data in relational databases. The main types are data manipulation (SELECT, INSERT, DELETE, UPDATE), data definition (CREATE TABLE, DROP TABLE), and transaction control (COMMIT, ROLLBACK). Tables contain rows and columns identified by unique names. Primary keys uniquely identify each row, and foreign keys in one table match primary keys in another to link the tables. Relational databases follow Codd's twelve rules including representing all data in tables, supporting null values, and providing a comprehensive sublanguage like SQL.
This document provides examples of SQL queries to retrieve data from databases. It covers basic SELECT statements to retrieve all or some columns from tables, sorting and filtering results, using functions like COUNT and AVG, joining data from multiple tables, and using wildcard characters in queries. The examples demonstrate how to select, filter, sort, aggregate, and join data using SQL.
The document summarizes topics that will be covered in an advanced SQL training seminar, including SQL statement types, data types, aggregate functions, NULL handling, comparison operators, mathematical functions, joins, subqueries, views, materialized views, inline views, and optimizing SQL queries. Techniques for data sharing between databases are also mentioned. The seminar aims to provide in-depth knowledge of SQL concepts through explanations, examples, exercises and discussion.
This document discusses various SQL functions and concepts including:
1. Single row and multiple row/aggregate functions where single row functions return one result per row and aggregate functions return one result for a group of rows. Common aggregate functions discussed are AVG, COUNT, MAX, MIN, and SUM.
2. The GROUP BY clause which combines records with the same field values and the HAVING clause which specifies conditions for grouped data.
3. Joins which combine data from multiple tables. Types discussed are Cartesian products and equi-joins.
4. SQL constraints including NOT NULL, DEFAULT, UNIQUE, and PRIMARY KEY constraints.
Sql server ___________session 3(sql 2008)Ehtisham Ali
This document discusses several new features in SQL Server 2008 related to data manipulation language (DML) and XML data types, including table value constructors, table-valued parameters, the MERGE statement, enhanced GROUP BY functionality using ROLLUP, CUBE, and GROUPING SETS, and improved XML data type handling. It provides examples and explanations of the syntax and usage for each feature.
1. The document provides an overview of MySQL concepts including databases, tables, keys, and SQL commands.
2. It defines databases, DBMS, relational databases, RDBMS, benefits of using a DBMS, and introduces MySQL as an open source RDBMS.
3. It also covers SQL commands like SELECT, INSERT, UPDATE, DELETE and concepts like data types, constraints, indexes and functions.
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDev Chauhan
(i) DDL (Data Definition Language) is used to define the schema of the database. It is used to create, modify or delete definitions of database objects like tables, indexes, views etc.
(ii) DML (Data Manipulation Language) is used to manipulate the data present in the database. It is used to insert, update or delete rows/records from tables. Examples are SELECT, INSERT, UPDATE, DELETE statements.
(iii) Primary Key is a column or set of columns in a table that uniquely identifies each row/record in the table. It must contain unique values and cannot contain NULL values.
(iv) Candidate Key is a column or set of columns that can uniquely identify rows/records in a
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.
The document discusses various SQL concepts like views, triggers, functions, indexes, joins, and stored procedures. Views are virtual tables created by joining real tables, and can be updated, modified or dropped. Triggers automatically run code when data is inserted, updated or deleted from a table. Functions allow reusable code and improve clarity. Indexes allow faster data retrieval. Joins combine data from different tables. Stored procedures preserve data integrity.
This document provides an overview of Chapter 3 from the textbook "Database System Concepts, 7th Ed." by Silberschatz, Korth and Sudarshan. It covers the history and components of SQL, data definition and manipulation languages, basic query structure, predicates, null values, and set operations in SQL. Key topics include the CREATE TABLE statement, data types, integrity constraints, SELECT statements, joins, ordering results, and aggregate functions.
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.
The document discusses various SQL concepts including creating and dropping databases and tables, data types, SQL statements for inserting, updating and deleting records, joining tables, and aggregation functions. It provides syntax and examples for commands like CREATE DATABASE, CREATE TABLE, INSERT, UPDATE, DELETE, SELECT, WHERE, GROUP BY, UNION and functions like COUNT, SUM, AVG, MAX, MIN. The document is meant as a guide for students to learn fundamental SQL concepts through explanations, syntax and hands-on activities like creating a table.
The document discusses subqueries, backups, users, and privileges in SQL. It defines subqueries as SELECT statements nested inside other SELECT statements. Subqueries can include joins, WHERE clauses, and more. The document explains the terminology used in subqueries including inner and outer queries. It provides examples of different types of subqueries like those in the SELECT list, using operators like IN, ANY, ALL, and EXISTS. The document also discusses backups and why they are important to protect against data loss from hardware failures, natural disasters, and human errors. HAVING clauses are introduced as a way to use aggregate functions in queries.
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.
The document discusses SQL data manipulation topics including retrieving data using SELECT statements, filtering rows with WHERE clauses, sorting results with ORDER BY, grouping data with GROUP BY, restricting groups with HAVING, and using subqueries. It provides examples of each concept and rules for writing SQL statements and using different clauses.
1. The document provides information on database concepts like the system development life cycle, data modeling, relational database management systems, and creating and managing database tables in Oracle.
2. It discusses how to create tables, add, modify and delete columns, add comments, define constraints, create views, and perform data manipulation operations like insert, update, delete in Oracle.
3. Examples are provided for SQL statements like CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE VIEW, INSERT, UPDATE, DELETE.
This document defines SQL data definition statements and basic SQL query structure. It discusses DDL statements like CREATE, ALTER, and DROP that are used to define and manage database structures. It also explains the typical components of an SQL query including the SELECT, FROM, and WHERE clauses. Finally, it outlines several set operations in SQL like UNION, UNION ALL, INTERSECT, and MINUS.
The document provides an overview of SQL commands and syntax for creating and managing databases, tables, and querying data. Key points covered include:
- SQL commands for defining schema (CREATE TABLE), manipulating data (INSERT, UPDATE, DELETE), and querying data (SELECT).
- Data types, constraints, indexes and joins.
- Examples of SQL syntax for common queries and operations like filtering, sorting, aggregation, and joining tables.
This document discusses Structured Query Language (SQL) and its role in relational database management systems. It covers:
1) SQL allows for standardized database access, reducing training costs and increasing application portability.
2) SQL commands include data definition language (DDL) to define schemas, data manipulation language (DML) to query and modify data, and data control language (DCL) to manage privileges.
3) The SELECT statement is used to query tables, allowing the use of functions, expressions, wildcards, and clauses like WHERE, GROUP BY, HAVING, and ORDER BY.
Clauses in Sql(Structured Query Language), distinct clause, where clause, where clause, order by clause, group by clause, having clause, Relational Database Management System
The document discusses SQL DML statements like SELECT, INSERT, UPDATE, and DELETE. It provides examples of using each statement to manipulate data in tables. It also covers additional SQL clauses and functions like WHERE, ORDER BY, GROUP BY, JOIN, and aggregate functions that can be used with the SELECT statement to filter, sort, group, and perform calculations on the result set.
This tutorial will give you a quick start to SQL including examples. It covers most of the topics required for a basic understanding of SQL and to get a feel of how it works.
1. The document describes experiments related to SQL DDL, DML commands and SELECT statements.
2. It discusses commands like CREATE TABLE, ALTER TABLE, DROP TABLE, INSERT, SELECT, UPDATE, DELETE and provides syntax and examples for each.
3. Queries are provided at the end of each experiment to create tables, insert data, modify structure, retrieve and manipulate data using the studied commands.
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.
SQL is a language used to retrieve and manipulate data stored in relational database tables. It allows users to perform operations like selecting data, inserting rows, updating records, and deleting data. The four fundamental SQL statements are SELECT, INSERT, UPDATE, and DELETE. SQL statements follow a basic syntax and include keywords like SELECT, FROM, WHERE to query data and sort results.
Farhim Shaikh is seeking a job and has provided his contact information, objective, education history, work experience, technical skills, college and personal projects, and competencies. He completed a TYBSCIT degree in 2015 and has basic knowledge of programming languages like C++, C#, Java, and ASP.NET. His college projects include a student portal for his college and hospital management and travel booking applications. He is willing to learn, a team player, and has good communication skills.
This presentation was part of the CocoaHeadsBE session on Nov 27th, 2014 at the iCapps offices in Antwerp, Belgium.
You can find the examples here: https://github.com/Inferis/Practical-AutoLayout
1. The document provides an overview of MySQL concepts including databases, tables, keys, and SQL commands.
2. It defines databases, DBMS, relational databases, RDBMS, benefits of using a DBMS, and introduces MySQL as an open source RDBMS.
3. It also covers SQL commands like SELECT, INSERT, UPDATE, DELETE and concepts like data types, constraints, indexes and functions.
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDev Chauhan
(i) DDL (Data Definition Language) is used to define the schema of the database. It is used to create, modify or delete definitions of database objects like tables, indexes, views etc.
(ii) DML (Data Manipulation Language) is used to manipulate the data present in the database. It is used to insert, update or delete rows/records from tables. Examples are SELECT, INSERT, UPDATE, DELETE statements.
(iii) Primary Key is a column or set of columns in a table that uniquely identifies each row/record in the table. It must contain unique values and cannot contain NULL values.
(iv) Candidate Key is a column or set of columns that can uniquely identify rows/records in a
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.
The document discusses various SQL concepts like views, triggers, functions, indexes, joins, and stored procedures. Views are virtual tables created by joining real tables, and can be updated, modified or dropped. Triggers automatically run code when data is inserted, updated or deleted from a table. Functions allow reusable code and improve clarity. Indexes allow faster data retrieval. Joins combine data from different tables. Stored procedures preserve data integrity.
This document provides an overview of Chapter 3 from the textbook "Database System Concepts, 7th Ed." by Silberschatz, Korth and Sudarshan. It covers the history and components of SQL, data definition and manipulation languages, basic query structure, predicates, null values, and set operations in SQL. Key topics include the CREATE TABLE statement, data types, integrity constraints, SELECT statements, joins, ordering results, and aggregate functions.
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.
The document discusses various SQL concepts including creating and dropping databases and tables, data types, SQL statements for inserting, updating and deleting records, joining tables, and aggregation functions. It provides syntax and examples for commands like CREATE DATABASE, CREATE TABLE, INSERT, UPDATE, DELETE, SELECT, WHERE, GROUP BY, UNION and functions like COUNT, SUM, AVG, MAX, MIN. The document is meant as a guide for students to learn fundamental SQL concepts through explanations, syntax and hands-on activities like creating a table.
The document discusses subqueries, backups, users, and privileges in SQL. It defines subqueries as SELECT statements nested inside other SELECT statements. Subqueries can include joins, WHERE clauses, and more. The document explains the terminology used in subqueries including inner and outer queries. It provides examples of different types of subqueries like those in the SELECT list, using operators like IN, ANY, ALL, and EXISTS. The document also discusses backups and why they are important to protect against data loss from hardware failures, natural disasters, and human errors. HAVING clauses are introduced as a way to use aggregate functions in queries.
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.
The document discusses SQL data manipulation topics including retrieving data using SELECT statements, filtering rows with WHERE clauses, sorting results with ORDER BY, grouping data with GROUP BY, restricting groups with HAVING, and using subqueries. It provides examples of each concept and rules for writing SQL statements and using different clauses.
1. The document provides information on database concepts like the system development life cycle, data modeling, relational database management systems, and creating and managing database tables in Oracle.
2. It discusses how to create tables, add, modify and delete columns, add comments, define constraints, create views, and perform data manipulation operations like insert, update, delete in Oracle.
3. Examples are provided for SQL statements like CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE VIEW, INSERT, UPDATE, DELETE.
This document defines SQL data definition statements and basic SQL query structure. It discusses DDL statements like CREATE, ALTER, and DROP that are used to define and manage database structures. It also explains the typical components of an SQL query including the SELECT, FROM, and WHERE clauses. Finally, it outlines several set operations in SQL like UNION, UNION ALL, INTERSECT, and MINUS.
The document provides an overview of SQL commands and syntax for creating and managing databases, tables, and querying data. Key points covered include:
- SQL commands for defining schema (CREATE TABLE), manipulating data (INSERT, UPDATE, DELETE), and querying data (SELECT).
- Data types, constraints, indexes and joins.
- Examples of SQL syntax for common queries and operations like filtering, sorting, aggregation, and joining tables.
This document discusses Structured Query Language (SQL) and its role in relational database management systems. It covers:
1) SQL allows for standardized database access, reducing training costs and increasing application portability.
2) SQL commands include data definition language (DDL) to define schemas, data manipulation language (DML) to query and modify data, and data control language (DCL) to manage privileges.
3) The SELECT statement is used to query tables, allowing the use of functions, expressions, wildcards, and clauses like WHERE, GROUP BY, HAVING, and ORDER BY.
Clauses in Sql(Structured Query Language), distinct clause, where clause, where clause, order by clause, group by clause, having clause, Relational Database Management System
The document discusses SQL DML statements like SELECT, INSERT, UPDATE, and DELETE. It provides examples of using each statement to manipulate data in tables. It also covers additional SQL clauses and functions like WHERE, ORDER BY, GROUP BY, JOIN, and aggregate functions that can be used with the SELECT statement to filter, sort, group, and perform calculations on the result set.
This tutorial will give you a quick start to SQL including examples. It covers most of the topics required for a basic understanding of SQL and to get a feel of how it works.
1. The document describes experiments related to SQL DDL, DML commands and SELECT statements.
2. It discusses commands like CREATE TABLE, ALTER TABLE, DROP TABLE, INSERT, SELECT, UPDATE, DELETE and provides syntax and examples for each.
3. Queries are provided at the end of each experiment to create tables, insert data, modify structure, retrieve and manipulate data using the studied commands.
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.
SQL is a language used to retrieve and manipulate data stored in relational database tables. It allows users to perform operations like selecting data, inserting rows, updating records, and deleting data. The four fundamental SQL statements are SELECT, INSERT, UPDATE, and DELETE. SQL statements follow a basic syntax and include keywords like SELECT, FROM, WHERE to query data and sort results.
Farhim Shaikh is seeking a job and has provided his contact information, objective, education history, work experience, technical skills, college and personal projects, and competencies. He completed a TYBSCIT degree in 2015 and has basic knowledge of programming languages like C++, C#, Java, and ASP.NET. His college projects include a student portal for his college and hospital management and travel booking applications. He is willing to learn, a team player, and has good communication skills.
This presentation was part of the CocoaHeadsBE session on Nov 27th, 2014 at the iCapps offices in Antwerp, Belgium.
You can find the examples here: https://github.com/Inferis/Practical-AutoLayout
This document contains a summary of an exam on Internet Technology. The exam covers topics such as ARP, IP, TCP, RIP, OSPF, BGP, RMI, CORBA, WLAN, Socket Programming and more. It provides short questions to test understanding of concepts and protocols within each topic area. For example, it asks students to define fields in ARP packets, steps for IP checksum calculation, TCP header control bits, differences between RMI and CORBA, and how connections are established with ServerSocket and Socket classes. The exam aims to evaluate knowledge of fundamental Internet and network programming concepts.
The document provides instructions for a practical examination on project management. It includes multiple scenarios to be modeled using UML diagrams, including class diagrams, activity diagrams, use case diagrams, and work breakdown structures. Students are asked to draw diagrams for scenarios involving university course modeling, payroll systems, library management systems, ATM cash withdrawals, online paper submissions, and software development projects. The tasks assess students' ability to analyze requirements and derive UML diagrams from descriptive texts.
Geographic Information System (GIS) is a set of computer tools for collecting, storing, retrieving, transforming, and displaying spatial data. GIS integrates spatial information within a single system and allows users to manipulate and display geographic knowledge in new ways. GIS brings together technology from fields like geography, cartography, remote sensing, and computer science to analyze and solve real world problems with geographic components.
The document discusses various Data Definition Language (DDL) commands in SQL such as CREATE, ALTER, and DROP for defining and modifying database structure. It explains how to create tables with columns, constraints, indexes and views. It also covers removing tables and altering table definitions by adding, modifying or dropping columns, constraints and indexes. Different database architectures like single, multi database and distributed databases are also summarized.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
The document describes experiments conducted in a Database Management System lab. It includes steps to install MySQL, create databases and tables, perform CRUD operations, implement integrity constraints, use aggregate functions and joins. The key points are:
1) Installing MySQL and verifying the installation.
2) Creating databases and tables with commands like CREATE DATABASE and CREATE TABLE.
3) Performing insertion, updation, deletion and selection of data using SQL commands.
Data Definition Language (DDL), Data Definition Language (DDL), Data Manipulation Language (DML) , Transaction Control Language (TCL) , Data Control Language (DCL) - , SQL Constraints
DDL(Data defination Language ) Using OracleFarhan Aslam
The document discusses DDL and DCL commands in Oracle including naming rules for objects, data types, creating tables, constraints, defining constraints, updating and violating constraints, creating tables using subqueries, altering tables, views, sequences, granting and revoking privileges, and dropping tables. It also discusses the Oracle data dictionary.
2. DBMS Experiment - Lab 2 Made in SQL UsedTheVerse1
The document describes a database management system lab covering integrity constraints and data manipulation language (DML). It defines various integrity constraints like primary key, unique key, foreign key, check, default and NOT NULL constraints. It also explains how to create tables, alter tables, insert, update and delete data using DML commands. Experiments are described to design tables for different systems using appropriate integrity constraints and populate them with sample data using DML statements.
The document provides an overview of SQL commands and operations including:
1) Creating a database and table, inserting and selecting data, updating records with WHERE clauses.
2) Altering tables by adding or modifying columns and constraints.
3) Different SQL statements like SELECT, INSERT, UPDATE and DELETE and clauses like WHERE are discussed along with syntax and examples.
SQL is a database sublanguage used to query and modify relational databases. It consists of two categories of statements: DDL (data definition language) used to define database schema objects like tables and indexes, and DML (data manipulation language) used to manipulate data within those objects. Oracle's SQL*Plus tool allows users to enter, edit, run and format SQL statements against an Oracle database. Common Oracle database objects include tables, views, indexes, triggers, and users. SQL statements like CREATE TABLE, ALTER TABLE, INSERT, UPDATE, DELETE and SELECT are used to define and manipulate data in database tables.
SQL is a relational database language used to define, manipulate, and control access to data in a relational database. SQL statements are used to perform tasks like data retrieval, insertion, deletion, updating and table/database management. The basic structure of an SQL query involves selecting data from one or more tables to display or use. SQL supports features like constraints, indexes, views, triggers that enforce data integrity and security.
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.
Les09 (using ddl statements to create and manage tables)Achmad Solichin
Using DDL Statements to Create and Manage Tables
The document discusses using DDL statements to create and manage database tables. It covers categorizing database objects like tables, views, indexes, and sequences. It also covers the syntax for creating tables, specifying column names and data types, creating constraints, and dropping tables. Examples are provided for creating a simple table, adding constraints, creating a table using a subquery, and altering or dropping existing tables.
The document provides information on various SQL commands used to create and manage databases and tables. It explains how to use SHOW, CREATE DATABASE, USE, SHOW TABLES, CREATE TABLE, DESCRIBE, ALTER TABLE, SELECT, UPDATE, DELETE, INSERT, CREATE VIEW commands. It also discusses table constraints like NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY and provides examples of how to implement them in CREATE TABLE and ALTER TABLE statements.
Using DDL Statements to Create and Manage Tables
This document discusses using data definition language (DDL) statements to create and manage database tables. It covers categorizing database objects like tables, views, and indexes; defining table structures with columns and data types; creating tables with the CREATE TABLE statement; adding constraints at table creation; and dropping tables with DROP TABLE. The key topics are creating simple tables, understanding available data types, defining columns and constraints, and using DDL statements like CREATE TABLE, ALTER TABLE, and DROP TABLE to manage tables.
The document discusses how to create and manage database tables. Key topics covered include using CREATE TABLE to define table structure, ALTER TABLE to modify tables, DROP TABLE to remove tables, and TRUNCATE TABLE to delete all rows. Datatypes, naming conventions, adding comments, and joining tables with subqueries are also summarized.
The document describes Data Definition Language (DDL) commands in SQL. It explains that DDL allows the specification of relations, schemas, domains, integrity constraints, indices, security, and storage structures. The core DDL commands are CREATE, ALTER, and DROP. CREATE is used to define new tables with columns, data types, primary keys, foreign keys and other constraints. ALTER modifies existing tables by adding, dropping, renaming columns or modifying column properties. DROP removes tables from the database. Examples are provided for each command demonstrating how to define, modify and remove tables for a university database schema.
Data Manipulation(DML) and Transaction Control (TCL) MuhammadWaheed44
A short course "SQL Fundamentals - Oracle 11g" is being in progress at PMAS Arid Agriculture University. Complete course video and can be found at following link
https://www.youtube.com/playlist?list=PL12t8CWUhXZaUXsmg7M67o_Q37JhhfAKU
This document discusses how to create a database and table in SQL. It explains that the CREATE DATABASE statement is used to create a new database by specifying the database name. An example shows a database called "testDB" being created. It also explains that the CREATE TABLE statement is used to create a new table by specifying the table name and column names along with their data types. An example shows a table called "Persons" being created with five columns for storing a person's ID, name, address and city.
This document provides instructions for experiments in a Database Management System laboratory course. It includes a list of 12 experiments covering topics like Data Definition Language commands, Data Manipulation Language commands, database design using ER modeling and normalization, and implementation of various database applications. It also provides details on the hardware and software requirements for the course, as well as the internal assessment structure including marks distribution.
This document discusses how to create, manage, and modify database tables in Oracle. The key points covered include how to create tables with column definitions and datatypes, alter tables by adding, modifying or dropping columns, rename and truncate tables, and add comments to tables. Operations like create, alter, drop, and truncate allow managing the structure of tables, while comments provide descriptive information.
The document discusses how to create a database and tables in SQL using DDL statements like CREATE, DROP, and ALTER. It explains that CREATE is used to define new database objects, DROP removes objects, and ALTER modifies objects. Specific examples show how to create a database called ABCCO, and tables like Persons with columns for ID, name, city. It also covers defining primary keys, foreign keys, default and null values when creating 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.
The Elphinstonian 1988-College Building Centenary Number (2).pdfMukesh Tekwani
This is the 1988 issue of The Elphinstonian, the annual magazine of Elphinstone College, Mumbai. This is the special issue to commemorate the Century of the Elphinstone College Building in Mumbai.
This document contains lecture notes on various topics related to gravitation and orbital mechanics:
1. It defines Newton's law of gravitation and the gravitational constant G.
2. It discusses the difference between G and g, the acceleration due to gravity, and derives the relation between the two.
3. It then covers concepts like the critical velocity, time period, binding energy, and escape velocity required for a satellite to orbit or escape the gravitational pull of Earth.
4. Additional topics include weightlessness in satellites, variation of g with altitude and depth, and the definition of latitude.
ISCE-Class 12-Question Bank - Electrostatics - PhysicsMukesh Tekwani
This is a 14 page question bank on the chapters of Electrostatics. This is based on the syllabus of most Board exams such as CBSE, ISCE and state boards.
Extremely important topic for Digital electronics, digital circuits, computer architecture and computer science.
Full video is available on Youtube: https://youtu.be/oyOaXqx06pY
This video explains the method of converting a decimal number to a binary number. Many solved examples are given here and also two exercises which you can attempt on your own and then check the answers.
I have also discussed the concept of LSB (least significant bit) and MSB (most significant bit), and also least significant digit (LSD) and most significant digit (MSD).
This topic is important for following courses: class 11 and 12 computer science of all state boards, class 11 and 12 physics, BSc Computer science, BSc IT, MCA (Masters degree in Computer Applications), BTech, BE (First Year), and many competitive examinations.
Free Lectures on YouTube for IGCSE Physics for the syllabus effective 2020-21. These lectures cover the syllabus of IGCSE and a major part of GCSE syllabus also.
1. The Hidden Meaning of Words in Science Question Papers
2. Scientific Notation or Powers of Ten Notation
3. Units and Base Quantities
4. What is Physics?
Refraction and dispersion of light through a prismMukesh Tekwani
This document contains 20 important theory questions about refraction and dispersion of light through a prism. Some key topics covered are:
1) The angle of deviation of light passing through a prism depends on factors like the refracting angle of the prism and the angle of incidence of light.
2) When white light passes through a prism, it disperses into its constituent colors due to the refractive index of the material being different for different wavelengths of light.
3) In the position of minimum deviation, the angles of incidence and refraction of a monochromatic light ray passing through a prism are related to the refracting angle of the prism.
This document contains important theory questions about refraction of light at a plane surface and total internal reflection. It includes 24 multiple choice and derivation questions covering topics such as Snell's law, refractive index, critical angle, total internal reflection, mirages, reflecting prisms, reversing prisms, erecting prisms, optical fibers, and their applications. The document was prepared by Mukesh N Tekwani and provides a comprehensive review of key concepts and formulas relating to the refraction and total internal reflection of light.
This document contains 10 important theory questions about spherical mirrors. It defines key terms used to describe spherical mirrors such as pole, center of curvature, radius of curvature, principal axis, aperture, principal focus, focal length and focal plane. It also derives several important relationships for spherical mirrors, including that the focal length of a concave or convex mirror of small aperture is half the radius of curvature, and the mirror formula relating the focal length to the object and image distances. Finally, it derives the magnification formula for concave mirrors and asks which type of spherical mirror is preferable for observing traffic from a car.
Atom, origin of spectra Bohr's theory of hydrogen atomMukesh Tekwani
This document contains 15 important theory questions about Rutherford's alpha particle scattering experiment, Rutherford's model of the atom, its limitations, Bohr's model of the hydrogen atom, Bohr's postulates, expressions for the stationary and kinetic energy levels of an electron in the hydrogen atom, the energy level diagram for hydrogen showing different emission series, and definitions of terms like Rydberg constant, excitation potential, and ionization potential. The questions are related to key experiments and models in the development of atomic structure and spectra.
Refraction of light at spherical surfaces of lensesMukesh Tekwani
This document contains 15 important theory questions about refraction of light at spherical surfaces and lenses. It includes questions about sign convention in optics, the optical center of a lens, focal length of concave and convex lenses, lens maker's formula, derivation of expressions for refraction at single spherical surfaces and thin lens combinations, linear magnification by a lens, location of a virtual image formed by a convex lens based on focal length, dependence of focal length on wavelength, definition and unit of power of a lens, definition of 1 dioptre, formula for combined power of two lenses in contact, and laws governing image formation by lenses. The questions cover key concepts like derivation, definition, diagrams, formulas, and image formation.
This document outlines the unit-wise weightage for the February 2020 ISCE Class 12 Physics board exam. Unit 3 on Magnetic Effects of Current and Magnetism has the highest weightage at 16. Other highly weighted units include Electromagnetic Induction and Alternating Currents at 14, and Optics at 12. The lowest weighted units are Communication Systems at 2 and Electronic Devices at 8.
What is Cyber Law? Why is cyber security law needed? International cyber law. What is copyright? What are security, controls, privacy, piracy and ethics? Code of ethics for computer professionals. What is cyber insurance?
The document discusses the disadvantages of HTML and the advantages of using XML instead. It notes that HTML lacks structure, syntax checking, and is not suitable for data interchange or describing semantics. XML was designed to store, describe, and transport data, unlike HTML which was designed for display. XML simplifies data sharing and transport between applications since it separates data from presentation and uses plain text. It also allows for international character support and makes data more available and reusable.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
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.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
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.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
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
1. SQL Simple Queries – Ch 5
SQL Queries - Basics
Worksheet - 2
DATABASE OPERATIONS
1 CREATE Database Statement:
This statement is used to create a database.
Syntax
CREATE DATABASE { databasename }
Arguments database
Is the name of the database which is to be created..
Example:
CREATE DATABASE student
2 Deleting a database with DROP statement
This statement is used to delete a database.
Syntax
DROP DATABASE { databasename }
Arguments: database
Example:
DROP DATABASE student
TABLE OPERATIONS
3 Creating a Table – the CREATE TABLE statement
CREATE TABLE tablename (Column1, Column2, Column3,…)
Each column is created as
ColumnName DataType Options
Example:
CREATE TABLE Student
(
RollNo nvarchar(32),
DOB DATE,
FullName nvarchar(50),
Address NVARCHAR(120),
City NvarChar(40),
State NVarChar(50),
PostalCode nvarchar(20),
HomePhone nvarchar(20),
);
Prof. Mukesh N. Tekwani Page 1 of 11
2. SQL Simple Queries – Ch 5
4 Delete a table with DROP TABLE statement
DROP TABLE TableName
COLUMN OPERATIONS
5 How will you specify unique values in a column?
You may want a column to receive a unique value for each of its records. To specify
that a column will require unique values, use the UNIQUE keyword.
USE College;
CREATE TABLE Students
(
RollNo int UNIQUE,
FirstName nvarchar(50),
LastName nvarchar(50) NOT NULL
);
When a column has been marked as unique, during data entry, the user must provide
a unique value for each new record created. If an existing value is assigned to the
column, this would produce an error:
USE College;
CREATE TABLE Students
(
StudentNumber int UNIQUE,
FirstName nvarchar(50),
LastName nvarchar(50) NOT NULL
);
INSERT INTO Students
VALUES(2, 'Jitesh', 'Patel'),
(9, 'Rani', 'Shah'),
(4, 'Preeti', 'Patel'),
(9, 'Deepak', 'Tiwari'),
(6, 'Priyanka', 'Chopra');
By the time the fourth record is entered, since it uses a student number that exists already,
the database engine would produce an error.
6 What is a check constraint? Explain, with the help of a suitable example, how to
create a check constraint.
Check Constraint:
When performing data entry, in some columns, we may want to restrict a range of
values that are allowed. We can create a rule that must be followed on a combination
of columns before the record can be created. For example, you can ask the database
engine to check that at least one of two columns received a value. For example, on a
table that holds information about customers, you can ask the database engine to
check that, for each record, either the phone number or the email address of the
Page 2 of 11 mukeshtekwani@hotmail.com
3. SQL Simple Queries – Ch 5
customer is entered.
The ability to verify that one or more rules are respected on a table is called a check
constraint. A check constraint is a Boolean operation performed by the SQL
interpreter. The interpreter examines a value that has just been provided for a
column.
If the value is appropriate:
a. The constraint produces TRUE
b. The value gets accepted
c. The value is assigned to the column
If the value is not appropriate:
a. The constraint produces FALSE
b. The value gets rejected
c. The value is not assigned to the column
You create a check constraint at the time you are creating a table.
Example:
1. To create a table that has a check mechanism, type the following:
CREATE TABLE Customers
(
CustomerID int ,
AccountNumber nchar(10) UNIQUE,
FullName nvarchar(50) NOT NULL,
PhoneNumber nvarchar(20),
EmailAddress nvarchar(50),
CONSTRAINT CK_CustomerContact
CHECK ((PhoneNumber IS NOT NULL) OR (EmailAddress IS NOT NULL))
);
2. To add records to the new table, type the following:
INSERT INTO Customers(AccountNumber, FullName,
PhoneNumber, EmailAddress)
VALUES('39', 'Anita', '301-128-3506', 'anita@yahoo.com'),
('62', 'Preeti', '(202) 050-1629', 'preeti@hotmail.com'),
('86', 'Julie', '410-114-6820', 'julie@email.net');
3. To try adding a new record to the table, type the following:
INSERT INTO Customers(AccountNumber, FullName)
VALUES('22', 'Jiten')
Notice that you receive an error.
7 Explain how a default value can be given to a column.
A default value is one that a column would apply to its record if a value is not
Prof. Mukesh N. Tekwani Page 3 of 11
4. SQL Simple Queries – Ch 5
provided. You can assign a default value when creating a table.
To specify the default value in a SQL statement, when creating the column, before the
semi-colon or the closing parenthesis of the last column, assign the desired value to
the DEFAULT keyword.
After creating the table, the user does not have to provide a value for a column that
has a default. If the user does not provide the value, the default would be used when
the record is saved.
Example 1:
CREATE TABLE Employees
(
FullName NVARCHAR(50),
Address NVARCHAR(80),
City NVARCHAR(40),
State NVARCHAR(40) DEFAULT 'Maharashtra',
PinCode NVARCHAR(4) DEFAULT '400001',
Country NVARCHAR(20) DEFAULT 'India'
);
Example 2:
The default value can also come from a function.
CREATE TABLE Employees
(
EmployeeName nvarchar(50),
DateHired datetime DEFAULT GETDATE(),
Address nvarchar(50),
City nvarchar(40),
State nchar(2) DEFAULT 'Maharashtra',
PostalCode NVARCHAR(4),
Country NVARCHAR(20)
);
Example 3:
If the table exists already and you want to add a column that has a default value, use
this method:
ALTER TABLE TableName ADD ColumnName Options
Here is an example:
USE Exercise1;
ALTER TABLE Employees
ADD HomePhone nvarchar(20) default '(000) 000-0000';
8 Explain how a column can contain an expression.
An expression used on a column is a combination of operators and operands used to
produce the value of the column. The user will not enter a value for such a column.
Page 4 of 11 mukeshtekwani@hotmail.com
5. SQL Simple Queries – Ch 5
Example 1:
To create an expression in SQL, in the placeholder of the column, enter the name of
the column, followed by AS, and followed by the desired expression.
CREATE TABLE Circle
(
CircleID int NOT NULL,
Radius decimal(8, 3) NOT NULL,
Area AS Radius * Radius * PI()
);
When performing data entry, we must not provide a value for a column that has an
expression; the SQL interpreter would provide the value automatically.
INSERT INTO Circle(Radius) VALUES(46.82);
INSERT INTO Circle(Radius) VALUES(8.15);
INSERT INTO Circle(Radius) VALUES(122.57);
RECORD OPERATIONS
9 Updating a Record
Updating a record means changing or more of its values. SQL provides the UPDATE
keyword:
Example 1:
UPDATE TableName
SET ColumnName = Expression
Example 2:
UPDATE TableName
SET ColumnName = Expression
WHERE Condition(s)
Example 3:
UPDATE Videos
SET YearReleased = 1996
WHERE VideoID = 5;
10 How can a column or a table be renamed?
The sp_rename command changes the name of an object.
Syntax
sp_rename 'object_name' , 'new_name' , 'object_type'
‘objecttype’ is the type of the object being renamed. This object may be a TABLE, a
COLUMN, a DATABASE, or an INDEX.
To change the name of a column, we specify the command as shown below:
Prof. Mukesh N. Tekwani Page 5 of 11
6. SQL Simple Queries – Ch 5
Example 1:
This example renames the contact title column in the customers table to title.
EXEC sp_rename 'customers.[contact title]', 'title', 'COLUMN'
Example 2:
To rename a column called rno to RollNo in the tybsc table:
EXEC sp_rename 'tybsc.rno', 'RollNo', 'COLUMN'
To change the name of a table, we specify the command as shown below:
EXEC sp_rename 'tybscit', 'tybsc'
11 How can a database be deleted?
The DROP DATABASE command is used to delete or DROP a database.
Syntax
DROP DATABASE database_name [ ,...n ]
One or more databases can be deleted in this way.
To use DROP DATABASE, the database context of the connection must be in the master
database. A database that is currently in use cannot be dropped.
Example 1:
Drop a single database called publishing,
DROP DATABASE publishing
Example 2:
Delete databases called sybscit and tybscit.
DROP DATABASE sybscit, tybscit
12 Explain functions in SQL.
In Transact-SQL, the primary formula of creating a function is:
CREATE FUNCTION FunctionName()
For a function to be useful, it must produce a result and return a value. When creating
a function, we must specify the type of value that the function would return.
To provide this information, after the name of the function, type the RETURNS
keyword followed by a definition for a data type.
Page 6 of 11 mukeshtekwani@hotmail.com
7. SQL Simple Queries – Ch 5
Example 1:
CREATE FUNCTION Addition()
RETURNS Decimal(6,3)
After specifying the type of value that the function would return, you can create a
body for the function. The body of a function starts with the BEGIN and ends with the
END keywords.
CREATE FUNCTION Addition()
RETURNS Decimal(6,3)
BEGIN
END
Between the BEGIN and END keywords, we can define the statements the function must
perform. After performing this assignment, just before the END keyword, you must specify
the value that the function returns. This is done by typing the RETURN keyword followed
by an expression.
CREATE FUNCTION Addition()
RETURNS Decimal(6,3)
BEGIN
RETURN Expression
END
Function Calling:
After a function has been created, we can use the value it returns. Using a function is
also referred to as calling it. To call a function, you must qualify its name. To do this,
type the name of the database in which it was created, followed by the period
operator, followed by dbo, followed by the period operator, followed by the name of
the function, and its parentheses. The formula to use is:
DatabaseName.dbo.FunctionName()
A Parameterized Function
To create a function that takes a parameter, specify a name and the type of value of
the parameter(s) in its parentheses. Here is an example:
CREATE FUNCTION Addition(@Number1 Decimal(6,2))
When a function takes a parameter, in the body of the function, you can use the
parameter as if you knew its value, as long as you respect the type of that value. Here
is an example:
CREATE FUNCTION Addition(@Number1 Decimal(6,2))
RETURNS Decimal(6,2)
BEGIN
RETURN @Number1 + 1450
END
Prof. Mukesh N. Tekwani Page 7 of 11
8. SQL Simple Queries – Ch 5
13 Explain what is meant by a procedure in SQL.
A procedure is a collection of SQL statements.
One of the simplest procedures is selecting columns from a table. This is done with the
SELECT operator.
For example, to create a stored procedure that would hold a list of students from a
table named Students, we would create the procedure as follows:
CREATE PROCEDURE GetStudDetails
AS
BEGIN
SELECT FirstName, LastName, DateOfBirth, Gender
FROM Students
END
Executing a Procedure
To execute a procedure, you use the EXECUTE keyword followed by the name of the
procedure.
EXECUTE ProcedureName
Instead of EXECUTE, you can use the EXEC keyword:
EXEC ProcedureName
For example, if you have a procedure named GetStudDetails, to execute it, we would
type:
EXECUTE GetStudentIdentification
Example 3:
Write a procedure that creates the full name using the fields ‘FirstName’ and ‘LastName’
CREATE PROCEDURE GetStudentIdentification
AS
BEGIN
SELECT FullName = FirstName + ' ' + LastName,
DateOfBirth, Gender
FROM Students
END
Example 4:
Write a procedure that calls a function in its body.
USE STUDENT;
CREATE PROCEDURE GetStudentsAges
AS
BEGIN
SELECT FullName = FirstName + N' ' + LastName,
DATEDIFF(year, DateOfBirth, GETDATE()) AS Age,
Gender
FROM Students
END
Page 8 of 11 mukeshtekwani@hotmail.com
9. SQL Simple Queries – Ch 5
14 How can a procedure be modified?
ALTER PROCEDURE ProcedureName
AS
Body of Procedure
How can a procedure be deleted?
When we don’t need a procedure anymore, we can delete it.
There are various types of stored procedures, some of which are considered
temporary. Those types of procedures delete themselves when not needed anymore,
such as when the person who created the stored procedure disconnects from the
database or shuts down the computer. Otherwise, to delete a procedure, you can use
either the Object Explorer or SQL.
To delete a procedure in SQL, the syntax to use is:
DROP PROCEDURE ProcedureName
INDEX
15
What is an index?
If you take a look at the last pages of a book (such as a book about mathematics,
computer science, etc), you may find a series of pages that start in a section label
Index. The words in that series allow you to locate a section of the book that
mentions, explains, or describes the word and related topics. An index in a book
makes it easy and fast to get to a section of a book that deals with a particular topic.
Like a book, a table or a view can use the mechanism provided by an index. In a table
or a view, an index is a column (or many columns) that can be used to locate records
and take a specific action based on some rule reinforced on that (those) column(s).
16
How can an index be created in SQL?
To create an index in SQL, the basic formula to follow is:
CREATE INDEX IndexName ON Table/View(Column(s))
The creation on an index starts with the CREATE INDEX expression, followed by a
name for the index, followed by the ON keyword. In the Table/View placeholder, enter
the name of the table or view for which you want to create the index, followed by
parentheses in which you enter at least one column.
Example 1:
-- =============================================
-- Database: Exercise
-- =============================================
USE master
Prof. Mukesh N. Tekwani Page 9 of 11
10. SQL Simple Queries – Ch 5
-- Drop the database if it already exists
IF EXISTS (
SELECT name
FROM sys.databases
WHERE name = 'Exercise'
)
DROP DATABASE Exercise
CREATE DATABASE Exercise
USE Exercise;
-- =============================================
-- Database: Exercise
-- Table; Employees
-- =============================================
CREATE TABLE Employees
(
EmployeeNumber int NOT NULL,
LastName nvarchar(20) NOT NULL,
FirstName nvarchar(20),
Username nchar(8) NOT NULL,
DateHired date NULL,
HourlySalary money
);
GO
INSERT INTO Employees
VALUES(62480, 'James', 'Haans', 'jhaans', '1998-10-25', 28.02),
(35844, 'Gertrude', 'Monay', 'gmonay', '2006-06-22', 14.36),
(24904, 'Philomène', 'Guillon', 'pguillon', '2001-10-16', 18.05),
(48049, 'Eddie', 'Monsoon', 'emonsoon', '08/10/2009', 26.22),
(25805, 'Peter', 'Mukoko', 'pmukoko', '03-10-2004', 22.48),
(58405, 'Chritian', 'Allen', 'callen', '06/16/1995', 16.45);
GO
CREATE INDEX IX_Employees
ON Employees(EmployeeNumber);
GO
If the index will include more than one column, list them separated by commas. Here
is an example:
CREATE INDEX IX_Employees
ON Employees(LastName, Username);
GO
17
How can an index be deleted?
If you don't need an index anymore, you can delete it.
The basic syntax to delete an index is:
DROP INDEX IndexName ON TableName;
Page 10 of 11 mukeshtekwani@hotmail.com
11. SQL Simple Queries – Ch 5
In this formula, replace the TableName with the name of the table that contains the
index. Replace the IndexName with the name of the index you want to get rid of.
Here is an example:
USE Exercise;
GO
DROP INDEX IX_Employees ON Employees;
TRIGGERS
18
What is a trigger?
When an action has been performed on a table, such as adding a new record, changing
(editing/updating) an existing record, or deleting a record, the table produces a
notification. We say that the table fires an event. You can use this occurring event to
take some action.
A trigger is an action that is performed behind-the-scenes when an event occurs on a
table.
Prof. Mukesh N. Tekwani Page 11 of 11