50 likes | 226 Views
S tructured Q uery L anguage - SQL. Industry standard data access language Developed by a number of companies in the 80’s However, there are slight variations in using SQL each RDBMS SQL types: DDL – data definition language Used by DBAs and developers to create db objects.
E N D
Structured Query Language - SQL • Industry standard data access language • Developed by a number of companies in the 80’s • However, there are slight variations in using SQL each RDBMS • SQL types: • DDL – data definition language • Used by DBAs and developers to create db objects. • Used to create BI objects • DML – data manipulation language • Used by DBAs, developers, and power users to access data in databases. • Used to retrieve data from a data warehouse.
SQL - DML • Based on a command (CRUD), data, criteria: • Commands: select, insert, update, delete • Data: lists the table and views to be utilized • Criteria: limits the subset of the data • Examples: • Select * from customer • retrieves all rows and columns from a customer table • Select ID, name from customer where customer id = 15 • retrieves customer 15’s id and name • Select distinct order id from order line • Retrieve an unduplicated list of orders
SQL - Criteria • Where clause • Limit the subset of data accessed • Select * from faculty where course id = ‘isom445’ • Join tables • Select student name from student, enrollment where course id = ‘isom445’ and student.student ID = enrollment.student id
SQL Operators • Multiple criteria may be linked with and / or: • Where customer id = 15 and product color = red • Where customer id = 15 or product color = red • Criteria may use and & or: • Where customer id = 15 or (customer id = 12 and color = red)
SQL Sorting and Grouping • Order By – clause: • Order by city, state • Ascending (asc) or descending (desc) • Group By – clause: • Summarize data on the group by column • Select count(*) from customer group by state • May apply functions on whole set or subset of the data • Average • Sum