This document provides an overview of database concepts including creating, altering, and dropping databases and tables. It discusses data definition language (DDL) commands like CREATE, ALTER, DROP as well as data manipulation language (DML) commands like INSERT, SELECT, UPDATE, DELETE. It also covers database constraints, joins, functions for aggregation, strings, numbers, dates and more. The document is an introduction to core SQL concepts for a course on data management and database design.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
YouTube Link: https://youtu.be/zbMHLJ0dY4w
** MySQL DBA Certification Training: https://www.edureka.co/mysql-dba **
This Edureka video on 'SQL Basics for Beginners' will help you understand the basics of SQL and also sql queries which are very popular and essential.. In this SQL Tutorial for Beginners you will learn SQL from scratch with examples. Following topics have been covered in this sql tutorial.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
A presentation about MySQL for beginners. It includes the following topics:
- Introduction
- Installation
- Executing SQL statements
- SQL Language Syntax
- The most important SQL commands
- MySQL Data Types
- Operators
- Basic Syntax
- SQL Joins
- Some Exercise
Tomasz Kopacz: Architektura i service fabric - jak budować aplikacje w paas v2AnalyticsConf
Service Fabric zmienia sposób myślenia o architekturze rozwiązań. Skalowanie warstwy UI jest proste. Ale - w przypadku logiki biznesowej, dotychczas można było albo budować szybko działające aplikacje typu "monolit" albo - skalowalne, n-warstwowe aplikacje oparte o kolejki (i podobne mechanizmy). Tu - dzięki zupełnie innemu podejściu do problemu - można te światy połączyć. Sesja dosyć techniczna!
YouTube Link: https://youtu.be/zbMHLJ0dY4w
** MySQL DBA Certification Training: https://www.edureka.co/mysql-dba **
This Edureka video on 'SQL Basics for Beginners' will help you understand the basics of SQL and also sql queries which are very popular and essential.. In this SQL Tutorial for Beginners you will learn SQL from scratch with examples. Following topics have been covered in this sql tutorial.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
A presentation about MySQL for beginners. It includes the following topics:
- Introduction
- Installation
- Executing SQL statements
- SQL Language Syntax
- The most important SQL commands
- MySQL Data Types
- Operators
- Basic Syntax
- SQL Joins
- Some Exercise
Tomasz Kopacz: Architektura i service fabric - jak budować aplikacje w paas v2AnalyticsConf
Service Fabric zmienia sposób myślenia o architekturze rozwiązań. Skalowanie warstwy UI jest proste. Ale - w przypadku logiki biznesowej, dotychczas można było albo budować szybko działające aplikacje typu "monolit" albo - skalowalne, n-warstwowe aplikacje oparte o kolejki (i podobne mechanizmy). Tu - dzięki zupełnie innemu podejściu do problemu - można te światy połączyć. Sesja dosyć techniczna!
Tor Hovland: Taking a swim in the big data lakeAnalyticsConf
Are you curious about the possibilities enabled by Microsoft Azure and Cortana Analytics? Come and see how to handle data input from a large number of “Internet of Things” devices, how to work with all the data, how to scale big computations, how to make predictions, and how to build applications on top of it. There will be demos!
This presentation is part of LearnItFirst's SQL Server 2012: A Comprehensive Introduction course. The video that contains this presentation can be watched here:
https://www.youtube.com/watch?v=00Wh8kmu9Ds
This slideshow will cover what Reporting Services is, how to install it, and what you can do with it. We will talk about the components that make up the architecture of SSRS, and the what/where/when/how of Reporting Services reports. Course 174: SQL Server 2012 Reporting Services will cover Reporting Services 2012 in detail and include report design, creation, dashboards, deployment, administration, SharePoint integration, and much more!
Highlights from this slideshow:
- What is SQL Server 2012 Reporting Services?
- What are the three components that makeup the architecture of SSRS?
- Where are report developed?
- Where can Reporting Services reports be stored?
- What else does the report server do besides connecting to the data source and creating reports?
- Where and when can reports be delivered to?
- Which editions of SQL Server 2012 include SSRS?
Denny Lee\'s Data Camp v1.0 talk on SSRS Best Practices for ITBala Subra
Building and Deploying Large Scale SQL Server Reporting Services Environments Technical Note:
* Report Catalog sizing
* The benefits of File System snapshots for SSRS 2005
* Why File System snapshots may not help for SSRS 2008
* Using Cache Execution
* Load Balancing your Network
* Isolate your workloads
* Report Data Performance Considerations
Rafał Korszuń: Security in Design of Cloud ApplicationsAnalyticsConf
W jaki sposób projektowanie aplikacji wpływa na bezpieczeństwo? Zasady projektowania aplikacji krytycznych ze względu na charakter przetrzymywanych danych. Omówienie ciekawszych przypadków wdrożenia lub nie securyty designu.
Sesja zapoznawcza na temat narzędzia Microsoftu do analizy danych – PowerBI. Koncepcja działania. Obsługiwane platformy. Wymagania. Źródła danych. Pulpit nawigacyjny i dashboardy oraz dostępne wizualizacje.
Ground floor introduction to the tools and best practices surrounding SQL Server’s built-in web-based, enterprise-level reporting engine. We'll start with what SSRS is, what you'll use it for and give top tips to know when developing your first reports.
This is a word file for SQL COMMANDS and including some basic information regarding SQL. I hope it will help you a lot while doing SQL and its functions and commands.
A. Table Basic Data Types- Char, varchar/varchar2, long, number, Fixed Commands to create table Commands for table handling- Alter table, Drop table, Insert records B. Commands for record handling Update, Delete Select with operators like arithmetic, comparison, logical Query Expression operators Ordering the records with orderby Grouping the records C. SQL functions Date, Numeric, Character, conversion Group functions avg, max, min, sum, count Set operations- Union, Union all, intersect, minu
2. • DDL
• CREATE
• USE
• ALTER
• DROP
• DML
• INSERT
• SELECT
• UPDATE
• DELETE
• Data Manipulating Functions – Functions in SQL Statement
• Summary Functions
• String and Numeric Functions
• Comparison and Cast Functions
• Control Flow Functions
• Date/Time Functions
OVERVIEW PART - I
3. • Joins
• Inner Join
• Outer Join
– Left Outer Join
– Right Outer Join
– Full Outer Join
• Cross Join
• Self Join
• Operators – Union and Union All
OVERVIEW PART - II
4. CREATE DATABASE [IF NOT EXISTS] <database name>;
- IF NOT EXISTS checks whether database with the same name exists or not
USE <database name>;
- Defines the context for creating tables or executing any statement for that database
ALTER DATABASE <database name>
- Allows you to change CHARACTER SET and/or COLLATE of database
DROP DATABASE <database name>;
- Allows you to delete database with all tables in it
Example:
CREATE DATABASE [IF NOT EXISTS] Customer;
USE Customer;
ALTER DATABASE Customer COLLATE latin1_bin;
DROP DATABASE Customer;
DATABASE: CREATE, USE, ALTER, DROP
6. • NOT NULL - A value in a column can not be NULL
• UNIQUE - Each row for a column must have a unique value
• PRIMARY KEY - Identifies each record uniquely. Its a
combination of a NOT NULL and UNIQUE. Ensures that a column
(or combination of two or more columns) have an unique
identity which helps to find a particular record in a table more
easily and quickly
• FOREIGN KEY - Ensure the referential integrity of the data in one
table to match values in another table
• CHECK - Ensures that the value in a column meets a specific
condition
• DEFAULT - Specifies a default value when specified none for this
column
CONSTRAINTS
9. INSERT INTO table_name
VALUES (value1,value2,value3,...),(value1,value2,value3,...),…;
INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3);
INSERT INTO table_name (column1, column2)
VALUES (value1, value2);
Example:
INSERT INTO Customer(CustomerID,LastName,FirstName,Address,City,SSN)
VALUES (234,'Dinoriya','Ashwin','Longwood','NewYork',1234567890);
INSERT INTO Customer
VALUES (123,'Ingle','Tanmay','Cityview','Boston',9876543210);
INSERT INTO Customer(CustomerID, LastName, Address, City)
VALUES (345,'Cardinal','Skagen 21','Norway');
INSERT INTO
10. UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;
Example
UPDATE Customer
SET FirstName=‘Ashwinkumar’, Address=‘Cityview’
WHERE CustomerID=123;
UPDATE
11. DELETE FROM table_name
WHERE some_column=some_value;
• Example:
DELETE FROM Customer
WHERE CustomerID=123;
DELETE
12. SELECT column_name_1, column_name_2
FROM table_name ;
SELECT * FROM table_name ;
Example:
SELECT LastName, FirstName, City
FROM Customer;
SELECT * FROM Customer;
SELECT
13. DROP TABLE IF EXISTS ‘table_name’;
TRUNCATE TABLE ‘table_name’;
Example:
DROP TABLE IF EXISTS Customer;
TRUNCATE TABLE Customer;
So, What is the difference between DROP and TRUNCATE ??
DROP & TRUNCATE TABLE
14. • AVG() Function
• SUM() Function
• MIN() and MAX() Functions
• COUNT() Function
SUMMARY FUNCTIONS
15. • GREATEST() – It returns greatest value
Ex: SELECT GREATEST(4, 83, 0, 9, -3); 83
• LEAST() – It returns least value
Ex: SELECT LEAST(4, 83, 0, 9, -3); -3
• ISNULL()- It returns a value of 1 if the expression evaluates
to NULL; otherwise, the function returns a value of 0
Ex: SELECT ISNULL(1*NULL); 1
COMPARISON FUNCTIONS
16. • CEIL() or CEILING(): SELECT CEILING(9.327); 10
• FLOOR(): SELECT CEILING(9.327); 9
• COT(<number>) : Calculates cotangent of number
• MOD(n1,n2) : Returns the remainder derived by dividing two
numbers(n1/n2)
• PI() : Returns 3.141593.
• POW(<number>, <power>) and POWER(<number>, <power>): Raises
the value of one number to the power of the second number
• ROUND(4.27943, 2) 4.28
• TRUNCATE(4.27943, 2) 4.27
• SQRT(36) 6
NUMERIC FUNCTIONS
17. CAST(<expression> AS <type>)
Ex: SELECT CAST(20041031 AS DATE);
• The conversion types available to the CAST() function are as follows:
❑ BINARY
❑ CHAR
❑ DATE
❑ DATETIME
❑ SIGNED and UNSIGNED [INTEGER]
❑ TIME
CONVERT(<expression>, <type>)
• The CONVERT() function allows you to convert dates in the same way as the CAST()
function
CAST FUNCTIONS
18. • IF() :
IF(<expression1>, <expression2>, <expression3)
If <expression1> evaluates to true, then the function returns <expression2>;
otherwise, the function returns <expression3>
• IFNULL():
IFNULL(<expression1>, <expression2>)
The function returns <expression1> if it is not NULL; otherwise, it returns
<expression2>
NULLIF():
IFNULL(<expression1>, <expression2>)
The NULLIF() function returns NULL if <expression1> equals <expression2>;
otherwise, it returns <expression1>
CONTROL FLOW FUNCTIONS
19. CASE():
CASE WHEN <expression> THEN <result>
[{WHEN <expression> THEN <result>}...]
[ELSE <result>]
END
The WHEN...THEN clause specifies the expression to be evaluated and the results to be returned if that expression
evaluates to true
CASE <expression>
WHEN <value> THEN <result>
[{WHEN <value> THEN <result>}...]
[ELSE <result>]
END
The main difference in this version of the CASE() function is that the expression is specified after the keyword CASE,
and the WHEN...THEN clauses include the possible values that result from that expression.
CONTROL FLOW CONT’D…
20. • CURDATE(), CURRENT_DATE(), CURTIME(), CURRENT_TIME(),
CURRENT_TIMESTAMP(), NOW() : Retrieve current date and
time information
• DATE(), MONTH(), MONTHNAME(), and YEAR(): Allows you to
extract specific information from a date or time value.
• DATEDIFF() and TIMEDIFF() : Determines the differences
between dates and times
• DAY(), DAYOFMONTH(), DAYNAME(), DAYOFWEEK(), and
DAYOFYEAR() : Allows you to pull day-related values out of
date or date/time values
• SECOND(), MINUTE(), HOUR(), and TIME(): Extract time parts
from a time or date/time value
DATE/TIME FUNCTIONS
21. • CHAR_LENGTH(), CHARACTER_LENGTH(): Both returns the
number of characters in the specified string
• LENGTH() : It returns the length of a string, only the length is
measured in bytes, rather than characters.
• CHARSET() and COLLATION() : Returns Character Set and
Collation type of database
• CONCAT() and CONCAT_WS() : allow you to concatenate
data.
• LCASE(), LOWER(), UCASE(), and UPPER() : allow you to
change string values to upper or lowercase
• LEFT(<string>, <length>) and RIGHT(<string>, <length>): The
<length> value determines how many characters are
returned, starting at the left/right end of the string
• REPEAT(<string>, <count>) and REVERSE(<string>)
STRING FUNCTIONS
23. • Joins enable you to retrieve related data from different tables and
display that data in one results set.
• It combine rows from two or more tables, based on a common
field between them.
JOIN
24. • Now when we look at the data of Product table we can see Vendor and Category in
the form of a foreign key i.e. a number.
• If we want to see a table with three columns namely productname, VendorName and
CategoryName we will have to link the above tables. This link is called as ‘JOIN’.
• There are 6 types of Joins – Inner Join, Left Outer Join, Right Outer Join, Full Join, Self Join
and Cross Join. Lets look at each of them.
JOIN
25. • The INNER JOIN selects only those rows from both tables
where there is a match between the common column in
both tables.
INNER JOIN
26. INNER JOIN - EXAMPLE
If we want to create a temporary table, just for
display sake with two columns, first column being
ProductName and second column being
VendorName, we create a Join between the
two tables on the common column which in this
case is VendorID
As you can see only the columns with common VendorIDs are displayed. Since there is no product with
VendorID 9,10 or 11, those Vendor Names are not displayed. This is called as inner join.
27. • SELECT column 1, column 2, column 3, etc.
FROM table1
JOIN/INNER JOIN table2
ON table1.column_name=table2.column_name;
INNER JOIN - SYNTAX
28. • Left outer join
• Right outer join
• Full outer join
OUTER JOINS
29. • Return all rows from the left table, and the matched rows
from the right table
• The result is NULL in the right side when there is no match
• Also called as ‘left join’
LEFT OUTER JOIN
30. LEFT OUTER JOIN - EXAMPLE
If we want to include all the vendornames
irrespective of if they are present in the
product table we use left outer join
keeping Vendor table on the left
Thus it includes every value present in the left table and displays ‘Null”
value in the other column. Thus we can understand that there is no
product from the vendors like Dell, Panasonic and HP.
31. LEFT JOIN - SYNTAX
SELECT column 1, column 2, column 3, etc.
FROM table1
LEFT JOIN/LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;
32. • Return all rows from the right table, and the matched
rows from the left table
• The result is NULL in the right side when there is no match
• Also called as ‘right join’
RIGHT OUTER JOIN
33. RIGHT OUTER JOIN - EXAMPLE
Right Outer Join works exactly like
left outer join but in the reverse way.
In the above query we have created a right join on Vendor and
product in which product table is on the right.
Since there are no such values in Product which aren’t present in
Vendor, the result displayed is same as inner join result.
34. RIGHT JOIN - SYNTAX
SELECT column 1, column 2, column 3, etc.
FROM table1
RIGHT JOIN/RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;
35. • The FULL OUTER JOIN returns all rows from the left table and from
the right table.
• It combines the result of both LEFT and RIGHT joins.
FULL OUTER JOIN
36. FULL OUTER JOIN EXAMPLE
Full Join displays all rows of the foreign key
column from both the tables irrespective of
if that value is present in the other table.
Can you
guess?
Since there is no such value of foreign key in Product table which isn’t
in Vendor table, this query will give results similar to those of left join on
vendor and product or right join on product and vendor.
37. FULL OUTER JOIN - SYNTAX
SELECT column 1, column 2, column 3, etc.
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;
38. • Returns the Cartesian product of rows from tables in the join.
• It will produce rows which combine each row from the first table with each row
from the second table
• Within SELECT statement, use CROSS JOIN explicitly or implicitly
CROSS JOIN
39. CROSS JOIN - EXAMPLE
This is the least used join and most basic
one. It includes all rows from both the tables
in the result set. The result set is the Cartesian
product of both the tables, such that all the
rows from one table combined with all the
rows from another table.
It will contain 11* 7 = 77 rows.
40. • A self-join occurs when a table is joined to itself rather than to another table
• Self-joins are also very useful in conjunction with subqueries
• When joining a table to itself, you must give the table an alias
• To give a table or column an alias, you simply put the keyword AS after the
table or column name and specify what you want the table to be known as.
SELECT VendorName AS VN
FROM Vendor
SELF JOIN
41. • If you need to compare the same fields but different records, you need a self-join.
• If you want to know all the students who stay at the same address
SELECT D1.StudentId, D1.Name, D1.Address, D2.StudentId,D2.Name, D2.Address
FROM Details AS D1 INNER JOIN Details AS D2
ON D1.Address = D2.Address AND
D1.StudentId < D2.StudentId;
SELF JOIN - EXAMPLE
StudentId Name Address
1 Tanmay 75 St. Alphonsus Street
2 Ashwin 75 St. Alphonsus Street
3 Shubham 22 parker street
4 Devashri 22 parker street
42. • At times, you might want to combine the results of two quite distinct queries.
There may be no link between the results of each query; you just want to display
them all in one results set.
• You can join the results from two or more SELECT queries into one results set by
using the UNION operator.
• Each query must produce the same number of columns and columns’ data
types must be the same
OPERATORS – UNION, UNION ALL
SELECT myColumn, myOtherColumn, someColumn FROM MyTable
UNION
SELECT anotherColumn, yetAnotherColumn, MoreColumn FROM MyOtherTable;
SELECT myColumn FROM MyTable
UNION
SELECT anotherColumn, yetAnotherColumn, MoreColumn FROM MyOtherTable;