Unit 10 : SQL ( Part 2 ) Flashcards
What keyword do we need to add to make changes to table structure?
- ALTER
- Add
- Modify
- Drop
- It can be used to change data type
Some RDBMS ( Oracle ) do not permit changes to data types unless what?
- Column to be changed is empty
What actions does some RDBMS impose restrictions on the deletion of an attribute?
- Use ALTER to drop down
List out the useful functions that SQL provides
- Count
- Find minimum and maximun values
- Calculates averages
List out the aggregate functions
- Count
- Min
- Max
- Sum
- Avg
What is a view?
- A virtual table based on SELECT query
What can a view contain?
- Columns
- Computed Columns
- Aliases
- Aggregate Functions
How can we create a view?
- Using CREATE VIEW to generate view
What is the most important disrinction between relational database and other databases?
- Ability to combine ( join ) tables on common attributes ( primary keys )
When is JOIN performed?
- When data are retrieved from more than one table at a time
What does JOIN is generally composed?
- Equality comparison between foreign key and primary key of related tables
What can alias be used to?
- Identify source source table
- Any legal table name can be used as alias
How to join tables with alias?
- Use the FROM clause
- FROM tablename alias
What is aggregate functions?
- Special functions that perform arithmetic computations over a set of rows
What does the ORDER BY clause used to?
- Sort output of SELECT statement
- Can sort by one or more columns and use either an ascending or descending order
When does Right Outer Join and Left Outer Join is used?
- Used to select rows that have no matching values in other related table
How does Inner Join joins both tables?
- Returns rows where there is a match in both tables
How does Left Join joins both tables?
- Returns all rows from the left table along with the matching rows from the right table
- If records from left table doesn’t appear from right table, it will show NULL values
- LEFT JOIN Orders
How does Right Join joins both tables?
- Returns all rows from the right table along with the matching rows from the left table
- If records from right table doesn’t appear from left table, it will show NULL values
What JOINS does FULL JOIN combines? ( 2 )
- LEFT JOIN
- RIGHT JOIN
How does Full Join ( Full Outer Join ) joins both tables?
- Returns all rows when there is a match in either the left or right table, if no match is found, NULL values are returned